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)
| 122 | // For the traces supported by this instrumentation code, provide an |
| 123 | // implementation of a TextMapPropagator and OpenTelemetry TracerProvider. |
| 124 | func 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 | |
| 140 | var joinServerOptions = internal.JoinServerOptions.(func(...grpc.ServerOption) grpc.ServerOption) |
| 141 |