Skip to content

Defensively import and vendor experimental components #41245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

lzchen
Copy link
Member

@lzchen lzchen commented May 21, 2025

Conditionally import experimental components to ensure distro does not crash on mismatched dependencies.
This could happen when there are breaking changes in upstream OpenTelemetry or azure.core

@Copilot Copilot AI review requested due to automatic review settings May 21, 2025 17:37
@github-actions github-actions bot added the Monitor - Distro Monitor OpenTelemetry Distro label May 21, 2025
Copy link
Contributor

@Copilot 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 defensively imports and vendors experimental components to prevent crashes when upstream dependencies change. Key changes include:

  • Modifying tests to conditionally patch experimental modules via sys.modules.
  • Updating dependency versions and import logic in setup.py and _configure.py.
  • Vendoring experimental OpenTelemetry code into _utils/instrumentation.py for added resilience.

Reviewed Changes

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

Show a summary per file
File Description
sdk/monitor/azure-monitor-opentelemetry/tests/test_configure.py Updated test patches to use sys.modules for experimental imports testing against breaking changes.
sdk/monitor/azure-monitor-opentelemetry/setup.py Upgraded dependency versions for Azure Monitor components and instrumentation libraries.
sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_utils/instrumentation.py Added vendored experimental code with proper documentation.
sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py Adjusted defensive import logic with try-except blocks for both tracing and logging setups.
sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md Documented the changes in the changelog to reflect updated component handling and dependency upgrades.

Comment on lines +162 to +167
"Exception occured when importing Azure SDK Tracing. Please upgrade to the latest OpenTelemetry version: %s.",
ex,
)
except Exception as ex: # pylint: disable=broad-except
_logger.warning( # pylint: disable=do-not-log-exceptions-if-not-debug
"Exception occured when setting Azure SDK Tracing: %s.",
Copy link
Preview

Copilot AI May 21, 2025

Choose a reason for hiding this comment

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

Typo in error message: 'occured' should be spelled as 'occurred'.

Suggested change
"Exception occured when importing Azure SDK Tracing. Please upgrade to the latest OpenTelemetry version: %s.",
ex,
)
except Exception as ex: # pylint: disable=broad-except
_logger.warning( # pylint: disable=do-not-log-exceptions-if-not-debug
"Exception occured when setting Azure SDK Tracing: %s.",
"Exception occurred when importing Azure SDK Tracing. Please upgrade to the latest OpenTelemetry version: %s.",
ex,
)
except Exception as ex: # pylint: disable=broad-except
_logger.warning( # pylint: disable=do-not-log-exceptions-if-not-debug
"Exception occurred when setting Azure SDK Tracing: %s.",

Copilot uses AI. Check for mistakes.

# This could possibly be due to breaking change in upstream OpenTelemetry
# Advise user to upgrade to latest OpenTelemetry version
_logger.warning( # pylint: disable=do-not-log-exceptions-if-not-debug
"Exception occured when setting up Logging. Please upgrade to the latest OpenTelemetry version: %s.",
Copy link
Preview

Copilot AI May 21, 2025

Choose a reason for hiding this comment

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

Typo in error message: 'occured' should be spelled as 'occurred'.

Suggested change
"Exception occured when setting up Logging. Please upgrade to the latest OpenTelemetry version: %s.",
"Exception occurred when setting up Logging. Please upgrade to the latest OpenTelemetry version: %s.",

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
Monitor - Distro Monitor OpenTelemetry Distro
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant