go.temporal.io/server/common/telemetry/env.go
79 LOC · 30 covered · 49 uncovered · 12 ranges · 74 concepts · 10 introducers · 19 tests
File neighbourhood
The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.
Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file
In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.
Graph controls are ready.
Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.
package telemetry
import (
"errors"
"fmt"
"strings"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
otelsdktrace "go.opentelemetry.io/otel/sdk/trace"
"go.temporal.io/server/common/primitives"
)
var (
unsupportedTraceExporter = errors.New("unsupported OTEL exporter")
unsupportedTraceExporterProtocol = errors.New("unsupported OTEL exporter protocol")
)
const (
OtelServiceNameEnvKey = "OTEL_SERVICE_NAME"
OtelTracesExporterTypesEnvKey = "OTEL_TRACES_EXPORTER"
OtelTracesOtlpExporterType = SpanExporterType("otlp")
OtelExporterOtlpTracesProtocolEnvKey = "OTEL_EXPORTER_OTLP_TRACES_PROTOCOL"
OtelExporterOtlpTracesGrcpProtocol = "grpc"
)
type envVarLookup = func(string) (string, bool)
// SpanExportersFromEnv creates OTEL span exporters from environment variables.
func SpanExportersFromEnv(
envVars envVarLookup,
exporters := map[SpanExporterType]otelsdktrace.SpanExporter{}
exporterTypes, ok := envVars(OtelTracesExporterTypesEnvKey)
if !ok {
}
switch SpanExporterType(exporterType) {
case OtelTracesOtlpExporterType:
// only grpc is supported; fail if user requests a different protocol
if protocol, exists := envVars(OtelExporterOtlpTracesProtocolEnvKey); exists {
if !isSupported {
return nil, fmt.Errorf("%w: %v=%v", unsupportedTraceExporterProtocol, OtelExporterOtlpTracesProtocolEnvKey, protocol)
}
}
// other OTEL configuration env variables are picked up automatically by the exporter itself
case "none":
// ignored
return nil, fmt.Errorf("%w: %v=%v", unsupportedTraceExporter, OtelTracesExporterTypesEnvKey, exporterType)
}
}
}
// ResourceServiceName returns the OpenTelemetry tracing service name for a Temporal service.
func ResourceServiceName(
rsn primitives.ServiceName,
envVars envVarLookup,
// map "internal-frontend" to "frontend" for the purpose of tracing
if rsn == primitives.InternalFrontendService {
}
// allow custom prefix via env vars
if customServicePrefix, found := envVars(OtelServiceNameEnvKey); found {
}
}