You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2026-06-19 21:45:50 +02:00
prometheus: avoid preallocating scope attributes when disabled (#8404)
Fixes #8401 A regression test was too verbose + brittle to be useful. --------- Co-authored-by: Robert Pająk <pellared@hotmail.com>
This commit is contained in:
@@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||
|
||||
### Fixed
|
||||
|
||||
- Avoid preallocating scope attributes when they are disabled in `go.opentelemetry.io/otel/exporters/prometheus` . (#8404)
|
||||
- Fix memory leak in `go.opentelemetry.io/otel/sdk/metric/exemplar` Reservoir where full `context.Context` was stored, pinning large objects like gRPC transport buffers. (#8389)
|
||||
- Interpret HTTP `Retry-After` header values as seconds instead of nanoseconds when retrying OTLP HTTP exports in `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`, `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`, `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#8383)
|
||||
- Drastically reduce histogram heap allocations by reusing `BucketCounts` and `Exemplars` slices across `Collect` cycles in the cumulative histogram aggregation in `go.opentelemetry.io/otel/sdk/metric`. (#8428)
|
||||
|
||||
@@ -251,8 +251,11 @@ func (c *collector) Collect(ch chan<- prometheus.Metric) {
|
||||
})
|
||||
continue
|
||||
}
|
||||
// resource attributes + scope attributes + scope name + scope version + scope schema url
|
||||
n := len(c.resourceKeyVals.keys) + 3 + scopeMetrics.Scope.Attributes.Len()
|
||||
// resource attributes + (if enabled) scope fields
|
||||
n := len(c.resourceKeyVals.keys)
|
||||
if !c.disableScopeInfo {
|
||||
n += 3 + scopeMetrics.Scope.Attributes.Len()
|
||||
}
|
||||
kv := keyVals{
|
||||
keys: make([]string, 0, n),
|
||||
vals: make([]string, 0, n),
|
||||
|
||||
Reference in New Issue
Block a user