Skip to content

Commit 1e9eb32

Browse files
prabhaksclaude
andcommitted
fix(otel): preserve all exemplars per data point (#1662)
insert_exemplars wrote every exemplar of a data point to the same static columns (exemplar_time_unix_nano, exemplar_span_id, exemplar_trace_id, exemplar_value), so each exemplar overwrote the previous one and only the last survived. This affected Sum, Histogram, ExponentialHistogram (and Gauge) metric types. Serialize all exemplars into a single nested `exemplars` array column (array of objects), the OTel-faithful representation recommended in the issue. Each element carries exemplar_time_unix_nano, exemplar_span_id, exemplar_trace_id, exemplar_value, and any filtered attributes. Add the P_OTEL_FLATTEN_EXEMPLARS flag (default false) to opt back into the legacy flat columns for backward compatibility. Also stops exemplar attributes from leaking into the physical-series hash: `exemplars` is added to OTEL_METRICS_KNOWN_FIELD_LIST so exemplar contents no longer fragment series identity. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent d6a3b5a commit 1e9eb32

2 files changed

Lines changed: 245 additions & 34 deletions

File tree

src/cli.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,14 @@ pub struct Options {
292292
)]
293293
pub metrics_endpoint_auth: bool,
294294

295+
#[arg(
296+
long,
297+
env = "P_OTEL_FLATTEN_EXEMPLARS",
298+
default_value = "false",
299+
help = "Use the legacy flat per-exemplar columns (exemplar_time_unix_nano, exemplar_span_id, exemplar_trace_id, exemplar_value) for OTEL metrics. These columns keep only the last exemplar of each data point. When false (default), all exemplars are stored under a single nested `exemplars` array column."
300+
)]
301+
pub otel_flatten_exemplars: bool,
302+
295303
// TLS/Security
296304
#[arg(
297305
long,

0 commit comments

Comments
 (0)