MCPcopy
hub / github.com/docker/compose / traceClientFromEnv

Function traceClientFromEnv

internal/tracing/tracing.go:123–145  ·  view source on GitHub ↗

traceClientFromEnv creates a GRPC OTLP client based on OS environment variables. https://opentelemetry.io/docs/concepts/sdk-configuration/otlp-exporter-configuration/

()

Source from the content-addressed store, hash-verified

121//
122// https://opentelemetry.io/docs/concepts/sdk-configuration/otlp-exporter-configuration/
123func traceClientFromEnv() (otlptrace.Client, envMap) {
124 hasOtelEndpointInEnv := false
125 otelEnv := make(map[string]string)
126 for _, kv := range os.Environ() {
127 k, v, ok := strings.Cut(kv, "=")
128 if !ok {
129 continue
130 }
131 if strings.HasPrefix(k, "OTEL_") {
132 otelEnv[k] = v
133 if strings.HasSuffix(k, "ENDPOINT") {
134 hasOtelEndpointInEnv = true
135 }
136 }
137 }
138
139 if !hasOtelEndpointInEnv {
140 return nil, nil
141 }
142
143 client := otlptracegrpc.NewClient()
144 return client, otelEnv
145}

Callers 1

InitProviderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected