8000 Implement Meter attributes in both exporters by pabloos · Pull Request #11 · pabloos/flow · GitHub
[go: up one dir, main page]

Skip to content

Implement Meter attributes in both exporters - #11

Merged
pabloos merged 1 commit into
mainfrom
feat/exporters-attrs
Nov 1, 2026
Merged

pabloos merged 1 commit into
mainfrom
feat/exporters-attrs

Conversation

@pabloos
@pabloos pabloos commented Nov 1, 2026
Copy link
Copy Markdown
Owner

Follow-up to #10, which added the Attr dimension to Meter in the core (tagged v0.7.0). This bumps both exporters and implements attributes, each the way its backend actually wants them.

Per backend

How attrs are applied
Prometheus const labels, baked into the instrument at creation
OpenTelemetry a metric.WithAttributes option, precomputed once and reused on every Add / Record

Either way the recording path stays allocation-free — which is the whole reason #10 passes attrs at creation rather than per measurement.

Instrument identity

Memoization is now keyed by name and attrs. Before, two instruments sharing a name would collide and silently return the first one; now the same name with different attrs yields distinct series.

Tests

Both exporters assert the attrs reach the backend, not just that the code compiles:

  • Prometheus: separate labelled series under flow_processed_total → {worker=0: 5, worker=1: 7}
  • OTel: separate attributed data points under flow.processed → {worker=0: 5, worker=1: 7}

Verification

go vet + go test -race -count=1 green in both submodules against the real tagged flow v0.7.0, with no go.work — the same resolution CI uses. go mod tidy promotes go.opentelemetry.io/otel to a direct dependency of x/otel, for the attribute package.

Suggests x/prometheus/v0.3.0 and x/otel/v0.3.0 tags once merged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LGsdwoFd3a7bejBXLr6saG

Bump x/prometheus and x/otel to flow v0.7.0 and honour the new Attr dimension,
each the way its backend wants it:

  Prometheus  attrs become const labels, baked into the instrument at creation
  OpenTelemetry  attrs become a metric.WithAttributes option, precomputed once
                 and reused on every Add/Record

Either way the recording path stays allocation-free, which is the point of
passing attrs at creation rather than per measurement.

Instrument memoization is now keyed by name *and* attrs, so same name with
different attrs yields distinct series instead of silently colliding. Tests
assert the attrs reach the backend: separate labelled series in Prometheus,
separate attributed data points in OTel, both {worker=0: 5, worker=1: 7}.

go mod tidy promotes go.opentelemetry.io/otel to a direct dependency of x/otel,
for the attribute package.
@pabloos
pabloos merged commit f90ecd8 into main Nov 1, 2026
2 checks passed
@pabloos
pabloos deleted the feat/exporters-attrs branch November 1, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0