open-telemetry / opentelemetry-go-contrib

Collection of extensions for OpenTelemetry-Go.
https://opentelemetry.io/
Apache License 2.0
1.07k stars 505 forks source link

Implement new runtime metrics #5780

Open dashpole opened 1 week ago

dashpole commented 1 week ago

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

Changes:

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.

codecov[bot] commented 1 week ago

Codecov Report

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

Project coverage is 64.9%. Comparing base (522f603) to head (ff06938).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/open-telemetry/opentelemetry-go-contrib/pull/5780/graphs/tree.svg?width=650&height=150&src=pr&token=P6F3W9WA7Q&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry)](https://app.codecov.io/gh/open-telemetry/opentelemetry-go-contrib/pull/5780?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry) ```diff @@ Coverage Diff @@ ## main #5780 +/- ## ======================================= + Coverage 64.5% 64.9% +0.3% ======================================= Files 200 201 +1 Lines 12563 12668 +105 ======================================= + Hits 8112 8225 +113 + Misses 4215 4195 -20 - Partials 236 248 +12 ``` | [Files](https://app.codecov.io/gh/open-telemetry/opentelemetry-go-contrib/pull/5780?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry) | Coverage Δ | | |---|---|---| | [instrumentation/runtime/options.go](https://app.codecov.io/gh/open-telemetry/opentelemetry-go-contrib/pull/5780?src=pr&el=tree&filepath=instrumentation%2Fruntime%2Foptions.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry#diff-aW5zdHJ1bWVudGF0aW9uL3J1bnRpbWUvb3B0aW9ucy5nbw==) | `100.0% <100.0%> (ø)` | | | [instrumentation/runtime/runtime.go](https://app.codecov.io/gh/open-telemetry/opentelemetry-go-contrib/pull/5780?src=pr&el=tree&filepath=instrumentation%2Fruntime%2Fruntime.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry#diff-aW5zdHJ1bWVudGF0aW9uL3J1bnRpbWUvcnVudGltZS5nbw==) | `79.6% <82.8%> (+79.6%)` | :arrow_up: | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/open-telemetry/opentelemetry-go-contrib/pull/5780/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry)
MrAlias commented 1 week ago

Waiting to merge so @XSAM can review.

dashpole commented 6 days ago

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

dashpole commented 5 days ago

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 commented 5 days ago

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

dashpole commented 1 day ago

I think I got the test passing