Documentation
¶
Index ¶
- func HTTPMiddleware(tp oteltrace.TracerProvider, opts ...HTTPOption) func(http.Handler) http.Handler
- func NewProviderFromEnv(serviceName string, opts ...ProviderOption) (*sdktrace.TracerProvider, func(context.Context) error, error)
- func NewTracer(provider oteltrace.TracerProvider) modulex.Tracer
- func SubscriberMiddleware(tp oteltrace.TracerProvider, opts ...SubscriberOption) func(topic string, handler modulex.EventHandler) modulex.EventHandler
- type HTTPOption
- type ProviderOption
- func WithExporterEndpoint(endpoint string) ProviderOption
- func WithExporterProtocol(protocol string) ProviderOption
- func WithInsecure(insecure bool) ProviderOption
- func WithResourceAttributes(attrs ...attribute.KeyValue) ProviderOption
- func WithSampleRatio(ratio float64) ProviderOption
- func WithSpanProcessor(sp sdktrace.SpanProcessor) ProviderOption
- type Span
- type SubscriberOption
- type Tracer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPMiddleware ¶ added in v0.2.0
func HTTPMiddleware(tp oteltrace.TracerProvider, opts ...HTTPOption) func(http.Handler) http.Handler
func NewProviderFromEnv ¶ added in v0.5.1
func NewProviderFromEnv(serviceName string, opts ...ProviderOption) (*sdktrace.TracerProvider, func(context.Context) error, error)
func NewTracer ¶
func NewTracer(provider oteltrace.TracerProvider) modulex.Tracer
NewTracer creates a Modulex Tracer backed by OpenTelemetry.
If provider is nil, the global OpenTelemetry TracerProvider is used. The returned tracer is safe for concurrent use.
func SubscriberMiddleware ¶ added in v0.2.0
func SubscriberMiddleware(tp oteltrace.TracerProvider, opts ...SubscriberOption) func(topic string, handler modulex.EventHandler) modulex.EventHandler
SubscriberMiddleware wraps an EventHandler with automatic span creation.
Types ¶
type HTTPOption ¶ added in v0.2.0
type HTTPOption func(*httpConfig)
HTTPOption configures the HTTP middleware.
func WithHTTPSpanName ¶ added in v0.2.0
func WithHTTPSpanName(fn func(r *http.Request) string) HTTPOption
WithHTTPSpanName sets a custom span naming function. The default uses the HTTP method as the span name.
type ProviderOption ¶ added in v0.5.1
type ProviderOption func(*providerConfig)
ProviderOption configures NewProviderFromEnv.
func WithExporterEndpoint ¶ added in v0.5.1
func WithExporterEndpoint(endpoint string) ProviderOption
func WithExporterProtocol ¶ added in v0.5.1
func WithExporterProtocol(protocol string) ProviderOption
func WithInsecure ¶ added in v0.6.0
func WithInsecure(insecure bool) ProviderOption
WithInsecure explicitly forces enabling or disabling TLS on the exporter.
func WithResourceAttributes ¶ added in v0.5.1
func WithResourceAttributes(attrs ...attribute.KeyValue) ProviderOption
func WithSampleRatio ¶ added in v0.5.1
func WithSampleRatio(ratio float64) ProviderOption
func WithSpanProcessor ¶ added in v0.5.1
func WithSpanProcessor(sp sdktrace.SpanProcessor) ProviderOption
type Span ¶
type Span struct {
// contains filtered or unexported fields
}
Span adapts an OpenTelemetry span to modulex.Span.
func (*Span) RecordError ¶
RecordError implements modulex.Span.
func (*Span) SetAttributes ¶
SetAttributes implements modulex.Span.
type SubscriberOption ¶ added in v0.2.0
type SubscriberOption func(*subscriberConfig)
SubscriberOption configures the subscriber middleware.
func WithSubscriberTopicAttr ¶ added in v0.2.0
func WithSubscriberTopicAttr(key string) SubscriberOption
WithSubscriberTopicAttr sets the attribute key used to record the topic name on subscriber spans. Default is "messaging.destination".
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
Tracer adapts an OpenTelemetry TracerProvider to modulex.Tracer.
func (*Tracer) ContextWithSpanContext ¶
func (t *Tracer) ContextWithSpanContext(ctx context.Context, sc modulex.SpanContext) context.Context
ContextWithSpanContext implements modulex.Tracer.
func (*Tracer) SpanContextFromContext ¶
func (t *Tracer) SpanContextFromContext(ctx context.Context) modulex.SpanContext
SpanContextFromContext implements modulex.Tracer.