Documentation ¶
Index ¶
- func ConvertHttpHeaderToRecordHeaders(httpHeader http.Header) []sarama.RecordHeader
- func ConvertRecordHeadersToHttpHeader(recordHeaders []*sarama.RecordHeader) http.Header
- func FilterCeRecordHeaders(recordHeaders []*sarama.RecordHeader) []*sarama.RecordHeader
- func ParseSpanContext(headers map[string][]byte) (sc trace.SpanContext, ok bool)
- func SerializeTrace(spanContext trace.SpanContext) []sarama.RecordHeader
- func StartTraceFromMessage(logger *zap.SugaredLogger, inCtx context.Context, ...) (context.Context, *trace.Span)
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.