m/n/c/rpc: implement Span/Trace
This is a first pass at implementing basic support for
Dapper/OpenTracing/OpenTelemetry-style tracing within Metropolis RPCs.
More precisely, this implements an API to expose an RPC-local Span to
RPC handlers (unary and streaming). These Spans are currently backed by
a logtree logger, and aren't processed further (ie. there's no support
for child spans and carrying span information over the wire when
performing remote calls from an active Span). However, this allows us to
at least start emitting Span Events and use them for debugging purposes.
Since we don't yet have OpenTelemetry in our GOPATH, we reimplement a
minimum subset of the Span type that should still be compatible with
real OpenTelemetry types. Once OpenTelemetry lands in our GOPATH (by way
of it landing in k8s, for example), we'll move over to using the real
type instead. Then, we can also begin integrating with OpenTelemetry
proper, ie. start sending traces over to collectors, start
injecting/extracing span information over gRPC, etc.
Another change on top of this one actually uses the Trace(ctx)
functionality within the curator - this is just the library
implementation.
Change-Id: I85506303538aacc137a28828ab39ccfd9ff72924
Reviewed-on: https://review.monogon.dev/c/monogon/+/541
Reviewed-by: Leopold Schabel <leo@nexantic.com>
diff --git a/metropolis/node/core/rpc/BUILD.bazel b/metropolis/node/core/rpc/BUILD.bazel
index d281a92..e749968 100644
--- a/metropolis/node/core/rpc/BUILD.bazel
+++ b/metropolis/node/core/rpc/BUILD.bazel
@@ -8,13 +8,16 @@
"peerinfo.go",
"server.go",
"server_authentication.go",
+ "server_interceptors.go",
"testhelpers.go",
+ "trace.go",
],
importpath = "source.monogon.dev/metropolis/node/core/rpc",
visibility = ["//visibility:public"],
deps = [
"//metropolis/node/core/curator/proto/api:go_default_library",
"//metropolis/node/core/identity:go_default_library",
+ "//metropolis/pkg/logtree:go_default_library",
"//metropolis/pkg/pki:go_default_library",
"//metropolis/proto/api:go_default_library",
"//metropolis/proto/ext:go_default_library",
@@ -24,6 +27,7 @@
"@org_golang_google_grpc//peer:go_default_library",
"@org_golang_google_grpc//status:go_default_library",
"@org_golang_google_grpc//test/bufconn:go_default_library",
+ "@org_golang_google_protobuf//encoding/prototext:go_default_library",
"@org_golang_google_protobuf//proto:go_default_library",
"@org_golang_google_protobuf//reflect/protoreflect:go_default_library",
"@org_golang_google_protobuf//reflect/protoregistry:go_default_library",
@@ -32,10 +36,14 @@
go_test(
name = "go_default_test",
- srcs = ["server_authentication_test.go"],
+ srcs = [
+ "server_authentication_test.go",
+ "trace_test.go",
+ ],
embed = [":go_default_library"],
deps = [
"//metropolis/node/core/curator/proto/api:go_default_library",
+ "//metropolis/pkg/logtree:go_default_library",
"//metropolis/proto/api:go_default_library",
"//metropolis/proto/ext:go_default_library",
"@org_golang_google_grpc//codes:go_default_library",