observe

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package observe provides zero-dependency observability hooks for goqu.

Hooks uses the wrap pattern: each hook receives a context and returns an enriched context plus a done function. This enables OpenTelemetry span propagation without importing OTel in core packages.

All hooks are optional. Nil hooks are silently skipped with zero overhead. Use WithHooks and FromContext to propagate hooks via context.Context.

Bridge implementations: otelbridge (OpenTelemetry spans) and prombridge (Prometheus metrics).

Package observe provides zero-dependency observability hooks for goqu.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithHooks

func WithHooks(ctx context.Context, h *Hooks) context.Context

WithHooks returns a context carrying the given Hooks.

Types

type CircuitInfo

type CircuitInfo struct {
	Name          string
	NumQubits     int
	GateCount     int
	TwoQubitGates int
	Depth         int
	Params        int
}

CircuitInfo holds circuit statistics for observability.

type HTTPInfo

type HTTPInfo struct {
	Method  string
	Path    string
	Backend string
}

HTTPInfo describes a backend HTTP request.

type Hooks

type Hooks struct {
	// WrapTranspile is called around the entire transpilation pipeline.
	WrapTranspile func(ctx context.Context, level int, in CircuitInfo) (context.Context, func(out CircuitInfo, err error))

	// WrapPass is called around each individual transpilation pass.
	WrapPass func(ctx context.Context, pass string, in CircuitInfo) (context.Context, func(out CircuitInfo, err error))

	// WrapJob is called around job submission through result retrieval.
	// The done function receives the job ID (empty if submission failed).
	WrapJob func(ctx context.Context, info JobInfo) (context.Context, func(jobID string, err error))

	// WrapSim is called around simulation execution.
	WrapSim func(ctx context.Context, info SimInfo) (context.Context, func(err error))

	// WrapHTTP is called around backend HTTP requests.
	WrapHTTP func(ctx context.Context, info HTTPInfo) (context.Context, func(statusCode int, err error))

	// WrapSweep is called around a parameter sweep execution.
	WrapSweep func(ctx context.Context, info SweepInfo) (context.Context, func(err error))

	// OnJobPoll is called each time a job is polled for status.
	OnJobPoll func(ctx context.Context, info JobPollInfo)
}

Hooks contains optional callbacks for observing goqu operations. Any nil field is silently skipped.

func FromContext

func FromContext(ctx context.Context) *Hooks

FromContext returns the Hooks from the context, or nil if none are set.

type JobInfo

type JobInfo struct {
	Backend string
	Shots   int
	Qubits  int
}

JobInfo describes a job being submitted.

type JobPollInfo

type JobPollInfo struct {
	Backend  string
	JobID    string
	State    string
	Attempt  int
	QueuePos int
}

JobPollInfo describes a job status poll event.

type SimInfo

type SimInfo struct {
	NumQubits int
	GateCount int
	Shots     int
}

SimInfo describes a simulation execution.

type SweepInfo

type SweepInfo struct {
	NumPoints int
	NumParams int
	Shots     int
	NumQubits int
}

SweepInfo describes a parameter sweep execution.

Jump to

Keyboard shortcuts

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