otel

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package otel adds optional OpenTelemetry tracing to a babelqueue producer or consumer (ADR-0025): produce/consume spans correlated across every hop and SDK through the envelope's trace_id, which maps 1:1 to an OTel TraceID. It lives in its own module so the zero-dependency core never imports OpenTelemetry — wiring a TracerProvider is opt-in.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Publish

func Publish(
	ctx context.Context,
	tracer trace.Tracer,
	app *babelqueue.App,
	urn string,
	data map[string]any,
	opts ...babelqueue.Option,
) (string, error)

Publish starts a PRODUCER span "publish <urn>", carries the active trace's TraceID into the message's trace_id, and publishes via app — so the downstream consumer recovers the same trace. It otherwise behaves like babelqueue.App.Publish, returning the message id.

func TraceIDOf

func TraceIDOf(traceID string) trace.TraceID

TraceIDOf maps an envelope trace_id to a deterministic OTel TraceID: a UUID maps to its 16 raw bytes; any other string is hashed (SHA-256, first 16 bytes). The inverse of UUIDOf for the UUID case.

func UUIDOf

func UUIDOf(t trace.TraceID) string

UUIDOf formats an OTel TraceID (16 bytes) as a canonical UUID string — the form a producer stamps into the message's trace_id so a consumer can recover the same TraceID.

func WrapHandler

func WrapHandler(tracer trace.Tracer, handler babelqueue.Handler) babelqueue.Handler

WrapHandler returns handler decorated to emit a CONSUMER span per message, in the OTel trace derived from the envelope's trace_id, recording the handler's error/status. Register it like any handler: app.Handle(urn, otel.WrapHandler(tracer, handler)).

Types

This section is empty.

Jump to

Keyboard shortcuts

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