opentelemetry-go-contrib icon indicating copy to clipboard operation
opentelemetry-go-contrib copied to clipboard

Implement new runtime metrics

Open dashpole opened this issue 1 year ago • 6 comments
trafficstars

Part of https://github.com/open-telemetry/opentelemetry-go-contrib/issues/5655

Changes:

  • Move the configuration options to options.go without modification.
  • Implements the metrics defined here: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/runtime/go-metrics.md. These are still disabled by default while it is under development.
  • Add unit tests

Notes:

It doesn't implement go.schedule.duration, as the histogram will need some additional work to figure out.

Based on https://github.com/prometheus/client_golang/pull/955#issue-1090830520, using go's runtime metrics should is more efficient than reading memstats.

dashpole avatar Jun 18 '24 20:06 dashpole

Codecov Report

Attention: Patch coverage is 85.24590% with 18 lines in your changes missing coverage. Please review.

Project coverage is 65.2%. Comparing base (879727b) to head (79f0b56).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #5780     +/-   ##
=======================================
+ Coverage   64.9%   65.2%   +0.3%     
=======================================
  Files        202     203      +1     
  Lines      12654   12759    +105     
=======================================
+ Hits        8213    8326    +113     
+ Misses      4210    4190     -20     
- Partials     231     243     +12     
Files Coverage Δ
instrumentation/runtime/options.go 100.0% <100.0%> (ø)
instrumentation/runtime/runtime.go 79.6% <82.8%> (+79.6%) :arrow_up:

... and 1 file with indirect coverage changes

codecov[bot] avatar Jun 18 '24 20:06 codecov[bot]

Waiting to merge so @XSAM can review.

MrAlias avatar Jun 20 '24 17:06 MrAlias

Working on tests. metrics.Read is being strange during unit testing, and seems to always return the same result.

dashpole avatar Jun 22 '24 15:06 dashpole

I had to add code that allocates memory to ensure the metric actually changes for the refresh test. I ran it locally with -count 10000, and it passes, so hopefully it won't be flaky.

dashpole avatar Jun 23 '24 15:06 dashpole

/gc/heap/allocs:bytes and /gc/heap/allocs:objects don't seem to be populated on windows. I'm investigating

dashpole avatar Jun 23 '24 19:06 dashpole

I think I got the test passing

dashpole avatar Jun 28 '24 01:06 dashpole

Looks like go mod tidy needs to be run.

MrAlias avatar Jul 09 '24 15:07 MrAlias

@XSAM PTAL.

MrAlias avatar Jul 09 '24 15:07 MrAlias

@XSAM planning to merge this in an hour or two unless I hear from you otherwise.

MrAlias avatar Jul 15 '24 16:07 MrAlias