open-telemetry / open-telemetry/opentelemetry-ruby
Stop over-validating instrument `unit`/`description`; coerce `nil` to `''`
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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