tracing

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 31 Imported by: 3

Documentation

Index

Constants

View Source
const TraceIDKey = "traceID"

TraceIDKey is a constant value for trace id

Variables

View Source
var (
	//SpanKind "span.kind"
	SpanKind = "span.kind"
	//TraceKeyComponent "component"
	TraceKeyComponent = "component"
)
View Source
var ElementKey = micro.ElementKey("TracingComponent")

ElementKey is ElementKey for tracing

Functions

func ContinueSpanFromJSON

func ContinueSpanFromJSON(tracer opentracing.Tracer, operateName, marshaled string) (opentracing.Span, error)

ContinueSpanFromJSON ContinueSpanFromJsons

func CreateTracer

func CreateTracer(basic microConf.BasicConfig, trace TraceConfig, zlog *zap.Logger) (opentracing.Tracer, io.Closer, error)

CreateTracer create tracer

func ErrorToSpan

func ErrorToSpan(span opentracing.Span, err error)

ErrorToSpan ErrorTo Span

func GetGRPCClientSpan

func GetGRPCClientSpan(
	ctx context.Context,
	logger logging.ILogger,
	tracer opentracing.Tracer,
	operationName string,
	mustFindParent bool,
) (context.Context, func(), logging.ILogger)

GetGRPCClientSpan get grpc client span

func GetTraceIDFromJSON

func GetTraceIDFromJSON(marshaled string) string

GetTraceIDFromJSON get traceID from a JSON string

func GetTraceIDFromLog

func GetTraceIDFromLog(ctx context.Context, lokiClient *loki.Client, selector string) ([]string, error)

GetTraceIDFromLog get traceIDs from logs query by selector

func GetTraceIDFromSpan

func GetTraceIDFromSpan(span opentracing.Span) string

GetTraceIDFromSpan get traceID from a Span

func MarshalSpanToJSON

func MarshalSpanToJSON(span opentracing.Span) (string, error)

MarshalSpanToJSON parse span to json

func SetDefaultTraceConfig

func SetDefaultTraceConfig()

SetDefaultTraceConfig set default Trace configuration

func SetupGlobalTracer

func SetupGlobalTracer(basic microConf.BasicConfig, trace TraceConfig, zlog *zap.Logger) (opentracing.Tracer, io.Closer, error)

SetupGlobalTracer Set this overall tracer

func StartChildSpan

func StartChildSpan(
	ctx context.Context,
	logger logging.ILogger,
	tracer opentracing.Tracer,
	operateName string,
	tags ...opentracing.StartSpanOption,
) (context.Context, func(), logging.ILogger)

StartChildSpan Start ChildSpan

func StartChildSpanFromJSON

func StartChildSpanFromJSON(tracer opentracing.Tracer, operatorName, marshaled string) (opentracing.Span, error)

StartChildSpanFromJSON Start a subtask Span from json

func UnmarshalJSONToCarrier

func UnmarshalJSONToCarrier(marshaled string) (opentracing.TextMapCarrier, error)

UnmarshalJSONToCarrier unmarshal a JSON string to an opentracing.TextMapCarrier object

Types

type Component

type Component struct {
	micro.EmptyComponent
	// contains filtered or unexported fields
}

Component is Component for tracing

func (*Component) Init

func (c *Component) Init(server *micro.Server) error

Init the component

func (*Component) Name

func (c *Component) Name() string

Name of the component

func (*Component) PostStop

func (c *Component) PostStop(ctx context.Context) error

PostStop called after Stop()

func (*Component) PreInit

func (c *Component) PreInit(ctx context.Context) error

PreInit called before Init()

func (*Component) SetDynamicConfig

func (c *Component) SetDynamicConfig(config *platformConf.NodeConfig) error

SetDynamicConfig called when get dynamic config for the first time

type JaegerClient

type JaegerClient struct {
	// contains filtered or unexported fields
}

JaegerClient is a client for query Jaeger

func NewJaegerClient

