Skip to content

Read for global feature sdkstats bitmap and add a 15 second delay timer#47031

Merged
rads-1996 merged 5 commits into
Azure:mainfrom
rads-1996:mot-feature-sdkstats
May 27, 2026
Merged

Read for global feature sdkstats bitmap and add a 15 second delay timer#47031
rads-1996 merged 5 commits into
Azure:mainfrom
rads-1996:mot-feature-sdkstats

Conversation

@rads-1996
Copy link
Copy Markdown
Member

@rads-1996 rads-1996 commented May 20, 2026

TODO Since we have live metrics on by default now, we should track when it has been disabled instead.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Copilot AI review requested due to automatic review settings May 20, 2026 23:16
@github-actions github-actions Bot added the Monitor - Exporter Monitor OpenTelemetry Exporter label May 20, 2026
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 azure-monitor-opentelemetry-exporter statsbeat so it can accept Microsoft OpenTelemetry distro feature/instrumentation bitmasks (including lazily via callables) and OR them into the emitted statsbeat feature/instrumentation bitmaps, with accompanying test coverage.

Changes:

  • Add new internal kwargs/fields for Microsoft OpenTelemetry distro feature + instrumentation bitmasks and plumb them from exporter → StatsbeatConfig_StatsbeatMetrics.
  • Update statsbeat metric emission to OR in these bitmasks (and resolve them lazily each collection when provided as callables).
  • Add unit tests covering the new bitmask behavior across config, manager, and metric emission paths.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/_statsbeat_metrics.py Accept and lazily resolve MOT distro bitmasks; OR them into statsbeat feature/instrumentation metrics.
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/_manager.py Extend StatsbeatConfig and initialization flow to carry MOT distro bitmask fields into _StatsbeatMetrics.
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py Capture MOT distro bitmask kwargs on exporter instances so statsbeat can consume them.
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_constants.py Define internal kwarg names for MOT distro bitmask inputs.
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_storage.py Minor comment formatting tweak in folder-permission checks.
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/statsbeat/test_statsbeat.py Update existing tests for new args and add an end-to-end flow test for MOT distro bits.
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/statsbeat/test_metrics.py Add metric-level tests validating feature/instrumentation OR-ing behavior.
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/statsbeat/test_manager.py Add tests ensuring StatsbeatConfig stores/copies/preserves MOT distro fields.
Comments suppressed due to low confidence (2)

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/_manager.py:142

  • from_config() copies mot_distro_* fields from base_config, but the control-plane callback path uses StatsbeatManager.get_current_config() as the base config. That method currently returns a new StatsbeatConfig without the mot_distro_features / mot_distro_instrumentations values, so a reconfiguration would silently drop the distro bitmasks back to 0. Update get_current_config() to include these fields (or otherwise ensure reconfig preserves them).
        return cls(
            endpoint=base_config.endpoint,
            region=base_config.region,
            instrumentation_key=base_config.instrumentation_key,
            disable_offline_storage=disable_offline_storage_config,  # TODO: Use config value once supported
            credential=base_config.credential,
            distro_version=base_config.distro_version,
            mot_distro_features=base_config.mot_distro_features,
            mot_distro_instrumentations=base_config.mot_distro_instrumentations,
            connection_string=connection_string,
        )

sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/_statsbeat_metrics.py:301

  • self._feature and _StatsbeatFeature.NONE are ints; using identity comparison (is not) is not reliable for numeric equality and can behave unexpectedly across interpreters/optimizations. Use != here so the feature observation emission check is correct by value.
        # Don't send observation if no features enabled
        if self._feature is not _StatsbeatFeature.NONE:
            attributes = dict(_StatsbeatMetrics._COMMON_ATTRIBUTES)
            attributes.update(_StatsbeatMetrics._FEATURE_ATTRIBUTES)  # type: ignore
            observations.append(Observation(1, dict(attributes)))  # type: ignore

@rads-1996 rads-1996 force-pushed the mot-feature-sdkstats branch 3 times, most recently from 45f5cb3 to 340d889 Compare May 21, 2026 15:46
@rads-1996 rads-1996 changed the title Accept bitmask from microsoft distro and OR with azure monitor feature sdkstats Read for global feature sdkstats bitmap and add a 15 second delay timer May 26, 2026
@rads-1996 rads-1996 force-pushed the mot-feature-sdkstats branch 3 times, most recently from e908b7c to 59f8909 Compare May 26, 2026 20:05
@rads-1996 rads-1996 force-pushed the mot-feature-sdkstats branch from 59f8909 to 14558ae Compare May 27, 2026 16:54
@rads-1996 rads-1996 force-pushed the mot-feature-sdkstats branch from 14558ae to a1b632d Compare May 27, 2026 17:55
@rads-1996 rads-1996 force-pushed the mot-feature-sdkstats branch from 709ef83 to 040d308 Compare May 27, 2026 20:36
@rads-1996 rads-1996 merged commit d6f1a72 into Azure:main May 27, 2026
19 checks passed
@rads-1996 rads-1996 deleted the mot-feature-sdkstats branch May 27, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Monitor - Exporter Monitor OpenTelemetry Exporter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants