tracing

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertHttpHeaderToRecordHeaders added in v0.28.0

func ConvertHttpHeaderToRecordHeaders(httpHeader http.Header) []sarama.RecordHeader

ConvertHttpHeaderToRecordHeaders converts the specified HTTP Header to Sarama RecordHeaders It returns an array of RecordHeaders as is used in the Sarama ProducerMessage. Multi-value HTTP Headers are decomposed into separate RecordHeader instances rather than serializing as JSON or similar.

func ConvertRecordHeadersToHttpHeader added in v0.28.0

func ConvertRecordHeadersToHttpHeader(recordHeaders []*sarama.RecordHeader) http.Header

ConvertRecordHeadersToHttpHeader converts the specified Sarama RecordHeaders to an HTTP Header. It expects an array of RecordHeader pointers as is used in the Sarama ConsumerMessage. Multi-value HTTP Headers are re-composed form RecordHeader instances sharing the same Key rather than de-serializing JSON or similar.

func FilterCeRecordHeaders added in v0.28.0

func FilterCeRecordHeaders(recordHeaders []*sarama.RecordHeader) []*sarama.RecordHeader

FilterCeRecordHeaders returns a new array of RecordHeader pointers including only instances with non "ce_" Keys.

func ParseSpanContext

func ParseSpanContext(headers map[string][]byte) (sc trace.SpanContext, ok bool)

ParseSpanContext takes the "traceparent" and "tracestate" headers and regenerates the trace span context from them. This context can then be used to start a new span that uses the same trace ID as a different (but related) span.

func SerializeTrace

func SerializeTrace(spanContext trace.SpanContext) []sarama.RecordHeader

SerializeTrace returns the traceparent and tracestate values from a span context as a slice of sarama.RecordHeader structs that can be appended to an existing sarama.ProducerMessage

func StartTraceFromMessage

func StartTraceFromMessage(logger *zap.SugaredLogger, inCtx context.Context, message *protocolkafka.Message, spanName string) (context.Context, *trace.Span)

StartTraceFromMessage extracts the headers from a message (traceparent and tracestate) and uses them to start a span, which can be used with whatever tracing backend is set up (e.g. Zipkin) in order to trace the flow of a message. Multiple spans may be part of a single trace, for example, a dead letter message or a reply should be easy to match with the original message based on the trace ID. This ID is originally set in the first message header using the SerializeTrace function.

Types

This section is empty.

Jump to

Keyboard shortcuts

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