Documentation ¶
Overview ¶
Package internal provides common types and functionality for instrumentation offered by this project.
Index ¶
- type Config
- func (c *Config) Copy() *Config
- func (c *Config) MergedSpanStartOptions(opts ...trace.SpanStartOption) []trace.SpanStartOption
- func (c *Config) ResolveMeter() metric.Meter
- func (c *Config) ResolveTracer(ctx context.Context) trace.Tracer
- func (c *Config) WithSpan(ctx context.Context, name string, f func(context.Context) error, ...) error
- type Option
- type OptionFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Version is the version of the instrumentation this Config is used for. // It has to be set before user-provided options are applied. Version string Tracer trace.Tracer Meter metric.Meter Propagator propagation.TextMapPropagator DefaultStartOpts []trace.SpanStartOption // contains filtered or unexported fields }
Config contains configuration options.
func NewConfig ¶
NewConfig returns a Config for instrumentation with all options applied.
If no TracerProvider or Propagator are specified with options, the default OpenTelemetry globals will be used.
func (*Config) MergedSpanStartOptions ¶
func (c *Config) MergedSpanStartOptions(opts ...trace.SpanStartOption) []trace.SpanStartOption
MergedSpanStartOptions returns a copy of opts with any DefaultStartOpts that c is configured with prepended.
func (*Config) ResolveMeter ¶ added in v1.5.0
ResolveMeter returns an OpenTelemetry meter from the appropriate MeterProvider.
func (*Config) ResolveTracer ¶
ResolveTracer returns an OpenTelemetry tracer from the appropriate TracerProvider.
If the passed context contains a span, the TracerProvider that created the tracer that created that span will be used. Otherwise, the TracerProvider from c is used.
type Option ¶
type Option interface {
Apply(*Config)
}
Option applies options to a configuration.
func WithAttributes ¶
WithAttributes returns an Option that appends attr to the attributes set for every span created.
func WithMeterProvider ¶ added in v1.5.0
func WithMeterProvider(mp metric.MeterProvider) Option
WithMeterProvider returns an Option that sets the MeterProvider used for a configuration.
func WithPropagator ¶
func WithPropagator(p propagation.TextMapPropagator) Option
WithPropagator returns an Option that sets p as the TextMapPropagator used when propagating a span context.
func WithTracerProvider ¶
func WithTracerProvider(tp trace.TracerProvider) Option
WithTracerProvider returns an Option that sets the TracerProvider used for a configuration.
type OptionFunc ¶
type OptionFunc func(*Config)
OptionFunc is a generic way to set an option using a func.
func (OptionFunc) Apply ¶
func (o OptionFunc) Apply(c *Config)
Apply applies the configuration option.