From ed65051e552bfd5c3181dfd69780c16b481b83a9 Mon Sep 17 00:00:00 2001 From: Brandur Date: Tue, 21 Jul 2026 13:14:15 -0500 Subject: [PATCH] A couple tweaks to `HookMetricEmit` documentation A couple minor tweaks to `HookMetricEmit` documentation: * Noticed we were previously reusing the word "invoked" twice in quick succession. Reworded to read better. * I copied some of the docs to `HookMetricEmitFunc`. The note about how stats are emitted in the hot path so stats should be consumed async is quite important, so worth repeating. --- hook_defaults_funcs.go | 5 +++++ rivertype/river_type.go | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hook_defaults_funcs.go b/hook_defaults_funcs.go index 58c1d2cf..0cec9220 100644 --- a/hook_defaults_funcs.go +++ b/hook_defaults_funcs.go @@ -29,6 +29,11 @@ func (f HookInsertBeginFunc) IsPlugin() bool { return true } // HookMetricEmitFunc is a convenience helper for implementing // rivertype.HookMetricEmit using a simple function instead of a struct. +// +// Notably, this function is invoked each time River emits a metric. Metrics are +// emitted in very hot paths like job fetching, and should therefore not block +// on network I/O or anything else, and should usually pass metrics through to +// an asynchronous instrumentation package like OpenTelemetry. type HookMetricEmitFunc func(ctx context.Context, params *rivertype.HookMetricEmitParams) func (f HookMetricEmitFunc) IsHook() bool { return true } diff --git a/rivertype/river_type.go b/rivertype/river_type.go index 47c98dfb..64a5387e 100644 --- a/rivertype/river_type.go +++ b/rivertype/river_type.go @@ -354,8 +354,8 @@ type HookInsertBegin interface { type HookMetricEmit interface { Hook - // MetricEmit is invoked each time River emits a metric. This is invoked in - // very hot paths like job fetching, and should therefore not block on + // MetricEmit is invoked each time River emits a metric. Metrics are emitted + // in very hot paths like job fetching, and should therefore not block on // network I/O or anything else, and should usually pass metrics through to // an asynchronous instrumentation package like OpenTelemetry. MetricEmit(ctx context.Context, params *HookMetricEmitParams)