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.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the fileworkflow_handler.go ×11 · 117 introduced LOCworkflow_handler.go ×11common.go ×1 · 11 introduced LOCcommon.go ×1request_response.pb.go ×6 · 246 introduced LOCrequest_response.pb.go ×…visibility_store.go ×17 · 171 introduced LOCvisibility_store.go ×17telemetry.go ×2 · 15 introduced LOCtelemetry.go ×2fx.go ×1 · 4 introduced LOCfx.go ×1collector.go ×7 · 33 introduced LOCcollector.go ×7data_store_factory.go ×29 · 703 introduced LOCdata_store_factory.go ×2…TestNewServer · 0 introduced LOCTestNewServerpri_matcher.go ×1 · 2 introduced LOCpri_matcher.go ×1timer_queue_active_task_executor.go ×1 · 3 introduced LOCtimer_queue_active_task_…TestNewServer · 0 introduced LOCTestNewServermetric_client.go ×3 · 18 introduced LOCmetric_client.go ×3request_response.pb.go ×12 · 137 introduced LOCrequest_response.pb.go ×…workflow_task_completed_handler.go ×9 · 75 introduced LOCworkflow_task_completed_…pri_forwarder.go ×2 · 4 introduced LOCpri_forwarder.go ×2request_response.pb.go ×1 · 7 introduced LOCrequest_response.pb.go ×…logger.go ×1 · 5 introduced LOClogger.go ×1connections.go ×1 · 9 introduced LOCconnections.go ×1persistence_rate_limited_clients.go ×2 · 17 introduced LOCpersistence_rate_limited…logger.go ×1 · 2 introduced LOClogger.go ×1metric_client.go ×2 · 7 introduced LOCmetric_client.go ×2pri_matcher.go ×1 · 4 introduced LOCpri_matcher.go ×1task_queue_partition_manager.go ×2 · 10 introduced LOCtask_queue_partition_man…connections.go ×2 · 12 introduced LOCconnections.go ×2workflow_handler.go ×8 · 144 introduced LOCworkflow_handler.go ×8pri_matcher.go ×1 · 2 introduced LOCpri_matcher.go ×1handler.go ×1 · 20 introduced LOChandler.go ×1pri_matcher.go ×8 · 55 introduced LOCpri_matcher.go ×8matching_engine.go ×1 · 8 introduced LOCmatching_engine.go ×1server.go ×1 · 3 introduced LOCserver.go ×1logger.go ×2 · 21 introduced LOClogger.go ×2queue_scheduled.go ×1 · 2 introduced LOCqueue_scheduled.go ×1handler.go ×25 · 728 introduced LOChandler.go ×25onebox.go ×75 · 1256 introduced LOConebox.go ×75metric_client_gen.go ×4 · 50 introduced LOCmetric_client_gen.go ×4pri_forwarder.go ×1 · 6 introduced LOCpri_forwarder.go ×1matching_service_server_gen.go ×1 · 2 introduced LOCmatching_service_server_…http_api_server.go ×23 · 195 introduced LOChttp_api_server.go ×23db.go ×1 · 2 introduced LOCdb.go ×1pri_task_writer.go ×3 · 14 introduced LOCpri_task_writer.go ×3namespace_handover.go ×3 · 8 introduced LOCnamespace_handover.go ×3task_queue_partition_manager.go ×2 · 4 introduced LOCtask_queue_partition_man…matching_engine.go ×3 · 5 introduced LOCmatching_engine.go ×3service_grpc.pb.go ×19 · 357 introduced LOCservice_grpc.pb.go ×19request_response.pb.go ×6 · 114 introduced LOCrequest_response.pb.go ×…reader.go ×2 · 8 introduced LOCreader.go ×2service_grpc.pb.go ×20 · 740 introduced LOCservice_grpc.pb.go ×20endpoint_registry.go ×2 · 26 introduced LOCendpoint_registry.go ×2server.go ×3 · 13 introduced LOCserver.go ×3scanner.go ×1 · 2 introduced LOCscanner.go ×1mask_internal_error.go ×1 · 2 introduced LOCmask_internal_error.go ×…matching_engine.go ×2 · 5 introduced LOCmatching_engine.go ×2service_resolver.go ×4 · 49 introduced LOCservice_resolver.go ×4lite_server.go ×25 · 303 introduced LOClite_server.go ×25fx.go ×44 · 705 introduced LOCfx.go ×44adaptive_pool.go ×1 · 3 introduced LOCadaptive_pool.go ×1queue_immediate.go ×1 · 1 introduced LOCqueue_immediate.go ×1fx.go ×1 · 1 introduced LOCfx.go ×1service.go ×8 · 413 introduced LOCservice.go ×8rpc.go ×1 · 13 introduced LOCrpc.go ×1queue_scheduled.go ×1 · 1 introduced LOCqueue_scheduled.go ×1fx.go ×1 · 2 introduced LOCfx.go ×1fx.go ×44 · 4693 introduced LOCfx.go ×44env.go ×1 · 2 introduced LOCenv.go ×1env.go ×1 · 1 introduced LOCenv.go ×1env.go ×1 · 2 introduced LOCenv.go ×1env.go ×1 · 2 introduced LOCenv.go ×1env.go ×1 · 1 introduced LOCenv.go ×1env.go ×1 · 4 introduced LOCenv.go ×1env.go ×3 · 6 introduced LOCenv.go ×3env.go ×1 · 2 introduced LOCenv.go ×1env.go ×1 · 5 introduced LOCenv.go ×1env.go ×1 · 5 introduced LOCenv.go ×1always_use_single_service_name_for_internal_frontend · introduced test · go.temporal.io/server/common/telemetry/TestResourceServiceName/always_use_single_service_name_for_internal_frontendalways_use_single_servic…when_env_variable_is_specified,_use_custom_service_name_prefix · introduced test · go.temporal.io/server/common/telemetry/TestResourceServiceName/when_env_variable_is_specified,_use_custom_service_name_prefixwhen_env_variable_is_spe…when_not_specified,_use_default_prefix · introduced test · go.temporal.io/server/common/telemetry/TestResourceServiceName/when_not_specified,_use_default_prefixwhen_not_specified,_use_…when_env_variable_is_specified_but_exporter_type_is_not_supported,_return_error · introduced test · go.temporal.io/server/common/telemetry/TestSupplementTraceExportersFromEnv/when_env_variable_is_specified_but_exporter_type_is_not_supported,_return_errorwhen_env_variable_is_spe…when_env_variable_specifies_valid_OTEL_exporter_type,_add_exporter · introduced test · go.temporal.io/server/common/telemetry/TestSupplementTraceExportersFromEnv/when_env_variable_specifies_valid_OTEL_exporter_type,_add_exporterwhen_env_variable_specif…when_env_variable_specifies_valid_OTEL_exporter_type_but_invalid_protocol,_return_error · introduced test · go.temporal.io/server/common/telemetry/TestSupplementTraceExportersFromEnv/when_env_variable_specifies_valid_OTEL_exporter_type_but_invalid_protocol,_return_errorwhen_env_variable_specif…when_not_specified,_do_not_create_any_exporters · introduced test · go.temporal.io/server/common/telemetry/TestSupplementTraceExportersFromEnv/when_not_specified,_do_not_create_any_exporterswhen_not_specified,_do_n…TestNewServer · introduced test · go.temporal.io/server/temporal/TestNewServerTestNewServerTestNewServerWithJSONEncoding · introduced test · go.temporal.io/server/temporal/TestNewServerWithJSONEncodingTestNewServerWithJSONEnc…with_OTEL_Collector_running · introduced test · go.temporal.io/server/temporal/TestNewServerWithOTEL/with_OTEL_Collector_runningwith_OTEL_Collector_runn…without_OTEL_Collector_running · introduced test · go.temporal.io/server/temporal/TestNewServerWithOTEL/without_OTEL_Collector_runningwithout_OTEL_Collector_r…ExampleNewServer · introduced test · go.temporal.io/server/temporaltest/ExampleNewServerExampleNewServerTestBaseServerOptions · introduced test · go.temporal.io/server/temporaltest/TestBaseServerOptionsTestBaseServerOptionsTestClientWithCustomInterceptor · introduced test · go.temporal.io/server/temporaltest/TestClientWithCustomInterceptorTestClientWithCustomInte…TestDefaultWorkerOptions · introduced test · go.temporal.io/server/temporaltest/TestDefaultWorkerOptionsTestDefaultWorkerOptionsTestNewServer · introduced test · go.temporal.io/server/temporaltest/TestNewServerTestNewServerTestNewWorkerWithOptions · introduced test · go.temporal.io/server/temporaltest/TestNewWorkerWithOptionsTestNewWorkerWithOptionsTestSearchAttributeRegistration · introduced test · go.temporal.io/server/temporaltest/TestSearchAttributeRegistrationTestSearchAttributeRegis…TestWorkerServiceHealthCheck · introduced test · go.temporal.io/server/tests/testcore/TestFunctionalTestBaseSuite/TestWorkerServiceHealthCheckTestWorkerServiceHealthC…Focused file · go.temporal.io/server/common/telemetry/env.go · 79 LOCtelemetry/env.go

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.

