datadog

package
v0.0.0-...-fee7787 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2021 License: MIT Imports: 5 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL