0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2025-04-01 02:42:35 -05:00

Update tracer.go

This commit is contained in:
Archimedes Trajano 2024-07-28 04:58:07 -04:00 committed by GitHub
parent 976469ca0d
commit 12704e8839
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)
}