1 package telemetry
2
3 import (
4 "errors"
5 "fmt"
6 "strings"
7
8 "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
9 otelsdktrace "go.opentelemetry.io/otel/sdk/trace"
10 "go.temporal.io/server/common/primitives"
11 )
12
13 var (
14 unsupportedTraceExporter = errors.New("unsupported OTEL exporter")
15 unsupportedTraceExporterProtocol = errors.New("unsupported OTEL exporter protocol")
16 )
17
18 const (
19 OtelServiceNameEnvKey = "OTEL_SERVICE_NAME"
20 OtelTracesExporterTypesEnvKey = "OTEL_TRACES_EXPORTER"
21 OtelTracesOtlpExporterType = SpanExporterType("otlp")
22 OtelExporterOtlpTracesProtocolEnvKey = "OTEL_EXPORTER_OTLP_TRACES_PROTOCOL"
23 OtelExporterOtlpTracesGrcpProtocol = "grpc"
24 )
25
26 type envVarLookup = func(string) (string, bool)
27
28 // SpanExportersFromEnv creates OTEL span exporters from environment variables.
29 func SpanExportersFromEnv(
30 envVars envVarLookup,
31 > ) (map[SpanExporterType]otelsdktrace.SpanExporter, error) { env.go ×1
32 > exporters := map[SpanExporterType]otelsdktrace.SpanExporter{}
33 >
34 > exporterTypes, ok := envVars(OtelTracesExporterTypesEnvKey)
35 > if !ok {
36 > return exporters, nil env.go ×1
37 > }
38
39 > for exporterType := range strings.SplitSeq(exporterTypes, ",") { env.go ×1
40 > switch SpanExporterType(exporterType) {
41 > case OtelTracesOtlpExporterType:
42 > // only grpc is supported; fail if user requests a different protocol
43 > if protocol, exists := envVars(OtelExporterOtlpTracesProtocolEnvKey); exists {
44 > isSupported := protocol == OtelExporterOtlpTracesGrcpProtocol env.go ×1
45 > if !isSupported {
46 > return nil, fmt.Errorf("%w: %v=%v", unsupportedTraceExporterProtocol, OtelExporterOtlpTracesProtocolEnvKey, protocol)
47 > }
48 }
49
50 // other OTEL configuration env variables are picked up automatically by the exporter itself
51 > exporters[OtelTracesOtlpExporterType] = otlptracegrpc.NewUnstarted() env.go ×1
52 case "none":
53 // ignored
54 > default: env.go ×1
55 > return nil, fmt.Errorf("%w: %v=%v", unsupportedTraceExporter, OtelTracesExporterTypesEnvKey, exporterType)
56 }
57 }
58
59 > return exporters, nil env.go ×1
60 }
61
62 // ResourceServiceName returns the OpenTelemetry tracing service name for a Temporal service.
63 func ResourceServiceName(
64 rsn primitives.ServiceName,
65 envVars envVarLookup,
66 > ) string { env.go ×3
67 > // map "internal-frontend" to "frontend" for the purpose of tracing
68 > if rsn == primitives.InternalFrontendService {
69 > rsn = primitives.FrontendService env.go ×1
70 > }
71
72 // allow custom prefix via env vars
73 > serviceNamePrefix := "io.temporal" env.go ×3
74 > if customServicePrefix, found := envVars(OtelServiceNameEnvKey); found {
75 > serviceNamePrefix = customServicePrefix env.go ×1
76 > }
77
78 > return fmt.Sprintf("%s.%s", serviceNamePrefix, string(rsn)) env.go ×3
79 }