Skip to content

fix(profiles): count timestamps-only OTLP samples instead of storing 0 - #1006

Merged
rita7lopes merged 1 commit into
metrico:masterfrom
sam0392in:fix/otlp-profiles-timestamps-only-samples
Sep 30, 2026
Merged

rita7lopes merged 1 commit into
metrico:masterfrom
sam0392in:fix/otlp-profiles-timestamps-only-samples

Conversation

@sam0392in

Copy link
Copy Markdown
Contributor

What

Count a timestamps-only OTLP profile sample as one observation per timestamp, instead of storing it as 0.

Why

In profiles/v1development, a Sample can carry its observations in timestamps_unix_nano and leave values empty. The OpenTelemetry eBPF profiler (otel/opentelemetry-collector-ebpf-profiler) does this for its CPU samples: it only fills values when a profile type reports explicit values.

The writer (buildOTLPTree) and the reader (otlpToPProf) only summed values. So every sample from the eBPF profiler was stored with a value of 0. Labels and stack trees were ingested correctly, but Grafana's Pyroscope datasource showed total samples = 0 / max = 0 for every flamegraph.

Change

  • writer/utils/unmarshal/otlp_profile.go: when a sample has no values, buildOTLPTree uses the number of timestamps as its value.
  • reader/service/otlp_pprof.go: otlpToPProf does the same, so pprof exports match.
  • Samples that carry values are unchanged.

Testing

  • New unit tests: TestBuildOTLPTreeTimestampsOnly (writer) and TestOtlpToPProfTimestampsOnly (reader). Both fail without the fix and pass with it.
  • go test ./... passes.
  • Ran end to end with the eBPF profiler (collector v0.156.0), then OTLP/HTTP into a gigapipe writer, then ClickHouse. Before the fix, every row stored values_agg = [('samples:count', 0, 1)]. After the fix, rows carry the real sample counts, and SelectMergeStacktraces returns non-zero flamegraph totals in Grafana.

A profiles/v1development Sample may carry only timestamps_unix_nano, one
entry per observation, with an empty values list. The OpenTelemetry eBPF
profiler emits CPU samples this way. The writer (buildOTLPTree) and the
reader (otlpToPProf) only summed values, so every such sample was stored
as 0 and flamegraphs showed "total samples = 0".

When a sample has no values, use the number of timestamps as its value.
Samples that carry values are unchanged.
@CLAassistant

CLAassistant commented Sep 25, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rita7lopes

Copy link
Copy Markdown
Contributor

Hello @sam0392in
Thank you very much for your contribution.
All looks good on this PR. Please sign the CLA so we can merge it #1006 (comment)

@sam0392in

Copy link
Copy Markdown
Contributor Author

CLA signed.

@rita7lopes rita7lopes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sam0392in thank you for your fix! Merging

@rita7lopes
rita7lopes merged commit 3bcb89e into metrico:master Sep 30, 2026
10 checks passed
@askmanu askmanu Bot mentioned this pull request Sep 30, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants