tracing

package
v4.41.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package tracing implements utility functions for interacting with a global tracing system. Currently this system uses the opentelemetry APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FinishSpans

func FinishSpans(batch message.Batch)

FinishSpans calls Finish on all message parts containing a span.

func GetTraceID

func GetTraceID(p *message.Part) string

GetTraceID returns the traceID from a span attached to a message part. Returns a zeroed traceID if the part doesn't have a span attached.

func InitSpan

func InitSpan(prov trace.TracerProvider, operationName string, part *message.Part) *message.Part

InitSpan sets up an OpenTracing span on a message part if one does not already exist.

func InitSpans

func InitSpans(prov trace.TracerProvider, operationName string, batch message.Batch)

InitSpans sets up OpenTracing spans on each message part if one does not already exist.

func InitSpansFromParentTextMap

func InitSpansFromParentTextMap(prov trace.TracerProvider, operationName string, textMapGeneric map[string]any, batch message.Batch) error

InitSpansFromParentTextMap obtains a span parent reference from a text map and creates child spans for each message.

Types

type Span

type Span struct {
	// contains filtered or unexported fields
}

Span abstracts the span type of our global tracing system in order to allow it to be replaced in future.

func GetActiveSpan

func GetActiveSpan(p *message.Part) *Span

GetActiveSpan returns a span attached to a message part. Returns nil if the part doesn't have a span attached or it is inactive.

func GetSpan

func GetSpan(p *message.Part) *Span

GetSpan returns a span attached to a message part. Returns nil if the part doesn't have a span attached.

func GetSpanFromContext

func GetSpanFromContext(ctx context.Context) *Span

GetSpanFromContext returns a span within a context. Returns nil if the context doesn't have a span attached.

func OtelSpan

func OtelSpan(ctx context.Context, s trace.Span) *Span

OtelSpan creates a common span from the open telemetry package.

func WithChildSpan

func WithChildSpan(prov trace.TracerProvider, operationName string, part *message.Part) (*message.Part, *Span)

WithChildSpan takes a message, extracts a span, creates a new child span, and returns a new message with that span embedded. The original message is unchanged.

func WithChildSpans

func WithChildSpans(prov trace.TracerProvider, operationName string, batch message.Batch) (message.Batch, []*Span)

WithChildSpans takes a message, extracts spans per message part, creates new child spans, and returns a new message with those spans embedded. The original message is unchanged.

func WithSiblingSpans

func WithSiblingSpans(prov trace.TracerProvider, operationName string, batch message.Batch) (message.Batch, []*Span)

WithSiblingSpans takes a message, extracts spans per message part, creates new sibling spans, and returns a new message with those spans embedded. The original message is unchanged.

func (*Span) Finish

func (s *Span) Finish()

Finish the span.

func (*Span) LogKV

func (s *Span) LogKV(name string, kv ...string)

LogKV adds log key/value pairs to the span.

func (*Span) SetTag

func (s *Span) SetTag(key, value string)

SetTag sets a given tag to a value.

func (*Span) TextMap

func (s *Span) TextMap() (map[string]any, error)

TextMap attempts to inject a span into a map object in text map format.

Directories

Path Synopsis
Package tracing implements utility functions for interacting with a global tracing system.
Package tracing implements utility functions for interacting with a global tracing system.

Jump to

Keyboard shortcuts

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