Skip to content

Conversation

@JacksonWeber
Copy link
Member

Packages impacted by this PR

@azure/monitor-opentelemetry-exporter

Describe the problem that is addressed by this PR

This pull request introduces a mechanism to suppress noisy Statsbeat export failures in the OpenTelemetry exporter, ensuring that transient or expected Statsbeat errors do not surface as user-facing errors unless explicitly requested. It also adds an environment variable to control this behavior and updates related tests to verify the new logic.

Statsbeat error handling improvements:

  • Adds a new environment variable SDK_STATS_LOGGING to control whether Statsbeat export failures are surfaced or silenced. By default, failures are reported as success to prevent unnecessary error propagation to customers. [1] [2]
  • Refactors the BaseSender class to use a new buildExportResult method, which applies the above logic when returning export results for Statsbeat senders. [1] [2] [3] [4] [5] [6] [7]
  • Updates the changelog to document that Statsbeat exports now report success on failed sends to prevent PeriodicExportingMetricReader errors from surfacing to customers.

Testing enhancements:

  • Adds unit tests to verify that Statsbeat sender failures are reported as success by default, and as failure when SDK_STATS_LOGGING is enabled; also confirms that customer sender failures are unaffected.

Checklists

  • Added impacted package name to the issue description
  • Does this PR needs any fixes in the SDK Generator?** (If so, create an Issue in the Autorest/typescript repository and link it here)
  • Added a changelog (if necessary)

Copy link
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 pull request introduces a mechanism to suppress noisy Statsbeat export failures in the OpenTelemetry exporter by default, ensuring that transient or expected Statsbeat errors do not surface as user-facing failures unless explicitly requested via an environment variable.

Key changes:

  • Adds a new internal environment variable SDK_STATS_LOGGING to control whether Statsbeat export failures are surfaced (when set) or silenced (default behavior)
  • Introduces a buildExportResult method in BaseSender that converts FAILED results to SUCCESS for Statsbeat senders unless the logging flag is enabled
  • Updates all failure paths in BaseSender to use the new buildExportResult method, ensuring consistent handling of Statsbeat failures

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
sdk/monitor/monitor-opentelemetry-exporter/src/Declarations/Constants.ts Adds the ENV_SDK_STATS_LOGGING constant for the new internal environment variable
sdk/monitor/monitor-opentelemetry-exporter/src/platform/nodejs/baseSender.ts Implements buildExportResult method and updates all FAILED return paths to use it, silencing Statsbeat failures by default
sdk/monitor/monitor-opentelemetry-exporter/test/internal/baseSender.spec.ts Adds comprehensive test coverage for the new behavior: Statsbeat sender failures report success by default, failures surface when SDK_STATS_LOGGING is enabled, and customer sender behavior remains unchanged
sdk/monitor/monitor-opentelemetry-exporter/CHANGELOG.md Documents that Statsbeat exports now report success on failed sends to prevent PeriodicExportingMetricReader errors

* Enable verbose statsbeat logging and surfacing failures.
* @internal
*/
export const ENV_SDK_STATS_LOGGING = "SDK_STATS_LOGGING";
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

The environment variable name 'SDK_STATS_LOGGING' doesn't follow the established convention of prefixing with 'APPLICATIONINSIGHTS_' (e.g., 'APPLICATIONINSIGHTS_SDKSTATS_ENABLED_PREVIEW'). Consider renaming to 'APPLICATIONINSIGHTS_SDK_STATS_LOGGING' or 'APPLICATIONINSIGHTS_STATSBEAT_LOGGING' for consistency with other environment variables in this codebase, particularly those related to statsbeat features.

Copilot uses AI. Check for mistakes.
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