func NewJaegerClient(jaegerQueryAddr string) (*JaegerClient, error)

NewJaegerClient create a new JaegerClient

func (*JaegerClient) QuerySpans

func (c *JaegerClient) QuerySpans(ctx context.Context, query *proto.TraceQueryParameters) ([]model.Span, error)

QuerySpans query spans from Jaeger

type LoggerWithSpan

type LoggerWithSpan struct {
	Span           opentracing.Span
	OriginalLogger logging.ILogger
}

LoggerWithSpan logger

func (*LoggerWithSpan) Debug

func (l *LoggerWithSpan) Debug(args ...interface{})

Debug Debug

func (*LoggerWithSpan) Debugf

func (l *LoggerWithSpan) Debugf(template string, args ...interface{})

Debugf Debugf

func (*LoggerWithSpan) Debugw

func (l *LoggerWithSpan) Debugw(msg string, keysAndValues ...interface{})

Debugw Debug

func (*LoggerWithSpan) Error

func (l *LoggerWithSpan) Error(args ...interface{})

Error Error

func (*LoggerWithSpan) Errorf

func (l *LoggerWithSpan) Errorf(template string, args ...interface{})

Errorf Errorf

func (*LoggerWithSpan) Errorw

func (l *LoggerWithSpan) Errorw(msg string, keysAndValues ...interface{})

Errorw wrong error

func (*LoggerWithSpan) Fatal

func (l *LoggerWithSpan) Fatal(args ...interface{})

Fatal Fatal

func (*LoggerWithSpan) Fatalf

func (l *LoggerWithSpan) Fatalf(template string, args ...interface{})

Fatalf Fatal

func (*LoggerWithSpan) Fatalw

func (l *LoggerWithSpan) Fatalw(msg string, keysAndValues ...interface{})

Fatalw Fatal

func (*LoggerWithSpan) Info

func (l *LoggerWithSpan) Info(args ...interface{})

Info Info

func (*LoggerWithSpan) Infof

func (l *LoggerWithSpan) Infof(template string, args ...interface{})

Infof Info

func (*LoggerWithSpan) Infow

func (l *LoggerWithSpan) Infow(msg string, keysAndValues ...interface{})

Infow info

func (*LoggerWithSpan) Panic

func (l *LoggerWithSpan) Panic(args ...interface{})

Panic Panic

func (*LoggerWithSpan) Panicf

func (l *LoggerWithSpan) Panicf(template string, args ...interface{})

Panicf Panic

func (*LoggerWithSpan) Panicw

func (l *LoggerWithSpan) Panicw(msg string, keysAndValues ...interface{})

Panicw Panic

func (*LoggerWithSpan) Warn

func (l *LoggerWithSpan) Warn(args ...interface{})

Warn Warning

func (*LoggerWithSpan) Warnf

func (l *LoggerWithSpan) Warnf(template string, args ...interface{})

Warnf Warn

func (*LoggerWithSpan) Warnw

func (l *LoggerWithSpan) Warnw(msg string, keysAndValues ...interface{})

Warnw warn

type TempoClient

type TempoClient struct {
	// contains filtered or unexported fields
}

TempoClient is a client for Tempo

func NewTempoClient

func NewTempoClient(tempoQueryAddr string) (*TempoClient, error)

NewTempoClient create a new TempoClient

func (*TempoClient) FindTraceByID

func (c *TempoClient) FindTraceByID(ctx context.Context, traceID string) ([]*v1.ResourceSpans, error)

FindTraceByID find trace by traceID

type TraceConfig

type TraceConfig struct {
	JaegerCollectorAddr string `toml:"jaegerCollector"`
	JaegerQueryAddr     string `toml:"jaegerQuery"`
	TempoQueryAddr      string `toml:"tempoQuery"`
}

TraceConfig Trace

func GetTraceConfig

func GetTraceConfig() *TraceConfig

GetTraceConfig get Trace configuration

Jump to

Keyboard shortcuts

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