telemetry

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package telemetry is the single seam between bones command code and any OpenTelemetry tracer. Default builds (no -tags=otel) get a zero-cost no-op; `go build -tags=otel` swaps in the real OTel-backed implementation.

This file holds the build-tag-free types every caller speaks: Attr (a typed key/value pair built via String/Int/Bool) and EndFunc (the deferred cleanup returned by RecordCommand). The two RecordCommand implementations live in telemetry_default.go and telemetry_otel.go respectively.

Both implementations live in this package so the OTel branch can read Attr's unexported fields directly without exposing them to callers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attr

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

Attr is a typed key/value pair attached to a recorded command. Construct values via String, Int, or Bool — the zero value is intentionally useless so unsupported types fail at the constructor rather than silently flowing into the OTel branch.

func Bool

func Bool(key string, value bool) Attr

Bool returns an Attr carrying a boolean value.

func Int

func Int(key string, value int64) Attr

Int returns an Attr carrying a 64-bit signed integer value.

func String

func String(key, value string) Attr

String returns an Attr carrying a string value.

type EndFunc

type EndFunc func(err error)

EndFunc finalizes a span started by RecordCommand. Pass the operation's terminal error (or nil on success); the OTel branch records the error and closes the span. Always call exactly once — typically via `defer end(err)` against a named-return `err`.

func RecordCommand

func RecordCommand(
	ctx context.Context, _ string, _ ...Attr,
) (context.Context, EndFunc)

RecordCommand is the no-op default. With -tags=otel the implementation in telemetry_otel.go takes over and starts a real span. Returning the same ctx (rather than a derived child) keeps the no-op observably equivalent to "no instrumentation present at all."

Jump to

Keyboard shortcuts

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