MCPcopy
hub / github.com/grpc/grpc-go / DialOption

Function DialOption

stats/opentelemetry/opentelemetry.go:124–138  ·  view source on GitHub ↗

DialOption returns a dial option which enables OpenTelemetry instrumentation code for a grpc.ClientConn. Client applications interested in instrumenting their grpc.ClientConn should pass the dial option returned from this function as a dial option to grpc.NewClient(). For the metrics supported by

(o Options)

Source from the content-addressed store, hash-verified

122// For the traces supported by this instrumentation code, provide an
123// implementation of a TextMapPropagator and OpenTelemetry TracerProvider.
124func DialOption(o Options) grpc.DialOption {
125 var metricsOpts, tracingOpts []grpc.DialOption
126
127 if o.isMetricsEnabled() {
128 metricsHandler := &clientMetricsHandler{options: o}
129 metricsHandler.initializeMetrics()
130 metricsOpts = append(metricsOpts, grpc.WithChainUnaryInterceptor(metricsHandler.unaryInterceptor), grpc.WithChainStreamInterceptor(metricsHandler.streamInterceptor), grpc.WithStatsHandler(metricsHandler))
131 }
132 if o.isTracingEnabled() {
133 tracingHandler := &clientTracingHandler{options: o}
134 tracingHandler.initializeTraces()
135 tracingOpts = append(tracingOpts, grpc.WithChainUnaryInterceptor(tracingHandler.unaryInterceptor), grpc.WithChainStreamInterceptor(tracingHandler.streamInterceptor), grpc.WithStatsHandler(tracingHandler))
136 }
137 return joinDialOptions(append(metricsOpts, tracingOpts...)...)
138}
139
140var joinServerOptions = internal.JoinServerOptions.(func(...grpc.ServerOption) grpc.ServerOption)
141

Callers 15

runDisconnectLabelTestFunction · 0.92
mainFunction · 0.92
setupStubServerFunction · 0.92
TestWRRMetricsMethod · 0.92
TestSubChannelMetricsMethod · 0.92

Calls 7

initializeMetricsMethod · 0.95
initializeTracesMethod · 0.95
WithStatsHandlerFunction · 0.92
isMetricsEnabledMethod · 0.80
isTracingEnabledMethod · 0.80