prometheus/storage
Arve Knudsen 4afa76d083
OTLP: label caching for OTLP-to-Prometheus conversion to reduce allocations and improve latency (#17860)
* otlptranslator: add label caching for OTLP-to-Prometheus conversion

Add per-request caching to reduce redundant computation and allocations
during OTLP metric conversion:

1. Per-request label sanitization cache: Cache sanitized label names
   within a request to avoid repeated string allocations for commonly
   repeated labels like __name__, job, instance.

2. Resource-level label caching: Precompute and cache job, instance,
   promoted resource attributes, and external labels once per
   ResourceMetrics boundary instead of for each datapoint.

3. Scope-level label caching: Precompute and cache scope metadata labels
   (otel_scope_name, otel_scope_version, etc.) once per ScopeMetrics
   boundary.

4. LabelNamer instance caching: Reuse the LabelNamer struct across
   datapoints within the same resource context.

These optimizations significantly reduce allocations and improve latency
for OTLP ingestion workloads with many datapoints per resource/scope.

---------

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: George Krajcsovits <krajorama@users.noreply.github.com>
2026-01-16 10:30:05 +00:00
..
remote OTLP: label caching for OTLP-to-Prometheus conversion to reduce allocations and improve latency (#17860) 2026-01-16 10:30:05 +00:00
buffer.go storage/buffer.go: add ST to sample types and iterators 2026-01-14 13:15:10 +01:00
buffer_test.go add test coverage for buffer.go 2026-01-14 13:15:17 +01:00
errors.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
errors_test.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
fanout.go Refactor storage package errors (#17846) 2026-01-13 10:21:33 +01:00
fanout_test.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
generic.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
interface.go feat(tsdb): new AppenderV2 and AtST interface for chunks 2026-01-14 13:15:09 +01:00
interface_append.go refactor(tsdb/agent)[PART3]: add AppenderV2 support to agent 2025-12-13 05:17:39 +00:00
interface_test.go feat(tsdb): new AppenderV2 and AtST interface for chunks 2026-01-14 13:15:09 +01:00
lazy.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
memoized_iterator.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
memoized_iterator_test.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
merge.go feat(tsdb): new AppenderV2 and AtST interface for chunks 2026-01-14 13:15:09 +01:00
merge_test.go test that ChainSampleIterator passes on the AtST call 2026-01-14 13:15:18 +01:00
noop.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
secondary.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00
series.go update ExpandSamples 2026-01-14 13:15:14 +01:00
series_test.go test ListSeriesIterator with ST 2026-01-14 13:15:19 +01:00