Skip to content

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

Open
alliasgher wants to merge 5 commits intoopen-telemetry:mainfrom
alliasgher:docs/4801-gauge-sync-async
Open

metric: clarify sync vs observable Gauge in package godoc#8225
alliasgher wants to merge 5 commits intoopen-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
Copy link
Copy Markdown

codecov bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.6%. Comparing base (63ee0c5) to head (b3c0c62).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #8225     +/-   ##
=======================================
- Coverage   82.6%   82.6%   -0.1%     
=======================================
  Files        309     309             
  Lines      24621   24621             
=======================================
- Hits       20356   20355      -1     
- Misses      3888    3889      +1     
  Partials     377     377             

see 1 file 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 Outdated
@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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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
Comment thread metric/doc.go
@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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

5 participants