Documentation ¶
Index ¶
- Constants
- Variables
- func AddMeterConfigSchema(c interface{ ... }) error
- func AddTracerConfigSchema(c interface{ ... }) error
- func End(span trace.Span, err *error)
- func NewMeterProvider(l *logrusx.Logger, c *MeterConfig) (metric.MeterProvider, error)
- func SetupJaegerTracer(tracerName string, c *TracerConfig) (trace.Tracer, propagation.TextMapPropagator, error)
- func SetupOTLPMeterProvider(meterName string, c *MeterConfig) (metric.MeterProvider, error)
- func SetupOTLPTracer(tracerName string, c *TracerConfig) (trace.Tracer, propagation.TextMapPropagator, error)
- func SetupPrometheusMeterProvider(meterName string, c *MeterConfig) (metric.MeterProvider, error)
- func SetupStdoutMeterProvider(meterName string, c *MeterConfig) (metric.MeterProvider, error)
- func SetupStdoutTracer(tracerName string, c *TracerConfig) (trace.Tracer, propagation.TextMapPropagator, error)
- func StringAttrs(attrs map[string]string) []attribute.KeyValue
- func WithSpan(ctx context.Context, name string, f func(context.Context) error, ...) (err error)
- type JaegerConfig
- type JaegerSampling
- type MeterConfig
- type MeterProvidersConfig
- type OTLPMeterConfig
- type OTLPSampling
- type OTLPTracerConfig
- type Otel
- type OtelOption
- type OtelOptions
- type StdoutConfig
- type Tracer
- func (t *Tracer) Extract(ctx context.Context, carrier propagation.TextMapCarrier) context.Context
- func (t *Tracer) Inject(ctx context.Context, carrier propagation.TextMapCarrier)
- func (t *Tracer) IsLoaded() bool
- func (t *Tracer) Provider() trace.TracerProvider
- func (t *Tracer) TextMapPropagator() propagation.TextMapPropagator
- func (t *Tracer) Tracer() trace.Tracer
- type TracerConfig
- type TracerProvidersConfig
Constants ¶
const MeterConfigSchemaID = "clinia://meter-config"
const TracerConfigSchemaID = "clinia://tracer-config"
Variables ¶
var MeterConfigSchema string
var TracerConfigSchema string
Functions ¶
func AddMeterConfigSchema ¶ added in v0.0.36
AddMeterConfigSchema adds the meter schema to the compiler. The interface is specified instead of `jsonschema.Compiler` to allow the use of any jsonschema library fork or version.
func AddTracerConfigSchema ¶ added in v0.0.33
AddTracerConfigSchema adds the tracer schema to the compiler. The interface is specified instead of `jsonschema.Compiler` to allow the use of any jsonschema library fork or version.
func End ¶
End finishes span, and automatically sets the error state if *err is not nil or during panicking.
Usage:
func Divide(ctx context.Context, numerator, denominator int) (ratio int, err error) { ctx, span := tracer.Start(ctx, "my-operation") defer otelx.End(span, &err) if denominator == 0 { return 0, errors.New("cannot divide by zero") } return numerator / denominator, nil }
func NewMeterProvider ¶ added in v0.0.63
func NewMeterProvider(l *logrusx.Logger, c *MeterConfig) (metric.MeterProvider, error)
NewMeterProvider creates a new meter provider based on the configuration.
func SetupJaegerTracer ¶ added in v0.0.33
func SetupJaegerTracer(tracerName string, c *TracerConfig) (trace.Tracer, propagation.TextMapPropagator, error)
Optionally, Config.Providers.Jaeger.LocalAgentAddress can be set. NOTE: If Config.Providers.Jaeger.Sampling.ServerURL is not specfied, AlwaysSample is used.
func SetupOTLPMeterProvider ¶ added in v0.0.63
func SetupOTLPMeterProvider(meterName string, c *MeterConfig) (metric.MeterProvider, error)
func SetupOTLPTracer ¶ added in v0.0.33
func SetupOTLPTracer(tracerName string, c *TracerConfig) (trace.Tracer, propagation.TextMapPropagator, error)
func SetupPrometheusMeterProvider ¶ added in v0.0.63
func SetupPrometheusMeterProvider(meterName string, c *MeterConfig) (metric.MeterProvider, error)
func SetupStdoutMeterProvider ¶ added in v0.0.63
func SetupStdoutMeterProvider(meterName string, c *MeterConfig) (metric.MeterProvider, error)
func SetupStdoutTracer ¶ added in v0.0.33
func SetupStdoutTracer(tracerName string, c *TracerConfig) (trace.Tracer, propagation.TextMapPropagator, error)
func WithSpan ¶
func WithSpan(ctx context.Context, name string, f func(context.Context) error, opts ...trace.SpanStartOption) (err error)
WithSpan wraps execution of f in a span identified by name.
If f returns an error or panics, the span status will be set to the error state. The error (or panic) will be propagated unmodified.
f will be wrapped in a child span by default. To make a new root span instead, pass the trace.WithNewRoot() option.
Types ¶
type JaegerConfig ¶
type JaegerConfig struct { LocalAgentAddress string `json:"local_agent_address"` Sampling JaegerSampling `json:"sampling"` }
type JaegerSampling ¶
type MeterConfig ¶ added in v0.0.36
type MeterProvidersConfig ¶ added in v0.0.36
type MeterProvidersConfig struct {
OTLP OTLPMeterConfig `json:"otlp"`
}
type OTLPMeterConfig ¶ added in v0.0.36
type OTLPSampling ¶
type OTLPSampling struct {
SamplingRatio float64 `json:"sampling_ratio"`
}
type OTLPTracerConfig ¶ added in v0.0.36
type OTLPTracerConfig struct { Protocol string `json:"protocol"` ServerURL string `json:"server_url"` Insecure bool `json:"insecure"` Sampling OTLPSampling `json:"sampling"` }
type Otel ¶ added in v0.0.33
type Otel struct {
// contains filtered or unexported fields
}
func New ¶
func New(l *logrusx.Logger, opts ...OtelOption) (*Otel, error)
Creates opentelemetry tools (meter and tracer). Leaving
func (*Otel) MeterProvider ¶ added in v0.0.63
func (o *Otel) MeterProvider() metric.MeterProvider
MeterProvider returns the underlying OpenTelemetry meter provider.
type OtelOption ¶ added in v0.0.33
type OtelOption func(*OtelOptions)
func WithMeterConfig ¶ added in v0.0.63
func WithMeterConfig(config *MeterConfig) OtelOption
func WithTracer ¶ added in v0.0.33
func WithTracer(config *TracerConfig) OtelOption
type OtelOptions ¶ added in v0.0.33
type OtelOptions struct { TracerConfig *TracerConfig MeterConfig *MeterConfig }
type StdoutConfig ¶ added in v0.0.4
type StdoutConfig struct {
Pretty bool `json:"pretty"`
}
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
func NewNoopTracer ¶ added in v0.0.33
func (*Tracer) Extract ¶ added in v0.0.33
func (t *Tracer) Extract(ctx context.Context, carrier propagation.TextMapCarrier) context.Context
Extract reads tracecontext from the carrier into a returned Context. If the extracted tracecontext is invalid, the passed ctx will be returned directly instead.
func (*Tracer) Inject ¶ added in v0.0.33
func (t *Tracer) Inject(ctx context.Context, carrier propagation.TextMapCarrier)
Inject set tracecontext from the Context into the carrier.
func (*Tracer) Provider ¶
func (t *Tracer) Provider() trace.TracerProvider
Provider returns a TracerProvider which in turn yieds this tracer unmodified.
func (*Tracer) TextMapPropagator ¶ added in v0.0.33
func (t *Tracer) TextMapPropagator() propagation.TextMapPropagator
TextMapPropagator returns the underlying OpenTelemetry textMapPropagator.
type TracerConfig ¶ added in v0.0.33
type TracerConfig struct { ServiceName string `json:"service_name"` Name string `json:"name"` Provider string `json:"provider"` Providers TracerProvidersConfig `json:"tracer_providers"` ResourceAttributes []attribute.KeyValue `json:"resource_attributes"` SpanLimits *sdktrace.SpanLimits `json:"span_limits,omitempty"` }
type TracerProvidersConfig ¶ added in v0.0.33
type TracerProvidersConfig struct { Jaeger JaegerConfig `json:"jaeger"` OTLP OTLPTracerConfig `json:"otlp"` Stdout StdoutConfig `json:"stdout"` }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
instrumentation
|
|
otelhttpx
package otelhttpx provides an http.Handler and functions that are intended to be used to add tracing by wrapping existing handlers (with Handler) and routes WithRouteTag.
|
package otelhttpx provides an http.Handler and functions that are intended to be used to add tracing by wrapping existing handlers (with Handler) and routes WithRouteTag. |
otelhttpx/filters
Package filters provides a set of filters useful with the otelhttpx.WithFilter() option to control which inbound requests are traced.
|
Package filters provides a set of filters useful with the otelhttpx.WithFilter() option to control which inbound requests are traced. |