From 12704e88396428e693db09f4499e30a7708e54e0 Mon Sep 17 00:00:00 2001 From: Archimedes Trajano Date: Sun, 28 Jul 2024 04:58:07 -0400 Subject: [PATCH] Update tracer.go --- modules/caddyhttp/tracing/tracer.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/caddyhttp/tracing/tracer.go b/modules/caddyhttp/tracing/tracer.go index 89c617bf4..8fbc3cea0 100644 --- a/modules/caddyhttp/tracing/tracer.go +++ b/modules/caddyhttp/tracing/tracer.go @@ -4,10 +4,12 @@ import ( "context" "fmt" "net/http" + "os" "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" "go.opentelemetry.io/contrib/propagators/autoprop" "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" + "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp" "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/sdk/resource" sdktrace "go.opentelemetry.io/otel/sdk/trace" @@ -59,7 +61,12 @@ func newOpenTelemetryWrapper( return ot, fmt.Errorf("creating resource error: %w", err) } - traceExporter, err := otlptracegrpc.New(ctx) + protocol := os.Getenv("OTEL_EXPORTER_OTLP_PROTOCOL") + if protocol == "http/protobuf" { + traceExporter, err := otlptracehttp.New(ctx) + } else { + traceExporter, err := otlptracegrpc.New(ctx) + } if err != nil { return ot, fmt.Errorf("creating trace exporter error: %w", err) }