tracer

package
v1.11.14 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: Apache-2.0 Imports: 18 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTraceID

func GetTraceID(ctx context.Context) string

GetTraceID func

func GetTraceURL

func GetTraceURL(ctx context.Context) (u string)

GetTraceURL log trace url

func InitOpenTracing

func InitOpenTracing(serviceName string, opts ...OptionFunc) error

InitOpenTracing init jaeger tracing

func Log

func Log(ctx context.Context, key string, value interface{})

Log trace

func LogEvent

func LogEvent(ctx context.Context, event string, payload ...interface{})

LogEvent trace

func SetError

func SetError(ctx context.Context, err error)

SetError global func TODO: separate in each tracer platform

func SetTracerPlatformType added in v1.9.3

func SetTracerPlatformType(t PlatformType)

SetTracerPlatformType function for set tracer platform

func SkipTraceContext

func SkipTraceContext(ctx context.Context) context.Context

SkipTraceContext inject to context for skip span tracer

func WithTraceFunc

func WithTraceFunc(ctx context.Context, operationName string, fn func(context.Context, map[string]interface{}))

WithTraceFunc functional with context and tags in function params (DEPRECATED, use WithTracerFunc)

func WithTracerFunc added in v1.10.7

func WithTracerFunc(ctx context.Context, operationName string, fn func(context.Context, Tracer))

WithTracerFunc functional with Tracer instance in function params

Types

type FinishOption added in v1.10.6

type FinishOption struct {
	Tags  map[string]interface{}
	Error error
}

FinishOption for option when trace is finished

type FinishOptionFunc added in v1.10.6

type FinishOptionFunc func(*FinishOption)

FinishOptionFunc func

func FinishWithAdditionalTags added in v1.10.6

func FinishWithAdditionalTags(tags map[string]interface{}) FinishOptionFunc

FinishWithAdditionalTags option for add tag when finish

func FinishWithError added in v1.10.6

func FinishWithError(err error) FinishOptionFunc

FinishWithError option for add error when finish

type Option added in v1.6.8

type Option struct {
	AgentHost       string
	Level           string
	BuildNumberTag  string
	MaxGoroutineTag int
}

Option for init tracer option

type OptionFunc added in v1.6.8

type OptionFunc func(*Option)

OptionFunc func

func OptionSetAgentHost added in v1.6.8

func OptionSetAgentHost(agent string) OptionFunc

OptionSetAgentHost option func

func OptionSetBuildNumberTag added in v1.6.8

func OptionSetBuildNumberTag(number string) OptionFunc

OptionSetBuildNumberTag option func

func OptionSetLevel added in v1.6.8

func OptionSetLevel(level string) OptionFunc

OptionSetLevel option func

func OptionSetMaxGoroutineTag added in v1.6.8

func OptionSetMaxGoroutineTag(max int) OptionFunc

OptionSetMaxGoroutineTag option func

type PlatformType added in v1.9.3

type PlatformType interface {
	StartSpan(ctx context.Context, opName string) Tracer
	StartRootSpan(ctx context.Context, operationName string, header map[string]string) Tracer
	GetTraceID(ctx context.Context) string
	GetTraceURL(ctx context.Context) string
}

PlatformType define tracing platform. example using jaeger, sentry, aws x-ray, etc

type Tracer added in v1.10.6

type Tracer interface {
	Context() context.Context
	Tags() map[string]interface{}
	SetTag(key string, value interface{})
	InjectRequestHeader(header map[string]string)
	SetError(err error)
	Log(key string, value interface{})
	Finish(opts ...FinishOptionFunc)
}

Tracer for trace

func StartTrace

func StartTrace(ctx context.Context, operationName string) Tracer

StartTrace starting trace child span from parent span

func StartTraceFromHeader added in v1.9.3

func StartTraceFromHeader(ctx context.Context, operationName string, header map[string]string) (Tracer, context.Context)

StartTraceFromHeader starting trace from root app handler based on header

func StartTraceWithContext added in v1.0.9

func StartTraceWithContext(ctx context.Context, operationName string) (Tracer, context.Context)

StartTraceWithContext starting trace child span from parent span, returning tracer and context

Jump to

Keyboard shortcuts

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