Skip to content

docs(api): concurrency, instrument name syntax, and histogram value range - #141

Open
michaelbushe wants to merge 1 commit into
mainfrom
fix/metrics-api-docs
Open

michaelbushe wants to merge 1 commit into
mainfrom
fix/metrics-api-docs

Conversation

@michaelbushe

@michaelbushe michaelbushe commented Sep 13, 2026

Copy link
Copy Markdown
Member

Closes the three remaining P2 documentation items on #101. All three are in the metrics API, all are comments only, no behavior change.

Concurrency, MUST

metrics/api.md, Concurrency requirements requires MeterProvider, Meter and Instrument to each document that implementations need to be safe for concurrent use by default. Added to APIMeterProvider, APIMeter and all seven instruments, using the wording #120 and #121 established for trace and logs so the three signals read the same.

Instrument name syntax, SHOULD

Synchronous Instrument API: the API SHOULD be documented so users know name must conform to the syntax. The [name] doc on all seven create* methods now gives the rules and says this API does not validate them.

That last clause matters now: #139 removed the empty-name throws from the no-op meter, because noop.md says the Meter MUST NOT validate any argument. The documentation is what tells users the rule, and SDK-side validation is dartastic_opentelemetry#170.

Histogram value range, SHOULD

Record: "The value is expected to be non-negative. This API SHOULD be documented in a way to communicate to users that this value is expected to be non-negative. This API SHOULD NOT validate this value."

record and recordWithMap now say so. No check was added, per the second half of that requirement. APICounter.add already carried the same note, so this makes the histogram consistent with it.

Verification

  • dart analyze clean, dart test 1231 passing.
  • All nine classes the spec names carry the concurrency note, all seven create* methods carry the syntax note, both histogram record methods carry the range note.
  • Confirmed no validation was introduced in histogram.dart.

🤖 Generated with Claude Code

Fixes #72
Fixes #73
Fixes #74

…ange

Three documentation requirements in metrics/api.md that the metrics API
did not state.

Concurrency (MUST, api.md Concurrency requirements): MeterProvider,
Meter and Instrument must each document that implementations need to be
safe for concurrent use by default. Added to APIMeterProvider, APIMeter
and all seven instruments, using the wording already established for the
trace and logs APIs.

Instrument name syntax (SHOULD, api.md Synchronous Instrument API): the
name parameter doc on all seven create* methods now states the rules,
not empty, first character an ASCII letter, then letters, digits, _, .,
- or /, at most 255 characters, compared case-insensitively, and says
the API does not validate it.

Histogram value range (SHOULD, api.md Record): record and recordWithMap
now state the value is expected to be non-negative. No check was added;
the same section says this API SHOULD NOT validate it.

Fixes #72
Fixes #73
Fixes #74

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant