Repository navigation
fix(semconv): clear pooled slices to enable GC - #8352
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the generated semantic-convention metric helper code to proactively clear pooled option-slice contents before reusing them, allowing referenced objects to be garbage-collected instead of being retained by sync.Pool.
Changes:
- Clear
[]metric.AddOptionand[]metric.RecordOptionslices (viaclear) before resetting length and returning them to the pool. - Apply the change across the generated
semconv/v1.41.0/*conv/metric.gofiles. - Update the Go codegen template (
semconv/templates/registry/go/instrument.j2) so future regenerations keep the same behavior.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| semconv/v1.41.0/azureconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/v1.41.0/cicdconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/v1.41.0/containerconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/v1.41.0/dbconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/v1.41.0/dnsconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/v1.41.0/faasconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/v1.41.0/genaiconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/v1.41.0/goconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/v1.41.0/httpconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/v1.41.0/hwconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/v1.41.0/k8sconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/v1.41.0/mcpconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/v1.41.0/messagingconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/v1.41.0/nfsconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/v1.41.0/openshiftconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/v1.41.0/otelconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/v1.41.0/processconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/v1.41.0/rpcconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/v1.41.0/signalrconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/v1.41.0/systemconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/v1.41.0/vcsconv/metric.go | Clear pooled add/record option slices before putting them back in the pool. |
| semconv/templates/registry/go/instrument.j2 | Ensure generated metric helper code clears pooled slices prior to reuse. |
|
A further improvement would be to consolidate all those pools into a single pool (to rule them all!) per slice type. That way all the pooled objects are shared and, hence, there are fewer of them i.e. higher efficiency and less RAM usage. Less code bloat/duplication too! |
Codecov Reportโ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8352 +/- ##
=====================================
Coverage 82.9% 82.9%
=====================================
Files 314 314
Lines 25083 25083
=====================================
Hits 20799 20799
Misses 3910 3910
Partials 374 374 ๐ New features to boost your workflow:
|
Fixes #8320
Credits to @ash2k