Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LogrusDDTraceContextInjector ¶
func LogrusDDTraceContextInjector(entry *logrus.Entry) grpc.UnaryServerInterceptor
LogrusDDTraceContextInjector adds dd.trace_id, dd.span_id as logrus entry fields and puts new log entry into the context. Other interceptors can pick the log entry with ctxlogrus.Extract and add extra data. This interceptor must be used after grpctrace.UnaryServerInterceptor (from "gopkg.in/DataDog/dd-trace-go.v1/contrib/google.golang.org/grpc") and before grpc_logrus.UnaryServerInterceptor (from github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus)
Example:
ddtracer.Start() defer ddtracer.Flush() l := logrus.New() l.Out = os.Stderr logger := logrus.NewEntry(l) server := grpctest.NewServer(grpc_middleware.WithUnaryServerChain( grpctrace.UnaryServerInterceptor(), grpc_ctxtags.UnaryServerInterceptor(grpc_ctxtags.WithFieldExtractor(grpc_ctxtags.CodeGenRequestFieldExtractor)), midleware.LogrusDDTraceContextInjector(logger), grpc_logrus.UnaryServerInterceptor(logger), ))
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.