m/p/api: use protobuf.Timestamp in LogEntry
This updates LogEntry to use google.protobuf.Timestamp.
See: issue #129.
Change-Id: I937800aa91e86690da0d06f743e720c2d474ad0a
Reviewed-on: https://review.monogon.dev/c/monogon/+/832
Tested-by: Jenkins CI
Reviewed-by: Sergiusz Bazanski <serge@monogon.tech>
diff --git a/metropolis/pkg/logtree/BUILD.bazel b/metropolis/pkg/logtree/BUILD.bazel
index 0df5679..aabc40d 100644
--- a/metropolis/pkg/logtree/BUILD.bazel
+++ b/metropolis/pkg/logtree/BUILD.bazel
@@ -21,6 +21,7 @@
deps = [
"//metropolis/pkg/logbuffer",
"//metropolis/proto/api",
+ "@org_golang_google_protobuf//types/known/timestamppb",
],
)
diff --git a/metropolis/pkg/logtree/leveled_payload.go b/metropolis/pkg/logtree/leveled_payload.go
index a9ba56d..909d88a 100644
--- a/metropolis/pkg/logtree/leveled_payload.go
+++ b/metropolis/pkg/logtree/leveled_payload.go
@@ -22,6 +22,8 @@
"strings"
"time"
+ tpb "google.golang.org/protobuf/types/known/timestamppb"
+
apb "source.monogon.dev/metropolis/proto/api"
)
@@ -114,7 +116,7 @@
func (p *LeveledPayload) Proto() *apb.LogEntry_Leveled {
return &apb.LogEntry_Leveled{
Lines: p.Messages(),
- Timestamp: p.Timestamp().UnixNano(),
+ Timestamp: tpb.New(p.Timestamp()),
Severity: p.Severity().ToProto(),
Location: p.Location(),
}
@@ -137,7 +139,7 @@
}
return &LeveledPayload{
messages: p.Lines,
- timestamp: time.Unix(0, p.Timestamp),
+ timestamp: p.Timestamp.AsTime(),
severity: severity,
file: file,
line: line,
diff --git a/metropolis/proto/api/BUILD.bazel b/metropolis/proto/api/BUILD.bazel
index 5bc5640..a333b96 100644
--- a/metropolis/proto/api/BUILD.bazel
+++ b/metropolis/proto/api/BUILD.bazel
@@ -15,6 +15,7 @@
"//metropolis/proto/common:common_proto",
"//metropolis/proto/ext:ext_proto",
"@com_google_protobuf//:duration_proto",
+ "@com_google_protobuf//:timestamp_proto",
],
)
diff --git a/metropolis/proto/api/debug.proto b/metropolis/proto/api/debug.proto
index eabc766..c8deb73 100644
--- a/metropolis/proto/api/debug.proto
+++ b/metropolis/proto/api/debug.proto
@@ -18,6 +18,8 @@
package metropolis.proto.api;
option go_package = "source.monogon.dev/metropolis/proto/api";
+import "google/protobuf/timestamp.proto";
+
// NodeDebugService exposes debug and testing endpoints that allow introspection into a running Metropolis node.
// It is not authenticated and will be disabled in production. It is currently consumed by metropolis/cli/dbg and
// by tests.
@@ -145,7 +147,7 @@
message LogEntry {
message Leveled {
repeated string lines = 1;
- int64 timestamp = 2;
+ google.protobuf.Timestamp timestamp = 2;
LeveledLogSeverity severity = 3;
string location = 4;
}
@@ -177,4 +179,4 @@
message TraceEvent {
// Currently we do not parse the event data and just return what the kernel outputs, line-by-line.
string raw_line = 1;
-}
\ No newline at end of file
+}