telemetry

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

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

Go to latest
Published: Jan 6, 2025 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TraceStateKeyDetailLevel = "r8/dl"
	TraceStateKeySampleMode  = "r8/sm"
)

Variables

View Source
var (
	ErrUnsupportedValue      = fmt.Errorf("unsupported value")
	ErrUnsupportedSliceValue = fmt.Errorf("%w: slice attributes may contain only one type", ErrUnsupportedValue)
)
View Source
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 DefaultResource() *resource.Resource

func Meter

func Meter(service string, component string, opts ...metric.MeterOption) metric.Meter

Meter fetches a meter, applying a standard naming convention for use across services.

func Shutdown

func Shutdown(ctx context.Context) error

func Timer

func Timer(span trace.Span) func(string)

func TraceContextFromContext

func TraceContextFromContext(ctx context.Context) propagation.MapCarrier

TraceContextFromContext returns the tracecontext present in the passed context, if any.

func Tracer

func Tracer(service string, component string, opts ...trace.TracerOption) trace.Tracer

Tracer fetches a tracer, applying a standard naming convention for use across services.

func WithFullTrace

func WithFullTrace(ctx context.Context) context.Context

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

type Attributes []attribute.KeyValue

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 (*DroppedDataProcessor) OnStart

func (p *DroppedDataProcessor) OnStart(parent context.Context, s trace.ReadWriteSpan)

func (*DroppedDataProcessor) Shutdown

func (p *DroppedDataProcessor) Shutdown(ctx context.Context) error

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 (*TraceOptionsProcessor) OnStart

func (*TraceOptionsProcessor) Shutdown

func (p *TraceOptionsProcessor) Shutdown(ctx context.Context) error

type TraceOptionsPropagator

type TraceOptionsPropagator struct {
	Next propagation.TextMapPropagator
}

func (*TraceOptionsPropagator) Extract

func (*TraceOptionsPropagator) Fields

func (p *TraceOptionsPropagator) Fields() []string

func (*TraceOptionsPropagator) Inject

Directories

Path Synopsis
detectors
fly

Jump to

Keyboard shortcuts

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