tracing

package
v6.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package tracing provides the means for creating traces and configuring trace exporters.

Index

Constants

This section is empty.

Variables

View Source
var Configured bool

Configured indicates whether tracing has been configured or not.

This variable is needed in order to shortcircuit span generation when tracing hasn't been configured.

Functions

func ConfigureTraceProvider

func ConfigureTraceProvider(tp trace.Provider)

ConfigureTraceProvider configures the sdk to use a given trace provider.

By default, a noop tracer is registered, thus, it's safe to call StartSpan and other related methods even before `ConfigureTracer` it called.

func End

func End(span trace.Span, err error)

func FromContext

func FromContext(ctx context.Context) trace.Span

func Inject

func Inject(ctx context.Context, supplier propagators.Supplier)

func StartSpan

func StartSpan(
	ctx context.Context,
	component string,
	attrs Attrs,
) (context.Context, trace.Span)

StartSpan creates a span, giving back a context that has itself added as the parent span.

Calls to this function with a context that has been generated from a previous call to this method will make the resulting span a child of the span that preceded it.

For instance:

``` func fn () {

rootCtx, rootSpan := StartSpan(context.Background(), "foo", nil)
defer rootSpan.End()

_, childSpan := StartSpan(rootCtx, "bar", nil)
defer childSpan.End()

} ```

calling `fn()` will lead to the following trace:

``` foo 0--------3

bar    1----2

```

where (0) is the start of the root span, which then gets a child `bar` initializing at (1), having its end called (2), and then the last span finalization happening for the root span (3) given how `defer` statements stack.

func StartSpanFollowing

func StartSpanFollowing(
	ctx context.Context,
	following WithSpanContext,
	component string,
	attrs Attrs,
) (context.Context, trace.Span)

func StartSpanLinkedToFollowing

func StartSpanLinkedToFollowing(
	linked context.Context,
	following WithSpanContext,
	component string,
	attrs Attrs,
) (context.Context, trace.Span)

func TraceProvider

func TraceProvider(exporter export.SpanSyncer) trace.Provider

Types

type Attrs

type Attrs map[string]string

type Config

type Config struct {
	Jaeger      Jaeger
	Stackdriver Stackdriver
}

func (Config) Prepare

func (c Config) Prepare() error

type Jaeger

type Jaeger struct {
	Endpoint string            `long:"jaeger-endpoint" description:"jaeger http-based thrift collector"`
	Tags     map[string]string `long:"jaeger-tags"     description:"tags to add to the components"`
	Service  string            `long:"jaeger-service"  description:"jaeger process service name" default:"web"`
}

func (Jaeger) Exporter

func (j Jaeger) Exporter() (export.SpanSyncer, error)

func (Jaeger) IsConfigured

func (j Jaeger) IsConfigured() bool

type Stackdriver

type Stackdriver struct {
	ProjectID string `long:"stackdriver-projectid" description:"GCP's Project ID"`
}

func (Stackdriver) Exporter

func (s Stackdriver) Exporter() (export.SpanSyncer, error)

func (Stackdriver) IsConfigured

func (s Stackdriver) IsConfigured() bool

type TestTraceProvider

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

func (*TestTraceProvider) Tracer

func (tp *TestTraceProvider) Tracer(name string) trace.Tracer

type WithSpanContext

type WithSpanContext interface {
	SpanContext() propagators.Supplier
}

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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