grafana / pyroscope

Continuous Profiling Platform. Debug performance issues down to a single line of code
https://grafana.com/oss/pyroscope/
GNU Affero General Public License v3.0
9.98k stars 598 forks source link

The sample count displayed is wrong #3340

Open simonswine opened 3 months ago

simonswine commented 3 months ago

Describe the bug

Our currently displayed sample count in the UI is wrong. It seems to represent the sum of values multiplied by 10e9. In order to correct this we need to signal the sampling rate from the collection point (SDK/alloy/agent) and persist it in Pyroscope.

The OG Pyroscope endpoint has this metadata, which is unused by the adapter:

https://github.com/grafana/pyroscope/blob/ff0426278f16120b951cb4466b103349b0097c9d/pkg/og/ingestion/ingestion.go#L50

We then need to calculate the average sample rate for the profiles in a flamegraph (sample rate is a flamegraph wide parameter in flamebearer) and update our read path accordingly.

To Reproduce

Steps to reproduce:

  1. Query e.g. a CPU profile:
image

Both the value in the tool tip and and the total value, are wrong and just derived by

Expected behavior

This is the hard part to define the right count of samples in a flameGraph.

For time unit profiles:

For memory/object unit profiles:

Next steps

Variant A:

Variant B: