open-telemetry / open-telemetry/opentelemetry-ruby

Make `add_view` apply retroactively to existing instruments

Open
#2,361 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug metrics spec-compliance spec:stable
Dominant language
Ruby
Stars
606
Forks
301
Avg merge
3d 19h
Merged PRs (30d)
42

Description

Spec requirement

If configuration is updated (e.g. adding a View), the update MUST also apply to all already-returned Meters/instruments (sdk.md:143-159, Configuration).

Current behavior

add_metric_reader (meter_provider.rb:114-122 (permalink)) retroactively pushes the new reader onto every existing Meter. add_view (meter_provider.rb:186-189 (permalink)) does not. MetricStream#find_registered_view (state/metric_stream.rb:123-127 (permalink)) only runs once, at stream construction, so a View added after an instrument's first measurement won't affect that instrument's already-created stream.

Suggested fix

Have add_view re-resolve the matching View for every existing MetricStream, or re-run find_registered_view lazily on each collect/update rather than caching it once at construction.

Related rows in SPEC_COMPLIANCE_METRICS.md

SDK-6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with metrics_sdk/lib/opentelemetry/sdk/metrics/meter_provider.rb, especially add_view, then trace existing streams through metrics_sdk/lib/opentelemetry/sdk/metrics/state/metric_stream.rb and find_registered_view. Verify the change against an instrument and stream created before a View is added; done means the later View affects that existing instrument as required by SDK-6.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
observability-sre
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.