Skip to content

semconv: convert process metrics to Observable instrument types#8235

Open
abhay1999 wants to merge 1 commit into
open-telemetry:mainfrom
abhay1999:fix/processconv-observable-metrics
Open

semconv: convert process metrics to Observable instrument types#8235
abhay1999 wants to merge 1 commit into
open-telemetry:mainfrom
abhay1999:fix/processconv-observable-metrics

Conversation

@abhay1999
Copy link
Copy Markdown

@abhay1999 abhay1999 commented Apr 20, 2026

Fixes #7342

Background

Process-level metrics (memory usage, thread count, disk I/O, etc.) are
naturally read from the OS via callbacks rather than incremented inline
at a call site. Using synchronous instrument types (Int64Counter,
Int64UpDownCounter, Int64Gauge) for these makes it awkward for users
who want to register them with meter.RegisterCallback.

process.cpu.time was already using Float64ObservableCounter as the
model — this change brings the rest of the process metrics in line.

Changes

Template (semconv/templates/registry/go/weaver.yaml):
Added instrument overrides for all process metrics so future
semconv-generate runs automatically produce Observable variants.

Latest generated output (semconv/v1.40.0/processconv/metric.go):
Converted the following instruments to their Observable counterparts:

Metric Before After
process.context_switches Int64Counter Int64ObservableCounter
process.cpu.utilization Int64Gauge Int64ObservableGauge
process.disk.io Int64Counter Int64ObservableCounter
process.memory.usage Int64UpDownCounter Int64ObservableUpDownCounter
process.memory.virtual Int64UpDownCounter Int64ObservableUpDownCounter
process.network.io Int64Counter Int64ObservableCounter
process.paging.faults Int64Counter Int64ObservableCounter
process.thread.count Int64UpDownCounter Int64ObservableUpDownCounter
process.unix.file_descriptor.count Int64UpDownCounter Int64ObservableUpDownCounter
process.uptime Float64Gauge Float64ObservableGauge
process.windows.handle.count Int64UpDownCounter Int64ObservableUpDownCounter

The Add/AddSet/Record/RecordSet convenience methods are removed
from these types since Observable instruments use registered callbacks
instead of synchronous recording. The "context" and "sync" imports
and the addOptPool/recOptPool variables are also removed as they are
no longer needed.

Testing

Updated package compiles cleanly:

go build ./semconv/v1.40.0/processconv/...

@abhay1999 abhay1999 marked this pull request as ready for review April 20, 2026 10:40
@dashpole
Copy link
Copy Markdown
Collaborator

Semconv is a stable artifact. We can't regenerate existing versions that have already been released. You can make the change to the template, and paste what it would do to the latest version in the description (so we know it works), but we can't update older semconv directories.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.6%. Comparing base (036414b) to head (bed5db7).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #8235   +/-   ##
=====================================
  Coverage   82.6%   82.6%           
=====================================
  Files        310     310           
  Lines      24647   24647           
=====================================
+ Hits       20370   20375    +5     
+ Misses      3897    3893    -4     
+ Partials     380     379    -1     

see 2 files with indirect coverage changes

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

Process-level metrics like memory usage, thread count, CPU utilization,
and disk I/O are naturally collected via OS callbacks rather than
inline Add/Record calls. Using Observable instrument types
(Int64ObservableCounter, Int64ObservableGauge,
Int64ObservableUpDownCounter, Float64ObservableGauge) aligns the
generated wrappers with this access pattern and matches how
process.cpu.time was already defined.

Updated semconv/v1.37.0 through semconv/v1.40.0 and the Weaver template
(weaver.yaml) so future semconv generations inherit the same mapping.
Older versions (v1.32.0–v1.36.0) use a different generator pattern and
will need regeneration via `make semconv-generate TAG=<version>`.

Fixes open-telemetry#7342
@abhay1999 abhay1999 force-pushed the fix/processconv-observable-metrics branch from 4b0f509 to 21546d6 Compare April 21, 2026 03:13
@abhay1999
Copy link
Copy Markdown
Author

Thanks for the clarification! Makes sense — I've updated the PR to only touch the template (weaver.yaml) and the latest unreleased v1.40.0 output. Dropped all the changes to the released versions.

@dmathieu
Copy link
Copy Markdown
Member

1.40.0 has already been released. https://pkg.go.dev/go.opentelemetry.io/otel@v1.43.0/semconv/v1.40.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update all metric types in processconv to be Observable

3 participants