Read for global feature sdkstats bitmap and add a 15 second delay timer#47031
Merged
Conversation
Contributor
There was a problem hiding this comment.
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 frombase_config, but the control-plane callback path usesStatsbeatManager.get_current_config()as the base config. That method currently returns a new StatsbeatConfig without themot_distro_features/mot_distro_instrumentationsvalues, 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._featureand_StatsbeatFeature.NONEare 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
45f5cb3 to
340d889
Compare
e908b7c to
59f8909
Compare
lzchen
reviewed
May 27, 2026
59f8909 to
14558ae
Compare
14558ae to
a1b632d
Compare
709ef83 to
040d308
Compare
lzchen
approved these changes
May 27, 2026
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.
TODO Since we have live metrics on by default now, we should track when it has been disabled instead.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines