Documentation
¶
Index ¶
- Constants
- func CtxTracer(ctx context.Context) trace.Tracer
- func CtxTracerProvider(ctx context.Context) trace.TracerProvider
- func NewAlwaysOffSampler() otelsdktrace.Sampler
- func NewAlwaysOnSampler() otelsdktrace.Sampler
- func NewNoopSpanProcessor() trace.SpanProcessor
- func NewOtlpGrpcClientConnection(ctx context.Context, host string, dialOptions ...grpc.DialOption) (*grpc.ClientConn, error)
- func NewOtlpGrpcSpanProcessor(ctx context.Context, conn *grpc.ClientConn) (trace.SpanProcessor, error)
- func NewParentBasedAlwaysOffSampler() otelsdktrace.Sampler
- func NewParentBasedAlwaysOnSampler() otelsdktrace.Sampler
- func NewParentBasedTraceIdRatioSampler(ratio float64) otelsdktrace.Sampler
- func NewStdoutSpanProcessor(options ...stdouttrace.Option) trace.SpanProcessor
- func NewTestSpanProcessor(testTraceExporter tracetest.TestTraceExporter) trace.SpanProcessor
- func NewTraceIdRatioSampler(ratio float64) otelsdktrace.Sampler
- func WithContext(ctx context.Context, tp trace.TracerProvider) context.Context
- type CtxKey
- type DefaultTracerProviderFactory
- type Options
- type Sampler
- type SpanProcessor
- type TracerProviderFactory
- type TracerProviderOption
Constants ¶
const ( Stdout = "stdout" // processor to send trace spans to the standard output OtlpGrpc = "otlp-grpc" // processor to send the trace spans via OTLP/gRPC Test = "test" // processor to send the trace spans to a test buffer Noop = "noop" // processor to void the trace spans )
const ( ParentBasedAlwaysOn = "parent-based-always-on" // parent based always on sampling ParentBasedAlwaysOff = "parent-based-always-off" // parent based always off sampling ParentBasedTraceIdRatio = "parent-based-trace-id-ratio" // parent based trace id ratio sampling AlwaysOn = "always-on" // always on sampling AlwaysOff = "always-off" // always off sampling TraceIdRatio = "trace-id-ratio" // trace id ratio sampling )
const DefaultOtlpGrpcTimeout = 30
DefaultOtlpGrpcTimeout is the default timeout in seconds for the OTLP gRPC connection.
const TracerName = "yokai"
TracerName is the default tracer name.
Variables ¶
This section is empty.
Functions ¶
func CtxTracer ¶ added in v1.2.0
CtxTracer returns the default contextual OTEL Tracer from a provided context (or returns the default one if missing).
func CtxTracerProvider ¶
func CtxTracerProvider(ctx context.Context) trace.TracerProvider
CtxTracerProvider retrieves an OTEL TracerProvider from a provided context (or returns the default one if missing).
func NewAlwaysOffSampler ¶
func NewAlwaysOffSampler() otelsdktrace.Sampler
NewAlwaysOffSampler returns a otelsdktrace.Sampler with always off sampling.
func NewAlwaysOnSampler ¶
func NewAlwaysOnSampler() otelsdktrace.Sampler
NewAlwaysOnSampler returns a otelsdktrace.Sampler with always on sampling.
func NewNoopSpanProcessor ¶
func NewNoopSpanProcessor() trace.SpanProcessor
NewNoopSpanProcessor returns a trace.SpanProcessor that voids trace spans via an async otelsdktracetest.NoopExporter.
func NewOtlpGrpcClientConnection ¶
func NewOtlpGrpcClientConnection(ctx context.Context, host string, dialOptions ...grpc.DialOption) (*grpc.ClientConn, error)
NewOtlpGrpcClientConnection returns a gRPC connection, and accept a host and a list of grpc.DialOption.
func NewOtlpGrpcSpanProcessor ¶
func NewOtlpGrpcSpanProcessor(ctx context.Context, conn *grpc.ClientConn) (trace.SpanProcessor, error)
NewOtlpGrpcSpanProcessor returns a trace.SpanProcessor using an async otlptracegrpc.Exporter.
func NewParentBasedAlwaysOffSampler ¶
func NewParentBasedAlwaysOffSampler() otelsdktrace.Sampler
NewParentBasedAlwaysOffSampler returns a otelsdktrace.Sampler with parent based always off sampling.
func NewParentBasedAlwaysOnSampler ¶
func NewParentBasedAlwaysOnSampler() otelsdktrace.Sampler
NewParentBasedAlwaysOnSampler returns a otelsdktrace.Sampler with parent based always on sampling.
func NewParentBasedTraceIdRatioSampler ¶
func NewParentBasedTraceIdRatioSampler(ratio float64) otelsdktrace.Sampler
NewParentBasedTraceIdRatioSampler returns a otelsdktrace.Sampler with parent based trace id ratio sampling.
func NewStdoutSpanProcessor ¶
func NewStdoutSpanProcessor(options ...stdouttrace.Option) trace.SpanProcessor
NewStdoutSpanProcessor returns a trace.SpanProcessor using an async stdouttrace.Exporter.
func NewTestSpanProcessor ¶
func NewTestSpanProcessor(testTraceExporter tracetest.TestTraceExporter) trace.SpanProcessor
NewTestSpanProcessor returns a trace.SpanProcessor using a sync tracetest.TestTraceExporter.
func NewTraceIdRatioSampler ¶
func NewTraceIdRatioSampler(ratio float64) otelsdktrace.Sampler
NewTraceIdRatioSampler returns a otelsdktrace.Sampler with trace id ratio sampling.
func WithContext ¶
WithContext appends to a given context a OTEL TracerProvider.
Types ¶
type DefaultTracerProviderFactory ¶
type DefaultTracerProviderFactory struct{}
DefaultTracerProviderFactory is the default TracerProviderFactory implementation.
func (*DefaultTracerProviderFactory) Create ¶
func (f *DefaultTracerProviderFactory) Create(options ...TracerProviderOption) (*trace.TracerProvider, error)
Create returns a new OTEL TracerProvider, and accepts a list of TracerProviderOption.
For example:
tp, _ := trace.NewDefaultTracerProviderFactory().Create() is equivalent to: tp, _ = trace.NewDefaultTracerProviderFactory().Create( trace.Global(true), // set the tracer provider as global trace.WithResource(resource.Default()), // use the default resource trace.WithSampler(trace.NewParentBasedAlwaysOnSampler()), // use parent based always on sampling trace.WithSpanProcessor(trace.NewNoopSpanProcessor()), // use noop processor (void trace spans) )
type Options ¶
type Options struct { Global bool Resource *resource.Resource Sampler trace.Sampler SpanProcessors []trace.SpanProcessor }
Options are options for the TracerProviderFactory implementations.
func DefaultTracerProviderOptions ¶
func DefaultTracerProviderOptions() Options
DefaultTracerProviderOptions are the default options used in the TracerProviderFactory.
type Sampler ¶
type Sampler int
Sampler is an enum for the supported samplers.
func FetchSampler ¶
FetchSampler returns a Sampler for a given value.
type SpanProcessor ¶
type SpanProcessor int
SpanProcessor is an enum for the supported span processors.
const ( NoopSpanProcessor SpanProcessor = iota StdoutSpanProcessor TestSpanProcessor OtlpGrpcSpanProcessor )
func FetchSpanProcessor ¶
func FetchSpanProcessor(p string) SpanProcessor
FetchSpanProcessor returns a SpanProcessor for a given value.
func (SpanProcessor) String ¶
func (p SpanProcessor) String() string
String returns a string representation of the SpanProcessor.
type TracerProviderFactory ¶
type TracerProviderFactory interface {
Create(options ...TracerProviderOption) (*trace.TracerProvider, error)
}
TracerProviderFactory is the interface for OTEL TracerProvider factories.
func NewDefaultTracerProviderFactory ¶
func NewDefaultTracerProviderFactory() TracerProviderFactory
NewDefaultTracerProviderFactory returns a DefaultTracerProviderFactory, implementing TracerProviderFactory.
type TracerProviderOption ¶
type TracerProviderOption func(o *Options)
TracerProviderOption are functional options for the TracerProviderFactory implementations.
func Global ¶
func Global(b bool) TracerProviderOption
Global is used to set the OTEL TracerProvider as global.
func WithResource ¶
func WithResource(r *resource.Resource) TracerProviderOption
WithResource is used to set the resource to use by the OTEL TracerProvider.
func WithSampler ¶
func WithSampler(s trace.Sampler) TracerProviderOption
WithSampler is used to set the sampler to use by the OTEL TracerProvider.
func WithSpanProcessor ¶
func WithSpanProcessor(spanProcessor trace.SpanProcessor) TracerProviderOption
WithSpanProcessor is used to set the span processor to use by the OTEL TracerProvider.