tracing

package
v0.0.0-...-e2755d2 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2022 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package tracing provides func to initialize opentracing tracer using jaeger client

Index

Constants

View Source
const (
	// TagTraceID tag for trace id
	TagTraceID = "trace.traceid"
	// TagSpanID tag for span id
	TagSpanID = "trace.spanid"
	// TagSampled tag for sampled
	TagSampled = "trace.sampled"
)
View Source
const (
	// Component eg: GRPC
	Component = "component"
	// GRPCStatusCode status code
	GRPCStatusCode = "status.code"
	// GRPCResponseCode response code
	GRPCResponseCode = "response_code"
	// GRPCResponseClass response class
	GRPCResponseClass = "response_class"
)

Variables

This section is empty.

Functions

func Close

func Close() error

Close calls the closer function if initialized

func Init

func Init(env string, cnf Config, zlog *zap.Logger) error

Init initialises opentracing tracer. Returns tracer for tracing spans & closer for flushing in-memory spans before app shutdown.

func StreamServerInterceptor

func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor

StreamServerInterceptor returns a new streaming server interceptor for OpenTracing.

func UnaryServerInterceptor

func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor

UnaryServerInterceptor returns a new unary server interceptor for OpenTracing.

Types

type Class

type Class string

A Class is a set of types of outcomes (including errors) that will often be handled in the same way.

type Config

type Config struct {
	LogSpans    bool   // when set to true, reporter logs all submitted spans
	Host        string // jaeger-agent UDP binary thrift protocol endpoint
	Port        string // jaeger-agent UDP binary thrift protocol server port
	ServiceName string // name of this service used by tracer.
	Disabled    bool   // to mock tracer
}

Config ... struct expected by Init func to initialize jaeger tracing client.

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 OpNameFunc

type OpNameFunc func(method string) string

OpNameFunc is a func that allows custom operation names instead of the gRPC method.

type Option

type Option func(*options)

Option accepts a fun with options

func WithFilterFunc

func WithFilterFunc(f FilterFunc) Option

WithFilterFunc customizes the function used for deciding whether a given call is traced or not.

func WithOpName

func WithOpName(f OpNameFunc) Option

WithOpName customizes the trace Operation name

func WithTraceHeaderName

func WithTraceHeaderName(name string) Option

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.

func WithUnaryRequestHandlerFunc

func WithUnaryRequestHandlerFunc(f UnaryRequestHandlerFunc) Option

WithUnaryRequestHandlerFunc sets a custom handler for the request

type UnaryRequestHandlerFunc

type UnaryRequestHandlerFunc func(span opentracing.Span, req interface{})

UnaryRequestHandlerFunc is a custom request handler

Jump to

Keyboard shortcuts

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