From 17e749282d8d405ecbb4ee527e50cbdd0215d104 Mon Sep 17 00:00:00 2001 From: Saylor Berman Date: Thu, 18 Jul 2024 16:00:14 -0600 Subject: [PATCH] Add missing GRPC header (#165) Problem: F5 telemetry service requires the presence of the `X-F5-OTEL` header set to `GRPC`. Solution: Rather than having users of the library set this value, set it by default in the exporter. --- pkg/telemetry/span_provider.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/telemetry/span_provider.go b/pkg/telemetry/span_provider.go index aa169e1..74d289e 100644 --- a/pkg/telemetry/span_provider.go +++ b/pkg/telemetry/span_provider.go @@ -23,7 +23,13 @@ func CreateOTLPSpanProvider(options ...otlptracegrpc.Option) SpanProvider { // newOTLPExporter creates a new gRPC OTLP exporter. func newOTLPExporter(ctx context.Context, options ...otlptracegrpc.Option) (*otlptrace.Exporter, error) { - traceClient := otlptracegrpc.NewClient(options...) + defaultOptions := []otlptracegrpc.Option{ + otlptracegrpc.WithHeaders(map[string]string{ + "X-F5-OTEL": "GRPC", + }), + } + + traceClient := otlptracegrpc.NewClient(append(defaultOptions, options...)...) exp, err := otlptrace.New(ctx, traceClient) if err != nil { return nil, fmt.Errorf("failed to create OTLP exporter: %w", err)