otelobserver

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package otelobserver implements the credbound.Observer port with OpenTelemetry: every observed operation becomes a span, a "credbound.operations" counter increment, a "credbound.operation.duration" histogram sample and a log record, all attributed with the operation name and outcome. Operation records carry no secrets, so the telemetry is safe to export.

Wire it into credbound.Config.Observer:

observer, err := otelobserver.New(otelobserver.Config{})

A zero Config uses the process-global OTEL providers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// TracerProvider produces the per-operation spans. Defaults to
	// otel.GetTracerProvider().
	TracerProvider trace.TracerProvider
	// MeterProvider backs the operation counter and duration histogram.
	// Defaults to otel.GetMeterProvider().
	MeterProvider metric.MeterProvider
	// LoggerProvider receives one log record per operation. Defaults to
	// the global log provider.
	LoggerProvider logapi.LoggerProvider
}

Config selects the OpenTelemetry providers to emit through. Each nil field falls back to the corresponding process-global provider.

type Observer

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

Observer forwards credbound.Operation records to OpenTelemetry traces, metrics and logs. It is safe for concurrent use and implements credbound.Observer.

func New

func New(config Config) (*Observer, error)

New builds an Observer, creating its instruments on the configured (or global) providers. It fails only when an instrument cannot be created.

func (*Observer) Observe

func (o *Observer) Observe(ctx context.Context, operation credbound.Operation)

Observe records one completed operation: a span back-dated by the operation's duration, a counter increment, a histogram sample and a log record (error severity for the "error" outcome).

Jump to

Keyboard shortcuts

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