Skip to content

metric: clarify sync vs observable Gauge in package godoc - #8225

Merged
MrAlias merged 6 commits into
open-telemetry:mainfrom
alliasgher:docs/4801-gauge-sync-async
Apr 21, 2026
Merged

MrAlias merged 6 commits into
open-telemetry:mainfrom
alliasgher:docs/4801-gauge-sync-async

Conversation

@alliasgher

Copy link
Copy Markdown
Contributor

Description

The "Measurements" description in the `go.opentelemetry.io/otel/metric` package godoc stated that a Gauge is used when "the most recent measurement needs to be conveyed about an asynchronous measurement" and only listed `Int64ObservableGauge` and `Float64ObservableGauge`. Synchronous Gauge types (`Int64Gauge`, `Float64Gauge`) were added to the API but are not reflected in this paragraph.

This PR updates the sentence to list all four Gauge types and briefly note the difference (sync records an instantaneous value at a specific point in code; observable samples via a callback once per collection cycle).

Partially addresses #4801 (the "explain the differences between instrument types" request) by correcting the Gauge coverage specifically. Happy to follow up with a broader summary-by-example list if @pellared thinks that's still valuable.

Fixes #4801.

Checklist

  • CHANGELOG.md entry added (placeholder #XXXX, will update with real PR number once assigned).
  • Tests updated (godoc-only change, no behavior change).

@codecov

codecov Bot commented Apr 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.7%. Comparing base (6f81801) to head (896678a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #8225   +/-   ##
=====================================
  Coverage   83.7%   83.7%           
=====================================
  Files        314     314           
  Lines      29730   29730           
=====================================
+ Hits       24898   24904    +6     
+ Misses      4457    4451    -6     
  Partials     375     375           

see 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread CHANGELOG.md Resolved
@dashpole dashpole added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Apr 17, 2026
The Measurements description in the metric package godoc stated that a
Gauge is used when "the most recent measurement needs to be conveyed
about an asynchronous measurement" and only referenced Int64ObservableGauge
and Float64ObservableGauge. Synchronous Gauge types (Int64Gauge,
Float64Gauge) were added to the API but not reflected here.

Update the sentence to list all four Gauge types and briefly note when
to use a synchronous variant vs an observable one.

Fixes open-telemetry#4801

Signed-off-by: Ali <alliasgher123@gmail.com>
@alliasgher
alliasgher force-pushed the docs/4801-gauge-sync-async branch from dcc2cd8 to 93cbc86 Compare April 17, 2026 13:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the go.opentelemetry.io/otel/metric package godoc to correctly describe Gauge instruments now that both synchronous and observable Gauge types exist in the API.

Changes:

  • Expands the Gauge sentence to list both synchronous and observable Gauge types.
  • Adds a short explanation distinguishing synchronous Gauge recording from observable Gauge callback sampling.

Comment thread metric/doc.go Resolved
Comment thread metric/doc.go Resolved
@pellared

This comment was marked as resolved.

…tions

Address Copilot review feedback on the Gauge sync/async clarification:
list Int64Gauge and Float64Gauge in the "All synchronous instruments"
enumeration, and in the "Measurements" section note that histograms
and synchronous gauges both use Record.

Signed-off-by: Ali <alliasgher123@gmail.com>
@MrAlias MrAlias added the documentation Provides helpful information label Apr 21, 2026
@MrAlias
MrAlias merged commit c504548 into open-telemetry:main Apr 21, 2026
31 checks passed
pellared added a commit to pellared/opentelemetry-go that referenced this pull request Apr 23, 2026
…etry#8225)

## Description

The "Measurements" description in the
\`go.opentelemetry.io/otel/metric\` package godoc stated that a Gauge is
used when "the most recent measurement needs to be conveyed about an
asynchronous measurement" and only listed \`Int64ObservableGauge\` and
\`Float64ObservableGauge\`. Synchronous Gauge types (\`Int64Gauge\`,
\`Float64Gauge\`) were added to the API but are not reflected in this
paragraph.

This PR updates the sentence to list all four Gauge types and briefly
note the difference (sync records an instantaneous value at a specific
point in code; observable samples via a callback once per collection
cycle).

Partially addresses open-telemetry#4801 (the "explain the differences between
instrument types" request) by correcting the Gauge coverage
specifically. Happy to follow up with a broader summary-by-example list
if @pellared thinks that's still valuable.

Fixes open-telemetry#4801.

## Checklist

- [x] CHANGELOG.md entry added (placeholder `#XXXX`, will update with
real PR number once assigned).
- [ ] Tests updated (godoc-only change, no behavior change).

---------

Signed-off-by: Ali <alliasgher123@gmail.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
@pellared pellared added this to the v1.44.0 milestone May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Provides helpful information Skip Changelog PRs that do not require a CHANGELOG.md entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

otel/metric: godoc describing differences between Gauge and other metric types

6 participants