fix: make telemetry initialization non-fatal - #749
Open
sentry[bot] wants to merge 1 commit into
Open
Conversation
❌ 1 Tests Failed:
View the full list of 1 ❄️ flaky test(s)
To view more test analytics, go to the Test Analytics Dashboard |
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.
This PR addresses the
AttributeError: module 'sentry_sdk' has no attribute 'get_current_hub'issue by making the telemetry initialization process non-fatal.Root Cause: The original issue stemmed from older CLI versions (specifically
cli@10.0.1) where theopentelemetry.pymodule included an OpenTelemetry integration that internally calledsentry_sdk.get_current_hub(). This function was part of the Sentry SDK 1.x Hub API and was removed in Sentry SDK 2.x, whichcli@10.0.1was configured to use. This mismatch caused theAttributeErrorand crashed the CLI.Previous Fix: The OpenTelemetry integration, including the problematic
SentrySpanProcessorandSentryPropagatorimports, was removed fromcodecov_cli/opentelemetry.pyin commitdca7a65on Jan 21, 2025. This means that CLI versions released after this date no longer contain the code that directly causes thisAttributeError.Current Change: While the underlying bug is resolved in newer CLI versions, this PR adds a defensive
try-exceptblock around theinit_telem(ctx.obj)call incodecov_cli/main.py. This ensures that if any future Sentry SDK incompatibility or other issue arises during telemetry initialization, it will be caught, logged at a debug level, and will not prevent the CLI from executing its core functionality.Impact: This change improves the robustness of the CLI. Users running older, affected versions (like
cli@10.0.1) are strongly encouraged to upgrade to the latest CLI version to benefit from both the original fix and this added layer of stability.Fixes CLI-FV