Add remaining network sdkstats metrics for A365#192
Open
rads-1996 wants to merge 3 commits into
Open
Conversation
Member
Author
Performance comparisonThreshold: regressions >15.0% on gating scenarios fail the build. Higher ops/s is better; positive Δ means the PR is slower.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the distro’s SDKStats “network” metrics support (primarily for the Agent365 exporter) by adding the remaining upstream statsbeat metric names and wiring up additional observable gauge callbacks, along with comprehensive unit tests to validate the new record/observe behavior.
Changes:
- Add new sdkstats helpers/constants for request duration, failure, retry, throttle, and exception metrics (plus throttle status codes re-export).
- Attach callbacks for all six upstream statsbeat network gauges (success + 5 additional metrics) and add per-metric observation logic.
- Expand tests to cover new record helpers, new observation callbacks, and Agent365 exporter emission behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_sdkstats.py | Adds unit tests for new record_* helpers, new _observe_* callbacks, and verifies all six gauges are attached. |
| tests/a365/test_exporter.py | Adds Agent365 exporter tests verifying duration/failure/retry/throttle/exception metrics are recorded correctly. |
| src/microsoft/opentelemetry/a365/core/exporters/agent365_exporter.py | Records additional sdkstats metrics during _post_with_retries (duration, retry, failure/throttle, exception). |
| src/microsoft/opentelemetry/_sdkstats/_utils.py | Adds shared record helpers and expands _REQUESTS_MAP to include new metric buckets. |
| src/microsoft/opentelemetry/_sdkstats/_network_metrics.py | Adds observation callbacks for the additional metrics and registers them against upstream gauges. |
| src/microsoft/opentelemetry/_sdkstats/_constants.py | Re-exports additional upstream statsbeat metric names and throttle status codes. |
| src/microsoft/opentelemetry/_distro.py | Adjusts the sdkstats cikey placeholder value when Azure Monitor is disabled. |
Comments suppressed due to low confidence (1)
src/microsoft/opentelemetry/a365/core/exporters/agent365_exporter.py:399
time.time()is wall-clock time and can jump (NTP/manual clock changes), which can produce negative/incorrect durations. For request timing, prefer a monotonic clock liketime.perf_counter()for both start and elapsed calculations.
start_time = time.time()
try:
resp = self._session.post(
url,
data=body.encode("utf-8"),
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adding the remaining metrics -
I will raise another PR for OTLP once this PR is merged.