Skip to content

Add remaining network sdkstats metrics for A365#192

Open
rads-1996 wants to merge 3 commits into
microsoft:mainfrom
rads-1996:add-remaining-metrics-a365
Open

Add remaining network sdkstats metrics for A365#192
rads-1996 wants to merge 3 commits into
microsoft:mainfrom
rads-1996:add-remaining-metrics-a365

Conversation

@rads-1996
Copy link
Copy Markdown
Member

Adding the remaining metrics -

_REQ_DURATION_NAME,
_REQ_EXCEPTION_NAME,
_REQ_FAILURE_NAME,
_REQ_RETRY_NAME,
_REQ_THROTTLE_NAME,

I will raise another PR for OTLP once this PR is merged.

@rads-1996
Copy link
Copy Markdown
Member Author

Retry Count and Request Duration
image

Throttle Count
image

Exception Count
image

Failure Count
image

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

Performance comparison

Threshold: regressions >15.0% on gating scenarios fail the build. Higher ops/s is better; positive Δ means the PR is slower.

Scenario Gating Baseline (ops/s) Candidate (ops/s) Δ % Status
azure_monitor_log yes 26,406.1 25,659.4 +2.91%
azure_monitor_span yes 154,990.7 154,273.4 +0.46%
otel_log no 31,900.0 31,368.6 +1.69%
otel_span no 34,383.2 33,640.6 +2.21%

Copy link
Copy Markdown
Contributor

Copilot AI left a 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 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 like time.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.

Comment thread src/microsoft/opentelemetry/_sdkstats/_network_metrics.py
Comment thread src/microsoft/opentelemetry/_sdkstats/_network_metrics.py
Comment thread src/microsoft/opentelemetry/_sdkstats/_network_metrics.py
Comment thread src/microsoft/opentelemetry/_sdkstats/_network_metrics.py
Comment thread src/microsoft/opentelemetry/_sdkstats/_network_metrics.py
Comment thread src/microsoft/opentelemetry/_sdkstats/_network_metrics.py
Comment thread src/microsoft/opentelemetry/_sdkstats/_network_metrics.py
Comment thread src/microsoft/opentelemetry/_sdkstats/_network_metrics.py
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.

2 participants