api: add docstrings to core metrics instrument abstract methods#4923
Open
cluster2600 wants to merge 2 commits intoopen-telemetry:mainfrom
Open
api: add docstrings to core metrics instrument abstract methods#4923cluster2600 wants to merge 2 commits intoopen-telemetry:mainfrom
cluster2600 wants to merge 2 commits intoopen-telemetry:mainfrom
Conversation
Add missing docstrings to the abstract measurement methods on the four core synchronous metric instruments: - Counter.add – records a non-negative increment - UpDownCounter.add – records a positive or negative delta - Histogram.record – records an arbitrary statistical measurement - Gauge.set – records the current (non-additive) value Each docstring explains the intent of the method, any constraints on the parameter, and documents all three parameters (amount, attributes, context) using the existing Google-style format already present in the codebase. These methods are the primary interaction surface for developers using the OpenTelemetry Metrics API; having no docstring on the abstract definition makes generated API docs and IDE tooltips silent.
xrmx
reviewed
Feb 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add missing docstrings to the abstract measurement methods on the four core synchronous metric instruments:
Counter.add– records a non-negative incrementUpDownCounter.add– records a positive or negative deltaHistogram.record– records an arbitrary statistical measurementGauge.set– records the current (non-additive) valueEach docstring explains the intent of the method, any constraints on the
amountparameter, and documents all three parameters (amount,attributes,context) using the existing Google-style format already present in the codebase (e.g.CallbackOptions,Observation).These methods are the primary interaction surface for developers using the OpenTelemetry Metrics API; without docstrings on the abstract definitions, generated API docs and IDE tooltips are silent when hovering over the most commonly called methods.
Changes
opentelemetry-api/src/opentelemetry/metrics/_internal/instrument.py: Added docstrings toCounter.add,UpDownCounter.add,Histogram.record, andGauge.setCHANGELOG.md: Added entry under UnreleasedType of change
How Has This Been Tested?
Documentation-only change; no functional code was altered.
Verified that the added docstrings follow the existing Google-style format used in
CallbackOptionsandObservation.Does This PR Require a Contrib Repo Change?