Skip to content

[Profiling] Add support for variable sampling frequency #128086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rockdaboot
Copy link
Contributor

This PR adds support for a variable sampling frequency.

So far, all trace events are assumed to be sampled at exactly 19 Hz (19 samples per second).

The profiling agent allows to configure this frequency as positive integer values - as allowed by the eBPF API. But due to limitations in our backend processing, which only support 19 Hz, we could not expose this option to customers. Once we support variable sampling frequencies in our backend and UI, we can open this configuration option to customers. A second use case could, in theory, be that we implement changing sampling frequency on-demand during runtime. "On-demand" could be increase accuracy during selected APM traces and spans.

In short, a sampling variable frequency allows reducing the storage costs significantly and/or allows increasing accuracy of profiling data.

TODO:

  • add more unit tests
  • add integration tests

@rockdaboot rockdaboot self-assigned this May 15, 2025
@rockdaboot rockdaboot added >non-issue :UniversalProfiling/Application Elastic Universal Profiling REST APIs and infrastructure v9.1.0 labels May 15, 2025
@elasticsearchmachine elasticsearchmachine added the external-contributor Pull request authored by a developer outside the Elasticsearch team label May 15, 2025
@@ -76,6 +76,10 @@
"type": "short",
"index": false
},
"Stacktrace.sampling_frequency": {
"type": "long",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using long here to
a) avoid hardly compressible FP type (no use case in sight for non-integer frequencies in sight)
b) long compresses as well as any other integer type (variable length encoding)

.missing("")
.field("Stacktrace.sampling_frequency")
// missing(DEFAULT_SAMPLING_RATE) is used to include documents where the field is missing.
.missing((long) DEFAULT_SAMPLING_FREQUENCY)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This allows compatibility with old data that doesn't have the sampling_frequency field.

@rockdaboot rockdaboot marked this pull request as ready for review May 15, 2025 16:50
@elasticsearchmachine elasticsearchmachine added the Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team label May 15, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external-contributor Pull request authored by a developer outside the Elasticsearch team >non-issue Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team :UniversalProfiling/Application Elastic Universal Profiling REST APIs and infrastructure v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants