Add requester field and enricher hook to controller metrics#58
Merged
Conversation
DylanBlakemore
commented
May 25, 2026
KentHawkings
approved these changes
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
requesterfield toZexbox.Metrics.ControllerSeries(not populated by default)Zexbox.Metrics.ControllerSeriesEnricherbehaviour and an:enricheroption onZexbox.Metrics.start_link/1(also configurable viaconfig :zexbox, :metrics_enricher)Details
Host apps frequently need to attach context to the controller metric that
zexboxitself doesn't know about — most immediately, an identifier for the caller derived from an API key lookup. Rather than baking specific knowledge of those values intozexbox, this adds a small extension point: a Plug-shaped behaviour (init/1+call/3) that receives the in-flightControllerSeriesand theconn, and returns a possibly-modified series. The host app configures their enricher module either at supervision time or via application env, and uses it to copy values they've already stashed onconn.assigns(e.g. an API key description set by their auth plug) onto the series.The new
requesterfield is the canonical place to put that caller identifier, but the enricher is free to set any tag or field on the series. Enricher exceptions are caught by the metric handler and logged — a buggy enricher will not break telemetry; the un-enriched series is written instead.