Update telemetry event dependency to OpenTelemetry LoggingHandler#69
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request refactors the Azure Monitor telemetry integration to emit feature evaluation events via OpenTelemetry’s LoggingHandler rather than the deprecated azure-monitor-events-extension, and updates the test suite and dependency metadata to align with the new approach.
Changes:
- Replaced direct
azure-monitor-events-extensionevent tracking with an OpenTelemetry-backed event logger infeaturemanagement/azuremonitor/_send_telemetry.py. - Updated
tests/test_send_telemetry_appinsights.pyto assert the newtrack_event(event_name, user, event_properties=...)call shape and added coverage for the reservedmicrosoft.custom_event.nameattribute behavior. - Updated
pyproject.tomloptional dependencies to useazure-monitor-opentelemetryand introduced an explicit OpenTelemetry logging instrumentation dependency (currently only indev).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| featuremanagement/azuremonitor/_send_telemetry.py | Refactors telemetry publishing to use an OpenTelemetry logging handler and updates span processor gating/types accordingly. |
| tests/test_send_telemetry_appinsights.py | Adjusts tests to patch/assert the new tracking mechanism and validates reserved attribute handling. |
| pyproject.toml | Swaps the Azure Monitor optional dependency to azure-monitor-opentelemetry and updates dev/test dependency lists. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…eManagement-Python into yuanqu-telemetry
mrm9084
requested changes
Jun 29, 2026
mrm9084
requested changes
Jun 30, 2026
mrm9084
requested changes
Jun 30, 2026
mrm9084
requested changes
Jun 30, 2026
mrm9084
approved these changes
Jun 30, 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.
Overview
This pull request modernizes the Azure Monitor telemetry integration by switching from the deprecated
azure-monitor-events-extensionto the OpenTelemetry logging handler. It updates the telemetry event sending logic, improves the handling of reserved log attributes, and refactors tests to match the new implementation. Dependency management and sample requirements are also updated for consistency.Telemetry integration updates:
azure-monitor-events-extensionwith OpenTelemetry'sLoggingHandlerfor sending telemetry events, introducing a dedicated logger (_event_logger) and initialization logic in_send_telemetry.py. This ensures telemetry events are sent in a more standard and extensible way.track_eventandpublish_telemetryfunctions to use the new logging-based approach, including logic to avoid conflicts with reserved log record attributes. [1] [2]TargetingSpanProcessorto check for OpenTelemetry logging support rather than the old extension.Dependency and configuration changes:
pyproject.tomlto requireopentelemetry-sdkinstead ofazure-monitor-events-extension.azure-monitor-events-extensionfromsamples/requirements.txt.Testing improvements:
test_send_telemetry_appinsights.pyto patch the newtrack_eventfunction instead of the old event extension, and adds a helper to extract event properties from mock calls. [1] [2] [3] [4] [5] [6] [7]microsoft.custom_event.name) are handled safely and not overwritten.Validation
Verified that quota-of-the-day app is still able to send telemetry to my testing app insights in the correct location.
