Documentation
¶
Index ¶
- func EmitWide(event WideEvent)
- func Event(name string, attrs Attributes)
- func IncCounter(name string, labels map[string]string)
- func Organization(ctx context.Context) string
- func RenderPrometheus() string
- func ReplaceGaugeSnapshot(name, labelName string, values map[string]float64)
- func SetGauge(name string, value float64, labels map[string]string)
- func SetOutput(w io.Writer) (restore func())
- func WithOrganization(ctx context.Context, organizationID string) context.Context
- type Attributes
- type Collector
- type Field
- type WideEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Event ¶
func Event(name string, attrs Attributes)
func IncCounter ¶
IncCounter increments a process-local counter. Values are rendered in Prometheus text format by RenderPrometheus; label keys/values outside the bounded vocabulary are collapsed to "other".
func Organization ¶
func RenderPrometheus ¶
func RenderPrometheus() string
RenderPrometheus returns a complete Prometheus text exposition. A stable trailing newline and deterministic ordering make scrape output easy to diff and test.
func ReplaceGaugeSnapshot ¶
ReplaceGaugeSnapshot replaces every series for a gauge in one operation. Callers that aggregate a database table should use this instead of SetGauge so labels that disappeared from the latest snapshot cannot retain stale non-zero values forever.
Types ¶
type Attributes ¶
type Attributes struct {
// contains filtered or unexported fields
}
func Attrs ¶
func Attrs(fields ...Field) Attributes
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector accumulates wide-event annotations for a single unit of work. The wide-event interceptor stores a pointer in the request context so handlers can enrich the one event emitted per RPC without each re-plumbing timing, status, or emission. It is safe for concurrent use.
func CollectorFrom ¶
CollectorFrom returns the Collector attached to ctx, if any. Handlers should tolerate its absence so they remain callable from tests and non-RPC paths.
func NewCollector ¶
NewCollector returns a context carrying a fresh Collector and the Collector itself, so the caller (the interceptor) can read the accumulated annotations after the handler returns.
func (*Collector) Dimension ¶
Dimension records a low-cardinality string attribute. Empty values are ignored so the emitted event matches the previous "non-empty only" behavior.
func (*Collector) Measurement ¶
Measurement records a numeric attribute (counts, sizes, durations).
func (*Collector) SetOrganization ¶
SetOrganization records the tenant boundary once authentication resolves it.