observability

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package observability ships an opt-in OpenTelemetry adapter that bridges Prism's executor hooks (P03's plan.ExecOpts.OnNodeStart / OnNodeDone) to an OTel-emitting Bridge. Per D086 the package imports zero OTel SDK code; integrators register their own SDK-backed Bridge implementation.

Wiring:

import "github.com/frankbardon/prism/internal/observability"

// In the consumer process (or in tests):
observability.Register(&myOtelBridge{tracer: provider.Tracer("prism")})
os.Setenv("PRISM_OTEL_ENABLED", "1")

// In the Twirp handler or executor wiring:
opts := observability.Hooks()
// merge into plan.ExecOpts before calling plan.Execute

When PRISM_OTEL_ENABLED is unset (or != "1") OR no Bridge has been registered, Hooks() returns the zero plan.ExecOpts and the executor sees no observability overhead.

Index

Constants

View Source
const EnabledEnvVar = "PRISM_OTEL_ENABLED"

EnabledEnvVar is the gating environment variable. Set to "1" to arm the executor hooks.

Variables

This section is empty.

Functions

func Enabled

func Enabled() bool

Enabled reports whether the env gate is set. Decoupled from Registered() so tests can exercise each gate independently.

func Hooks

func Hooks() plan.ExecOpts

Hooks returns a plan.ExecOpts populated with OnNodeStart / OnNodeDone callbacks that emit OTel spans through the active Bridge. Returns the zero ExecOpts when either gate fails (env unset or no Bridge); the caller can merge unconditionally.

func Register

func Register(b Bridge)

Register installs a Bridge. Passing nil clears the previous registration. Safe for concurrent callers.

func Registered

func Registered() bool

Registered returns true when a Bridge is currently installed. Tests use it to assert opt-in pre-conditions.

Types

type Bridge

type Bridge interface {
	StartSpan(ctx context.Context, name string) (context.Context, func(error))
}

Bridge is the OTel adapter interface. Integrators implement this once against their preferred OTel SDK and call Register at process init. StartSpan returns the (possibly-augmented) context and a span-end callback that takes an optional error.

Jump to

Keyboard shortcuts

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