Documentation ¶
Overview ¶
Example ¶
package main import ( "google.golang.org/grpc" grpcopentracing "github.com/grpc-ecosystem/go-grpc-middleware/providers/opentracing/v2" "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/tracing" ) func main() { _ = grpc.NewServer( grpc.ChainUnaryInterceptor( tracing.UnaryServerInterceptor(grpcopentracing.InterceptorTracer()), ), grpc.ChainStreamInterceptor( tracing.StreamServerInterceptor(grpcopentracing.InterceptorTracer()), ), ) _, _ = grpc.Dial("", grpc.WithUnaryInterceptor(tracing.UnaryClientInterceptor(grpcopentracing.InterceptorTracer())), grpc.WithStreamInterceptor(tracing.StreamClientInterceptor(grpcopentracing.InterceptorTracer())), ) }
Output:
Index ¶
Examples ¶
Constants ¶
View Source
const ( TagTraceId = "trace.traceid" TagSpanId = "trace.spanid" TagSampled = "trace.sampled" )
Variables ¶
This section is empty.
Functions ¶
func ClientAddContextTags ¶
ClientAddContextTags returns a context with specified opentracing tags, which are used by UnaryClientInterceptor/StreamClientInterceptor when creating a new span.
func InterceptorTracer ¶
func InterceptorTracer(opts ...Option) *tracer
InterceptorTracer converts OpenTracing tracer to Tracer adapter.
Types ¶
type Option ¶
type Option func(*options)
func WithTraceHeaderName ¶
WithTraceHeaderName customizes the trace header name where trace metadata passed with requests. Default one is `uber-trace-id`
func WithTracer ¶
func WithTracer(tracer opentracing.Tracer) Option
WithTracer sets a custom tracer to be used for this middleware, otherwise the opentracing.GlobalTracer is used.
Click to show internal directories.
Click to hide internal directories.