* Adding a way to inject a request ID It is very useful to associate a request ID to each incoming request, this change allows to provide a function to do that via Server Option. The change comes with a default function which will generate a new request ID. The request ID is put in the request context along with a common logger which always logs the request-id We add gRPC interceptors to the server so it can get the request ID out of the gRPC metadata and put it in the common logger stored in the context so as all the log lines using the common logger from the context will have the request ID logged
grpc_opentracing
import "github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing"
Overview
grpc_opentracing adds OpenTracing
OpenTracing Interceptors
These are both client-side and server-side interceptors for OpenTracing. They are a provider-agnostic, with backends such as Zipkin, or Google Stackdriver Trace.
For a service that sends out requests and receives requests, you need to use both, otherwise downstream requests will not have the appropriate requests propagated.
All server-side spans are tagged with grpc_ctxtags information.
For more information see: http://opentracing.io/documentation/ https://github.com/opentracing/specification/blob/master/semantic_conventions.md
Imported Packages
- github.com/grpc-ecosystem/go-grpc-middleware
- github.com/grpc-ecosystem/go-grpc-middleware/tags
- github.com/grpc-ecosystem/go-grpc-middleware/util/metautils
- github.com/opentracing/opentracing-go
- github.com/opentracing/opentracing-go/ext
- github.com/opentracing/opentracing-go/log
- golang.org/x/net/context
- google.golang.org/grpc
- google.golang.org/grpc/grpclog
- google.golang.org/grpc/metadata
Index
- Constants
- func ClientAddContextTags(ctx context.Context, tags opentracing.Tags) context.Context
- func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor
- func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor
- func UnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor
- func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor
- type FilterFunc
- type Option
Package files
client_interceptors.go doc.go id_extract.go metadata.go options.go server_interceptors.go
Constants
const (
TagTraceId = "trace.traceid"
TagSpanId = "trace.spanid"
)
func ClientAddContextTags
func ClientAddContextTags(ctx context.Context, tags opentracing.Tags) context.Context
ClientAddContextTags returns a context with specified opentracing tags, which are used by UnaryClientInterceptor/StreamClientInterceptor when creating a new span.
func StreamClientInterceptor
func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor
StreamClientInterceptor returns a new streaming client interceptor for OpenTracing.
func StreamServerInterceptor
func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor
StreamServerInterceptor returns a new streaming server interceptor for OpenTracing.
func UnaryClientInterceptor
func UnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor
UnaryClientInterceptor returns a new unary client interceptor for OpenTracing.
func UnaryServerInterceptor
func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor
UnaryServerInterceptor returns a new unary server interceptor for OpenTracing.
type FilterFunc
type FilterFunc func(ctx context.Context, fullMethodName string) bool
FilterFunc allows users to provide a function that filters out certain methods from being traced.
If it returns false, the given request will not be traced.
type Option
type Option func(*options)
func WithFilterFunc
func WithFilterFunc(f FilterFunc) Option
WithFilterFunc customizes the function used for deciding whether a given call is traced or not.
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.
Generated by godoc2ghmd