Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultResource() *resource.Resource
- func Meter(service string, component string, opts ...metric.MeterOption) metric.Meter
- func Shutdown(ctx context.Context) error
- func Timer(span trace.Span) func(string)
- func TraceContextFromContext(ctx context.Context) propagation.MapCarrier
- func Tracer(service string, component string, opts ...trace.TracerOption) trace.Tracer
- func WithFullTrace(ctx context.Context) context.Context
- func WithTraceContext(ctx context.Context, carrier propagation.TextMapCarrier) context.Context
- func WithTraceOptions(ctx context.Context, to TraceOptions) context.Context
- type Attributes
- type DetailLevel
- type DroppedDataProcessor
- type ErrorHandler
- type SampleMode
- type TraceOptions
- type TraceOptionsProcessor
- type TraceOptionsPropagator
Constants ¶
const ( TraceStateKeyDetailLevel = "r8/dl" TraceStateKeySampleMode = "r8/sm" )
Variables ¶
var ( ErrUnsupportedValue = fmt.Errorf("unsupported value") ErrUnsupportedSliceValue = fmt.Errorf("%w: slice attributes may contain only one type", ErrUnsupportedValue) )
var Addr = func() string { if _, ok := os.LookupEnv("KUBERNETES_SERVICE_HOST"); ok { return ":9090" } return "localhost:9090" }()
We serve metrics for Prometheus over HTTP. If we appear to be running inside Kubernetes, bind to the wildcard address. Otherwise, bind to localhost.
While it has some security benefits, this is mainly to prevent macOS from constantly badgering the user in the development environment.
Functions ¶
func DefaultResource ¶
func TraceContextFromContext ¶
func TraceContextFromContext(ctx context.Context) propagation.MapCarrier
TraceContextFromContext returns the tracecontext present in the passed context, if any.
func Tracer ¶
Tracer fetches a tracer, applying a standard naming convention for use across services.
func WithFullTrace ¶
WithFullTrace returns a new context with full tracing mode enabled. This sets the trace detail level to "full" and the sample mode to "always".
func WithTraceContext ¶
func WithTraceContext(ctx context.Context, carrier propagation.TextMapCarrier) context.Context
WithTraceContext adds the tracecontext from the provided carrier to a returned Context. If no valid tracecontext is contained in the carrier, the passed ctx will be returned directly.
func WithTraceOptions ¶
func WithTraceOptions(ctx context.Context, to TraceOptions) context.Context
WithTraceOptions returns a copy of the provided context with the passed TraceOptions set.
Types ¶
type Attributes ¶
Attributes is a wrapper around a slice of attribute.KeyValue values which serializes to and from a simple JSON dictionary, handling type validation and ensuring that JSON numbers are upcast to the appropriate types in the attributes (int64 if possible, float64 otherwise).
func (Attributes) AsSlice ¶
func (as Attributes) AsSlice() []attribute.KeyValue
func (Attributes) MarshalJSON ¶
func (as Attributes) MarshalJSON() ([]byte, error)
func (*Attributes) UnmarshalJSON ¶
func (as *Attributes) UnmarshalJSON(b []byte) error
type DetailLevel ¶
type DetailLevel int
Don't forget to rerun `go generate ./...` if you add or remove values from the DetailLevel or SampleMode enums.
const ( DetailLevelDefault DetailLevel = iota DetailLevelFull )
func (DetailLevel) String ¶
func (i DetailLevel) String() string
type DroppedDataProcessor ¶
type DroppedDataProcessor struct {
Next trace.SpanProcessor
}
DroppedDataProcessor logs warnings when spans are dropping data due to attribute/event/link count limits.
See the various environment variables that control span limits at https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#span-limits
func (*DroppedDataProcessor) ForceFlush ¶
func (p *DroppedDataProcessor) ForceFlush(ctx context.Context) error
func (*DroppedDataProcessor) OnEnd ¶
func (p *DroppedDataProcessor) OnEnd(s trace.ReadOnlySpan)
func (*DroppedDataProcessor) OnStart ¶
func (p *DroppedDataProcessor) OnStart(parent context.Context, s trace.ReadWriteSpan)
type ErrorHandler ¶
type ErrorHandler struct{}
func (ErrorHandler) Handle ¶
func (eh ErrorHandler) Handle(err error)
type SampleMode ¶
type SampleMode int
const ( SampleModeNever SampleMode = iota - 1 SampleModeDefault SampleModeAlways )
func (SampleMode) String ¶
func (i SampleMode) String() string
type TraceOptions ¶
type TraceOptions struct { // How much detail to gather for this trace. DetailLevelFull enables // additional spans and trace context propagation which can enable a full // end-to-end trace, even for activities that are usually gathered under // separate trace IDs. DetailLevel DetailLevel // How to sample this trace. Controls the addition of attributes to trace // spans which serve as hints to our tail sampling proxy (Refinery) on how to // sample the trace. SampleMode SampleMode }
func TraceOptionsFromContext ¶
func TraceOptionsFromContext(ctx context.Context) TraceOptions
TraceOptionsFromContext extracts any custom trace options from the trace state carried in the passed context.
type TraceOptionsProcessor ¶
type TraceOptionsProcessor struct {
Next trace.SpanProcessor
}
TraceOptionsProcessor handles any custom span handling related to our own TraceOptions. At the moment it takes care of adding attributes to the span that control sampling and detail level.
func (*TraceOptionsProcessor) ForceFlush ¶
func (p *TraceOptionsProcessor) ForceFlush(ctx context.Context) error
func (*TraceOptionsProcessor) OnEnd ¶
func (p *TraceOptionsProcessor) OnEnd(s trace.ReadOnlySpan)
func (*TraceOptionsProcessor) OnStart ¶
func (p *TraceOptionsProcessor) OnStart(parent context.Context, s trace.ReadWriteSpan)
type TraceOptionsPropagator ¶
type TraceOptionsPropagator struct {
Next propagation.TextMapPropagator
}
func (*TraceOptionsPropagator) Extract ¶
func (p *TraceOptionsPropagator) Extract(ctx context.Context, carrier propagation.TextMapCarrier) context.Context
func (*TraceOptionsPropagator) Fields ¶
func (p *TraceOptionsPropagator) Fields() []string
func (*TraceOptionsPropagator) Inject ¶
func (p *TraceOptionsPropagator) Inject(ctx context.Context, carrier propagation.TextMapCarrier)