Documentation ¶
Overview ¶
Package tracing provides the means for creating traces and configuring trace exporters.
Index ¶
- Variables
- func ConfigureTraceProvider(tp trace.Provider)
- func End(span trace.Span, err error)
- func FromContext(ctx context.Context) trace.Span
- func Inject(ctx context.Context, supplier propagation.HTTPSupplier)
- func StartSpan(ctx context.Context, component string, attrs Attrs) (context.Context, trace.Span)
- func StartSpanFollowing(ctx context.Context, following WithSpanContext, component string, attrs Attrs) (context.Context, trace.Span)
- func StartSpanLinkedToFollowing(linked context.Context, following WithSpanContext, component string, ...) (context.Context, trace.Span)
- type Attrs
- type Config
- type Honeycomb
- type Jaeger
- type OTLP
- type Stackdriver
- type WithSpanContext
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 Inject ¶
func Inject(ctx context.Context, supplier propagation.HTTPSupplier)
func StartSpan ¶
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 ¶
Types ¶
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) TraceProvider ¶
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) IsConfigured ¶
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 ¶
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 ¶
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
}