metrics

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package metrics provides the metrics sink interface for GRIP.

This package defines the MetricsSink interface that all metrics implementations (Prometheus, OpenTelemetry) satisfy. A NoopSink is provided as the default, ensuring zero overhead when metrics are disabled.

Sub-packages:

  • prommetrics: Prometheus counter-based implementation
  • otelmetrics: OpenTelemetry meter-based implementation

Example:

sink := prommetrics.New(prommetrics.DefaultOptions())
u := unary.New(unary.WithMetricsSink(sink))

Package metrics provides the public metrics interfaces for GRIP.

This package re-exports the metrics types from the internal implementation, making them available for external consumers who want to provide custom metrics implementations or use the built-in Prometheus/OpenTelemetry sinks.

The Sink interface is the primary extension point. Implement it to receive supervisor lifecycle events (start, success, failure, retry, give-up).

Built-in implementations:

  • metrics.Noop() — no-op sink (default)
  • prommetrics.New(opts) — Prometheus counters
  • otelmetrics.New(meter) — OpenTelemetry counters

Index

Constants

This section is empty.

Variables

View Source
var BindSupervisorHooks = metrics.BindSupervisorHooks

BindSupervisorHooks converts a Sink into supervisor.Hooks. This is used internally by the pipeline but exported for advanced use cases.

View Source
var FromContext = metrics.FromContext

FromContext extracts metric metadata from a context.

View Source
var WithContext = metrics.WithContext

WithContext attaches metric metadata to a context.

Functions

This section is empty.

Types

type ContextData

type ContextData = metrics.ContextData

ContextData holds request-scoped metric labels.

type NoopSink

type NoopSink = metrics.NoopSink

NoopSink is a metrics sink that discards all events. It is the default when no metrics provider is configured.

type Sink

type Sink = metrics.Sink

Sink receives supervisor lifecycle events for metrics collection.

Contract:

  • Implementations MUST be goroutine-safe
  • Implementations MUST NOT block
  • Implementations MUST NOT panic (panics are recovered but waste resources)
  • Supervisor correctness MUST NOT depend on Sink

func Noop

func Noop() Sink

Noop returns a no-op metrics sink.

Directories

Path Synopsis
Package otelmetrics provides an OpenTelemetry metrics sink for GRIP supervisor events.
Package otelmetrics provides an OpenTelemetry metrics sink for GRIP supervisor events.
Package prommetrics provides a Prometheus metrics sink for GRIP supervisor events.
Package prommetrics provides a Prometheus metrics sink for GRIP supervisor events.

Jump to

Keyboard shortcuts

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