Documentation
¶
Overview ¶
Package tracing provides tools for comfort usage of tracing and view it with jaeger.
Index ¶
- Constants
- func CallerName(skipLevel int) string
- type CommonTraceProvider
- func (tp *CommonTraceProvider) Shutdown(ctx context.Context) error
- func (tp *CommonTraceProvider) Span(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
- func (tp *CommonTraceProvider) SpanFromTraceID(ctx context.Context, traceID trace.TraceID, name string, ...) (context.Context, trace.Span)
- func (tp *CommonTraceProvider) TraceIDFromHex(traceHex string) (trace.TraceID, error)
- type Config
- type SpanConfig
- type SpanEventConfig
- type SpanEventsConfig
- type TraceProvider
Constants ¶
const ( StatusOK = codes.Ok StatusError = codes.Error )
const (
DefaultSkipLevel = 1
)
const (
Key = "x-trace-id"
)
Variables ¶
This section is empty.
Functions ¶
func CallerName ¶ added in v1.2.6
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
func (tp *CommonTraceProvider) Span( ctx context.Context, name string, opts ...trace.SpanStartOption, ) (context.Context, trace.Span)
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 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.