trace

package
v0.0.0-...-4f9ff06 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2022 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSpanError

func AddSpanError(span trace.Span, err error)

AddSpanError adds a new event to the span. It will appear under the "Logs" section of the selected span. This is not going to flag the span as "failed". Use this if you think you should log any exceptions such as critical, error, warning, caution etc. Avoid logging sensitive data!

func AddSpanEvents

func AddSpanEvents(span trace.Span, name string, events map[string]string)

AddSpanEvents adds a new events to the span. It will appear under the "Logs" section of the selected span. Use this if the event could mean anything valuable while debugging.

func AddSpanTags

func AddSpanTags(span trace.Span, tags map[string]string)

AddSpanTags adds a new tags to the span. It will appear under "Tags" section of the selected span. Use this if you think the tag and its value could be useful while debugging.

func FailSpan

func FailSpan(span trace.Span, msg string)

FailSpan flags the span as "failed" and adds "error" label on listed trace. Use this after calling the `AddSpanError` function so that there is some sort of relevant exception logged against it.

func HTTPHandler

func HTTPHandler(handler http.Handler, name string) http.Handler

HTTPHandler is a convenience function which helps attaching tracing functionality to conventional HTTP handlers.

func HTTPHandlerFunc

func HTTPHandlerFunc(handler http.HandlerFunc, name string) http.HandlerFunc

HTTPHandlerFunc is a convenience function which helps attaching tracing functionality to conventional HTTP handlers.

func NewSpan

func NewSpan(ctx context.Context, name string) (context.Context, trace.Span)

NewSpan returns a new span from the global tracer. Depending on the `cus` argument, the span is either a plain one or a customised one. Each resulting span must be completed with `defer span.End()` right after the call.

func SpanFromContext

func SpanFromContext(ctx context.Context) trace.Span

SpanFromContext returns the current span from a context. If you wish to avoid creating child spans for each operation and just rely on the parent span, use this function throughout the application. With such practise you will get flatter span tree as opposed to deeper version. You can always mix and match both functions.

Types

type Provider

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

Provider represents the tracer provider. Depending on the `config.Disabled` parameter, it will either use a "live" provider or a "no operations" version. The "no operations" means, tracing will be globally disabled.

func NewProvider

func NewProvider(config ProviderConfig) (Provider, error)

New returns a new `Provider` type. It uses Jaeger exporter and globally sets the tracer provider as well as the global tracer for spans.

func (Provider) Close

func (p Provider) Close(ctx context.Context) error

Close shuts down the tracer provider only if it was not "no operations" version.

type ProviderConfig

type ProviderConfig struct {
	JaegerEndpoint string
	ServiceName    string
	ServiceVersion string
	Environment    string
	// Set this to `true` if you want to disable tracing completly.
	Disabled bool
}

ProviderConfig represents the provider configuration and used to create a new `Provider` type.

type SpanCustomiser

type SpanCustomiser interface {
	// contains filtered or unexported methods
}

SpanCustomiser is used to enforce custom span options. Any custom concrete span customiser type must implement this interface.

Jump to

Keyboard shortcuts

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