You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add client-side token bucket rate limiter for telemetry export
Addresses resilience finding: the Azure Monitor OpenTelemetry exporter had no
client-side send-rate cap, allowing telemetry bursts to overload shared
ingestion infrastructure.
Changes:
- Add _TokenBucketRateLimiter in export/_rate_limiter.py with configurable
max_envelopes_per_second (default 10,000/sec, 1s burst capacity)
- Integrate rate limiting into BaseExporter._transmit() so all exporter
types (traces, logs, metrics) are protected
- Excess envelopes are routed to local storage for retry, not dropped
- Stats/internal exporters bypass rate limiting to preserve observability
- Rate limiting can be disabled via max_envelopes_per_second=0
- Add 19 unit and integration tests in tests/test_rate_limiter.py
* Address PR review: fix overflow double-persist, validate negative rate limit values
- Mutate envelopes list in-place (del envelopes[granted:]) so callers'
_handle_transmit_from_storage sees only admitted envelopes, preventing
duplicate storage of overflow on retryable failures
- Log a warning when overflow is deferred but storage is disabled
- Reject negative max_envelopes_per_second with ValueError instead of
silently disabling rate limiting (only 0 disables, per documentation)
- Add clarifying comment that per-exporter rate limiting is intentional
- Add tests: negative value rejection, in-place mutation, no-storage overflow
* Fix pylint warnings: implicit-str-concat and too-many-statements
* Fix redirect double rate-limit: skip rate limiting on recursive _transmit calls
Address JacksonWeber review: when _transmit() hits a 307/308 redirect and
calls itself recursively, the rate-limiting logic at the top would consume
tokens a second time for the same batch. Add _skip_rate_limit parameter
that is set to True on recursive calls to prevent this.
* Fix black formatting issues in rate limiter and base exporter
* Retrigger CI checks
* Retrigger CI checks (attempt 2)
---------
Co-authored-by: Jackson Weber <47067795+JacksonWeber@users.noreply.github.com>
:keyword ManagedIdentityCredential/ClientSecretCredential credential: Token credential, such as ManagedIdentityCredential or ClientSecretCredential, used for Azure Active Directory (AAD) authentication. Defaults to None.
99
105
:keyword bool disable_offline_storage: Determines whether to disable storing failed telemetry records for retry. Defaults to `False`.
100
106
:keyword str storage_directory: Storage path in which to store retry files. Defaults to `<tempfile.gettempdir()>/opentelemetry-python-<your-instrumentation-key>`.
107
+
:keyword int max_envelopes_per_second: Maximum number of telemetry envelopes sent per second. Acts as a client-side safety cap to prevent overloading shared ingestion infrastructure during telemetry bursts. Defaults to 10000. Set to 0 to disable rate limiting.
0 commit comments