tracing

package
v1.2.10 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2025 License: GPL-3.0 Imports: 9 Imported by: 4

Documentation

Overview

Package tracing provides tools for comfort usage of tracing and view it with jaeger.

Index

Constants

View Source
const (
	DefaultSkipLevel = 1
)
View Source
const (
	Key = "x-trace-id"
)

Variables

This section is empty.

Functions

func CallerName added in v1.2.6

func CallerName(skipLevel int) string

CallerName return info about function, where trace.Span was created https://stackoverflow.com/questions/25927660/how-to-get-the-current-function-name

Types

type CommonTraceProvider added in v1.2.7

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

CommonTraceProvider provides the ability to easily create spans for tracing.

func New

func New(config Config, opts ...trace.TracerOption) (*CommonTraceProvider, error)

New create new *CommonTraceProvider for creating spans for traces.

func (*CommonTraceProvider) Shutdown added in v1.2.7

func (tp *CommonTraceProvider) Shutdown(ctx context.Context) error

Shutdown correctly shutdowns CommonTraceProvider's inner logic.

func (*CommonTraceProvider) Span added in v1.2.7

Span creates new span.

func (*CommonTraceProvider) SpanFromTraceID added in v1.2.7

func (tp *CommonTraceProvider) SpanFromTraceID(
	ctx context.Context,
	traceID trace.TraceID,
	name string,
	opts ...trace.SpanStartOption,
) (context.Context, trace.Span)

SpanFromTraceID creates new span on base of provided trace.TraceID.

func (*CommonTraceProvider) TraceIDFromHex added in v1.2.7

func (tp *CommonTraceProvider) TraceIDFromHex(traceHex string) (trace.TraceID, error)

TraceIDFromHex decodes trace.TraceID from hash.

type Config

type Config struct {
	ServiceName    string
	ServiceVersion string
	JaegerURL      string
}

Config represents tracing setup config.

type SpanConfig

type SpanConfig struct {
	Name   string
	Opts   []trace.SpanStartOption
	Events SpanEventsConfig
}

SpanConfig is needed to configure creation of new span.

type SpanEventConfig

type SpanEventConfig struct {
	Name string
	Opts []trace.EventOption
}

SpanEventConfig is needed to configure creation of single span event.

type SpanEventsConfig

type SpanEventsConfig struct {
	Start SpanEventConfig
	End   SpanEventConfig
}

SpanEventsConfig is needed to configure creation of span events.

type TraceProvider

type TraceProvider interface {
	Shutdown(ctx context.Context) error
	Span(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
	TraceIDFromHex(traceHex string) (trace.TraceID, error)
	SpanFromTraceID(
		ctx context.Context,
		traceID trace.TraceID,
		name string,
		opts ...trace.SpanStartOption,
	) (context.Context, trace.Span)
}

TraceProvider interface is created for usage in external application according to "dependency inversion principle" of SOLID due to working via abstractions.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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