open-telemetry / open-telemetry/opentelemetry-ruby

Stop over-validating instrument `unit`/`description`; coerce `nil` to `''`

Open Beginner friendly
#2,363 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

Meter SHOULD NOT validate unit or description; a null value for either MUST be treated as an empty string (sdk.md:1041-1052).

Current behavior

meter.rb:68 (permalink) does validate unit (raise InstrumentUnitError if unit && (!unit.ascii_only? || unit.size > 63)), and meter.rb:69 (permalink) validates description size/encoding (InstrumentDescriptionError) more strictly than required. In both cases a nil value is accepted without being coerced to '', so downstream consumers see nil rather than an empty string.

Suggested fix

Remove the unit/description validation (or downgrade it to a non-raising warning), and explicitly coerce nil to '' for both fields before storing them on the instrument.

Related rows in SPEC_COMPLIANCE_METRICS.md

SDK-39, SDK-40

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 in metrics_sdk/lib/opentelemetry/sdk/metrics/meter.rb at the unit and description validation cited in the issue, then read the SDK-39 and SDK-40 rows in SPEC_COMPLIANCE_METRICS.md. The change is complete when nil values are stored as empty strings and unit or description inputs no longer raise validation errors contrary to the referenced specification.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.