Skip to content

Conversation

@simonswine
Copy link
Contributor

@simonswine simonswine commented Jun 6, 2024

This fixes the default sample rate for profiling and clarfies the field value. Relates to #3340.

SpyName string `json:"spyName"`
// Sample rate at which the profiler was operating.
// Sample rate at which the profiler was operating. Note: This unit is not related to the Units field and is measured in samples per second.
SampleRate uint32 `json:"sampleRate"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not too sure if this is the right type and definition. I think it would be better if we would signal the sampleRate per SampleUnit. But for this we would need to change the field to be a float.

The default 100 Hz, would become 0.00001 per nanosecond. Any insights that you have on this @korniltsev

This fixes the default sample rate for profiling and clarfies the field
value. Relates to grafana#3340.
@simonswine simonswine force-pushed the 20240606_use-default-cpu-sample-rate branch from dcf5123 to 81c66e7 Compare August 21, 2024 14:03
@simonswine simonswine marked this pull request as ready for review August 21, 2024 14:03
@simonswine simonswine requested a review from a team as a code owner August 21, 2024 14:03
@aleks-p
Copy link
Contributor

aleks-p commented Oct 16, 2025

This seems to revert #2202 which I don't fully understand, do you have more context @korniltsev-grafanista ?

@korniltsev-grafanista
Copy link
Contributor

I don't think its a revert - it was 100_000_000 then 1_000_000_000 with #2202 and now 100 with #3342

The fix in #2202 "fixed" the duration formatting for process_cpu:cpu:nanoseconds:cpu:nanoseconds sample type.
Before the fix, the duration was 10 times bigger.

I look at the js code and this is how the formatter used to work back then

    const n = samples / sampleRate / this.divider;
    let nStr = n.toFixed(2);

which will accept for example 60_00_000_000 as the samples and sampleRate value is 1 second in nanoseconds and the divier is 60 - to get minutes, so the nStr is 1.00

I admit I don't fully understand the frontend code, not now, not back then when I "fixed" #2202

I also don't know how the current formatter works

@korniltsev-grafanista
Copy link
Contributor

Screenshot_2025-10-20_16-06-19 Screenshot_2025-10-20_16-09-02

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