tracing

package
v6.7.3-0...-1f455d7 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: Apache-2.0 Imports: 16 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 propagation.HTTPSupplier)

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)

Types

type Attrs

type Attrs map[string]string

type Config

type Config struct {
	ServiceName string            `long:"service-name"  description:"service name to attach to traces as metadata" default:"concourse-web"`
	Attributes  map[string]string `long:"attribute"  description:"attributes to attach to traces as metadata"`
	Honeycomb   Honeycomb
	Jaeger      Jaeger
	Stackdriver Stackdriver
	OTLP        OTLP
}

func (Config) Prepare

func (c Config) Prepare() error

func (Config) TraceProvider

func (c Config) TraceProvider(exporter func() (export.SpanSyncer, error)) (trace.Provider, error)

type Honeycomb

type Honeycomb struct {
	APIKey      string `long:"honeycomb-api-key" description:"honeycomb.io api key"`
	Dataset     string `long:"honeycomb-dataset" description:"honeycomb.io dataset name"`
	ServiceName string `long:"honeycomb-service-name" description:"honeycomb.io service name" default:"concourse"`
}

func (Honeycomb) Exporter

func (h Honeycomb) Exporter() (export.SpanSyncer, error)

func (Honeycomb) IsConfigured

func (h Honeycomb) IsConfigured() bool

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"`
}

Jaeger service to export traces to

func (Jaeger) Exporter

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

Exporter returns a SpanExporter to sync spans to Jaeger

func (Jaeger) IsConfigured

func (j Jaeger) IsConfigured() bool

IsConfigured identifies if an endpoint has been set

type OTLP

type OTLP struct {
	Address string            `long:"otlp-address" description:"otlp address to send traces to"`
	Headers map[string]string `long:"otlp-header" description:"headers to attach to each tracing message"`
	UseTLS  bool              `long:"otlp-use-tls" description:"whether to use tls or not"`
}

OTLP service to export traces to

func (OTLP) Exporter

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

Exporter returns a SpanExporter to sync spans to OTLP

func (OTLP) IsConfigured

func (s OTLP) IsConfigured() bool

IsConfigured identifies if an Address has been set

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 WithSpanContext

type WithSpanContext interface {
	SpanContext() propagation.HTTPSupplier
}

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