tracing

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: GPL-3.0 Imports: 10 Imported by: 3

Documentation

Overview

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

Index

Constants

View Source
const (
	StatusOK    = codes.Ok
	StatusError = codes.Error
)
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 CommonProvider added in v1.3.0

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

CommonProvider provides the ability to easily create spans for tracing.

func New

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

New create new *CommonProvider for creating spans for traces.

func (*CommonProvider) Shutdown added in v1.3.0

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

Shutdown correctly shutdowns CommonProvider's inner logic.

func (*CommonProvider) Span added in v1.3.0

func (tp *CommonProvider) Span(
	ctx context.Context,
	name string,
	opts ...trace.SpanStartOption,
) (context.Context, trace.Span)

Span creates new span.

func (*CommonProvider) SpanFromTraceID added in v1.3.0

func (tp *CommonProvider) 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 (*CommonProvider) TraceIDFromHex added in v1.3.0

func (tp *CommonProvider) 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 Provider added in v1.3.0

type Provider 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)
}

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

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.

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