mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-02 19:04:14 +02:00
telemetry: support b3 headers on gRPC server calls (#2376)
This commit is contained in:
parent
a02010409a
commit
fbf44261c1
3 changed files with 59 additions and 6 deletions
|
@ -6,6 +6,9 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.opencensus.io/plugin/ocgrpc"
|
||||
"go.opencensus.io/plugin/ochttp/propagation/b3"
|
||||
"go.opencensus.io/trace"
|
||||
"google.golang.org/grpc/metadata"
|
||||
grpcstats "google.golang.org/grpc/stats"
|
||||
)
|
||||
|
||||
|
@ -28,9 +31,17 @@ func Test_GRPCServerStatsHandler(t *testing.T) {
|
|||
}
|
||||
|
||||
ctx := context.WithValue(context.Background(), mockCtxTag("original"), "true")
|
||||
ctx = metadata.NewIncomingContext(ctx, metadata.MD{
|
||||
b3TraceIDHeader: {"9de3f6756f315fef"},
|
||||
b3SpanIDHeader: {"b4f83d3096b6bf9c"},
|
||||
})
|
||||
ctx = h.TagRPC(ctx, &grpcstats.RPCTagInfo{})
|
||||
|
||||
assert.True(t, metricsHandler.called)
|
||||
assert.Equal(t, ctx.Value(mockCtxTag("added")), "true")
|
||||
assert.Equal(t, ctx.Value(mockCtxTag("original")), "true")
|
||||
|
||||
span := trace.FromContext(ctx)
|
||||
expectedTraceID, _ := b3.ParseTraceID("9de3f6756f315fef")
|
||||
assert.Equal(t, expectedTraceID, span.SpanContext().TraceID)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue