opentracing

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package opentracing provides Go kit integration in term of transport layer for Apache Kafka to the OpenTracing project. OpenTracing implements a general purpose interface that microservices can program against, and which adapts to all major distributed tracing systems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextToKafka

func ContextToKafka(tracer opentracing.Tracer, logger log.Logger) transport.RequestFunc

ContextToKafka returns an transport.RequestFunc that injects an opentracing.Span found in ctx into the kafka headers. If no such Span can be found, the transport.RequestFunc is a noop.

func KafkaToContext

func KafkaToContext(tracer opentracing.Tracer, operationName string, logger log.Logger) transport.RequestFunc

KafkaToContext returns an transport.RequestFunc that tries to join with an OpenTracing trace found in msg and starts a new Span called operationName accordingly. If no trace could be found in msg, the Span will be a trace root. The Span is incorporated in the returned Context and can be retrieved with opentracing.SpanFromContext(ctx).

func TraceConsumer

func TraceConsumer(tracer opentracing.Tracer, operationName string, opts ...kitopentracing.EndpointOption) endpoint.Middleware

TraceConsumer returns a endpoint.Middleware that wraps the next endpoint.Endpoint in an opentracing.Span called operationName with consumer span.kind tag.

func TraceProducer added in v0.2.2

func TraceProducer(tracer opentracing.Tracer, operationName string, opts ...kitopentracing.EndpointOption) endpoint.Middleware

TraceProducer returns a endpoint.Middleware that wraps the next endpoint.Endpoint in an opentracing.Span called operationName with producer span.kind tag.

Types

type KafkaHeadersCarrier added in v1.0.0

type KafkaHeadersCarrier []kafka.Header

KafkaHeadersCarrier satisfies both opentracing.TextMapWriter and opentracing.TextMapReader.

Example usage for consumer side:

carrier := KafkaHeadersCarrier(msg.Headers)
clientContext, err := tracer.Extract(opentracing.TextMap, carrier)

Example usage for producer side:

carrier := KafkaHeadersCarrier(msg.Headers)
err := tracer.Inject(
    span.Context(),
    opentracing.TextMap,
    carrier,
)

func (KafkaHeadersCarrier) ForeachKey added in v1.0.0

func (c KafkaHeadersCarrier) ForeachKey(handler func(key string, val string) error) error

ForeachKey conforms to the opentracing.TextMapReader interface.

func (*KafkaHeadersCarrier) Set added in v1.0.0

func (c *KafkaHeadersCarrier) Set(key, val string)

Set conforms to the opentracing.TextMapWriter interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL