Repository navigation
Implement Meter attributes in both exporters - #11
Merged
Merged
Conversation
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.
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.
Follow-up to #10, which added the
Attrdimension toMeterin the core (taggedv0.7.0). This bumps both exporters and implements attributes, each the way its backend actually wants them.Per backend
metric.WithAttributesoption, precomputed once and reused on everyAdd/RecordEither 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:
flow_processed_total→{worker=0: 5, worker=1: 7}flow.processed→{worker=0: 5, worker=1: 7}Verification
go vet+go test -race -count=1green in both submodules against the real taggedflow v0.7.0, with nogo.work— the same resolution CI uses.go mod tidypromotesgo.opentelemetry.io/otelto a direct dependency ofx/otel, for theattributepackage.Suggests
x/prometheus/v0.3.0andx/otel/v0.3.0tags once merged.🤖 Generated with Claude Code
https://claude.ai/code/session_01LGsdwoFd3a7bejBXLr6saG