open-telemetry / open-telemetry/opentelemetry-ruby

Fix duplicate instrument registration warning to only fire on real conflicts, and add smarter remediation

Open
#2,362 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

Duplicate instrument registration (same name, at least one identifying field different) MUST still return a functional instrument and SHOULD emit a warning (sdk.md:976-1016). On a real conflict, producers SHOULD follow the specified remediation order: prefer the longer description, convert units/temporality where possible, otherwise warn and pass through (data-model.md:313-347, Producer recommendations, L326 specifically covers the "prefer the longer string" rule).

Current behavior

meter.rb:256-262 (permalink) (base create_instrument, inherited by the SDK Meter) returns a working new instrument and warns, but it warns on any re-use of an already-registered name, even when all identifying fields (kind/unit/description) are actually identical. This isn't a real conflict per the spec's own definition of distinct. It also doesn't attempt any of the spec's remediation strategies (longer description, unit/temporality conversion). It warns and lets both instruments export independently.

Suggested fix

Only warn when at least one identifying field actually differs between the new and existing registration. When it does differ, attempt the spec's remediation order (prefer the longer description; attempt unit/temporality conversion where feasible) before falling back to warn-and-pass-through.

Related rows in SPEC_COMPLIANCE_METRICS.md

SDK-36, DM-1

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 at metrics_api/lib/opentelemetry/metrics/meter.rb:256-262 and read the inherited create_instrument path in the SDK Meter alongside the linked SDK and data-model requirements. Done means identical registrations are warning-free, real conflicts still return a functional instrument, and the specified remediation or fallback warning behavior is covered by the relevant metrics tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
observability
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.