Documentation ¶
Overview ¶
Package otelcourier instruments the github.com/gojek/courier-go package.
Index ¶
- Constants
- func DisableCallbackTracing(opts *traceOptions)
- func DisablePublisherTracing(opts *traceOptions)
- func DisableSubscriberTracing(opts *traceOptions)
- func DisableUnsubscriberTracing(opts *traceOptions)
- type Option
- type Tracer
- func (t *Tracer) ApplyTraceMiddlewares(c *courier.Client)
- func (t *Tracer) PublisherMiddleware(next courier.Publisher) courier.Publisher
- func (t *Tracer) SubscriberMiddleware(next courier.Subscriber) courier.Subscriber
- func (t *Tracer) UnsubscriberMiddleware(next courier.Unsubscriber) courier.Unsubscriber
Examples ¶
Constants ¶
const ( // MQTTTopic is the attribute key for tracing message topic MQTTTopic = attribute.Key("mqtt.topic") // MQTTQoS is the attribute key for tracing message qos MQTTQoS = attribute.Key("mqtt.qos") // MQTTTopicWithQoS is the attribute key for tracing message topic and qos together MQTTTopicWithQoS = attribute.Key("mqtt.topicwithqos") // MQTTRetained is the attribute key for tracing message retained flag MQTTRetained = attribute.Key("mqtt.retained") )
Variables ¶
This section is empty.
Functions ¶
func DisableCallbackTracing ¶
func DisableCallbackTracing(opts *traceOptions)
DisableCallbackTracing disables implicit tracing on subscription callbacks.
func DisablePublisherTracing ¶
func DisablePublisherTracing(opts *traceOptions)
DisablePublisherTracing disables courier.Publisher tracing.
func DisableSubscriberTracing ¶
func DisableSubscriberTracing(opts *traceOptions)
DisableSubscriberTracing disables courier.Subscriber tracing.
func DisableUnsubscriberTracing ¶
func DisableUnsubscriberTracing(opts *traceOptions)
DisableUnsubscriberTracing disables courier.Unsubscriber tracing.
Types ¶
type Option ¶
type Option func(*traceOptions)
Option helps configure trace options.
func WithTextMapCarrierExtractFunc ¶ added in v0.2.1
func WithTextMapCarrierExtractFunc(fn func(context.Context) propagation.TextMapCarrier) Option
WithTextMapCarrierExtractFunc is used to specify the function which should be used to extract propagation.TextMapCarrier from the ongoing context.Context.
func WithTextMapPropagator ¶ added in v0.2.1
func WithTextMapPropagator(propagator propagation.TextMapPropagator) Option
WithTextMapPropagator specifies the propagator to use for extracting/injecting key-value texts. If none is specified, the global provider is used.
func WithTracerProvider ¶
func WithTracerProvider(provider oteltrace.TracerProvider) Option
WithTracerProvider specifies a tracer provider to use for creating a tracer. If none is specified, the global provider is used.
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
Tracer implements tracing abilities using OpenTelemetry SDK.
func NewTracer ¶
NewTracer creates a new Tracer with Option(s).
Example ¶
package main import ( "context" "os" "os/signal" "syscall" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/sdk/trace" courier "github.com/gojek/courier-go" "github.com/gojek/courier-go/otelcourier" ) func main() { tp := trace.NewTracerProvider() defer tp.Shutdown(context.Background()) otel.SetTracerProvider(tp) c, _ := courier.NewClient() otelcourier.NewTracer("service-name").ApplyTraceMiddlewares(c) if err := c.Start(); err != nil { panic(err) } stopCh := make(chan os.Signal, 1) signal.Notify(stopCh, []os.Signal{os.Interrupt, syscall.SIGTERM}...) if err := c.Publish( context.Background(), "test-topic", "message", courier.QOSOne); err != nil { panic(err) } <-stopCh c.Stop() }
Output:
func (*Tracer) ApplyTraceMiddlewares ¶
ApplyTraceMiddlewares will instrument all the operations of a courier.Client instance according to Option(s) used.
func (*Tracer) PublisherMiddleware ¶ added in v0.2.1
func (t *Tracer) PublisherMiddleware(next courier.Publisher) courier.Publisher
PublisherMiddleware is a courier.PublisherMiddlewareFunc for tracing publish calls.
func (*Tracer) SubscriberMiddleware ¶ added in v0.2.1
func (t *Tracer) SubscriberMiddleware(next courier.Subscriber) courier.Subscriber
SubscriberMiddleware is a courier.SubscriberMiddlewareFunc for tracing subscribe calls.
func (*Tracer) UnsubscriberMiddleware ¶ added in v0.2.1
func (t *Tracer) UnsubscriberMiddleware(next courier.Unsubscriber) courier.Unsubscriber
UnsubscriberMiddleware is a courier.UnsubscriberMiddlewareFunc for tracing unsubscribe calls.