-
Notifications
You must be signed in to change notification settings - Fork 3k
Added changes for rate limited sampler (azure-exporter changes) #41954
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
base: main
Are you sure you want to change the base?
Added changes for rate limited sampler (azure-exporter changes) #41954
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new rate-limited sampling mechanism for the Azure Monitor OTLP trace exporter, including utilities for DJB2-based sampling scores and rounding logic, and covers the feature with extensive unit tests.
- Implemented
RateLimitedSampler
and its adaptive percentage generator in_rate_limited_sampling.py
- Added two new utility functions (
_get_djb2_sample_score
,_round_down_to_nearest
) and corresponding constants in_utils.py
and_constants.py
- Exported
RateLimitedSampler
in the package API and supplied comprehensive tests intest_rate_limited_sampling.py
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
tests/trace/test_rate_limited_sampling.py | New unit tests exercising various sampling scenarios and thread safety |
export/trace/_utils.py | Added DJB2 hash sampling score and nearest-rounding helper |
export/trace/_rate_limited_sampling.py | Added RateLimitedSampler and RateLimitedSamplingPercentage |
exporter/_constants.py | Defined _HASH , _INTEGER_MAX , _INTEGER_MIN for DJB2 utilities |
exporter/init.py | Exported RateLimitedSampler in public API |
Comments suppressed due to low confidence (4)
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_utils.py:330
- [nitpick] Add a docstring describing the purpose, inputs, and output range of this DJB2-based sampling score function.
def _get_djb2_sample_score(trace_id_hex: str) -> float:
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_utils.py:348
- [nitpick] Add a docstring explaining the rounding strategy, edge cases handled, and example behavior.
def _round_down_to_nearest(sampling_percentage: float) -> float:
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_constants.py:221
- [nitpick] Consider renaming
_HASH
to_DJB2_INITIAL_HASH
or similar to clarify its role as the initial seed in the DJB2 algorithm.
_HASH = 5381
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_utils.py:348
- Add unit tests for
_round_down_to_nearest
to verify correct behavior at boundaries (e.g., very small percentages, zero, and percentages that map to integer counts).
def _round_down_to_nearest(sampling_percentage: float) -> float:
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
7f47987
to
c7d6608
Compare
1f39e15
to
463011e
Compare
Description
Adding support for RateLimitedSampler, inspired by Java Application Insights sampler
https://github.com/microsoft/ApplicationInsights-Java/blob/main/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/sampling/RateLimitedSamplingPercentage.java
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines