Skip to content

ref: Move OTel setup out of integrations/opentelemetry/ #4277

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

Merged
merged 38 commits into from
Apr 15, 2025

Conversation

sentrivana
Copy link
Contributor

@sentrivana sentrivana commented Apr 10, 2025

Moving stuff out of integrations/opentelemetry/ step by step since there is no OpenTelemetry integration anymore -- it's part of the core SDK.

  • Moved sentry_sdk/integrations/opentelemetry/integration.py -> sentry_sdk/opentelemetry/tracing.py.
  • Removed all the experimental autoinstrumentation stuff from integration.py.
  • Removed integrations/opentelemetry/ altogether (there was nothing left but __init__.py, which is now also gone).
  • Moved all tests from tests/integrations/opentelemetry to tests/opentelemetry.
  • Removed the potel/opentelemetry integration test targets from tox.ini. These will now be run as part of the Common test suite.

Ref #3853

@sentrivana sentrivana changed the title ref: Move integration out of opentelemetry/integrations/ ref: Move basic OTel setup out of integrations/opentelemetry/ Apr 10, 2025
Copy link

codecov bot commented Apr 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.55%. Comparing base (2d51839) to head (3fcbeee).
Report is 1 commits behind head on potel-base.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##           potel-base    #4277   +/-   ##
===========================================
  Coverage       83.54%   83.55%           
===========================================
  Files             144      144           
  Lines           14631    14613   -18     
  Branches         2325     2324    -1     
===========================================
- Hits            12224    12210   -14     
+ Misses           1690     1686    -4     
  Partials          717      717           
Files with missing lines Coverage Δ
sentry_sdk/client.py 84.58% <100.00%> (+0.10%) ⬆️
sentry_sdk/integrations/__init__.py 89.61% <ø> (ø)
sentry_sdk/opentelemetry/tracing.py 100.00% <100.00%> (ø)

@sentrivana sentrivana changed the title ref: Move basic OTel setup out of integrations/opentelemetry/ ref: Move OTel setup out of integrations/opentelemetry/ Apr 10, 2025
Base automatically changed from ivana/potel/move-scope-out-of-integrations to potel-base April 14, 2025 10:20
@@ -392,6 +393,13 @@ def _capture_envelope(envelope):
except Exception as e:
logger.debug("Can not set up continuous profiler. (%s)", e)

from sentry_sdk.opentelemetry.integration import (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This inline import is not great but having this on the top level causes Sphinx to fail and I've already spent too much time trying to fix this. (Ideas welcome)

Copy link
Member

Choose a reason for hiding this comment

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

I have two possible ideas:

  • Import the sentry_sdk.opentelemetry.integration module at the top, then call the methods on the module
  • Move the import to the bottom of the file in a "circular imports" section (I believe we have used this pattern elsewhere before, so it is likely preferable to an inline import if possible to do)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Neither of those works, unfortunately. They lead to more Sphinx errors.

@sentrivana sentrivana marked this pull request as ready for review April 14, 2025 13:25
@sentrivana sentrivana requested a review from a team as a code owner April 14, 2025 13:25
Copy link
Member

@szokeasaurusrex szokeasaurusrex left a comment

Choose a reason for hiding this comment

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

Some questions/suggestions

Copy link
Member

Choose a reason for hiding this comment

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

[suggestion] We should call this file something other than integration.py, since Opentelemetry is part of the SDK now, and no longer an integration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggestions welcome -- I think going with 'integration' would still be ok since we're integrating with OTel in that file but I agree it can be confusing to folks.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed naming is hard – maybe we can call it setup or something like that, given that it sets up the link with Otel?

I just think integration is particularly confusing here. While it is true that we "integrate" with Opentelemetry, the terminology is confusing because in the SDK codebase, "integration" usually means an optional integration with a library like FastAPI, Celery, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also considered setup but having a setup.py file is also not great 🫠

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Called it tracing.py now since it sets up OTel tracing

@@ -392,6 +393,13 @@ def _capture_envelope(envelope):
except Exception as e:
logger.debug("Can not set up continuous profiler. (%s)", e)

from sentry_sdk.opentelemetry.integration import (
Copy link
Member

Choose a reason for hiding this comment

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

I have two possible ideas:

  • Import the sentry_sdk.opentelemetry.integration module at the top, then call the methods on the module
  • Move the import to the bottom of the file in a "circular imports" section (I believe we have used this pattern elsewhere before, so it is likely preferable to an inline import if possible to do)

Copy link
Member

@szokeasaurusrex szokeasaurusrex left a comment

Choose a reason for hiding this comment

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

still would prefer to find a name other than integration, but I guess this would also be okay as is

Copy link
Member

Choose a reason for hiding this comment

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

Agreed naming is hard – maybe we can call it setup or something like that, given that it sets up the link with Otel?

I just think integration is particularly confusing here. While it is true that we "integrate" with Opentelemetry, the terminology is confusing because in the SDK codebase, "integration" usually means an optional integration with a library like FastAPI, Celery, etc.

@sentrivana sentrivana merged commit a610066 into potel-base Apr 15, 2025
126 checks passed
@sentrivana sentrivana deleted the ivana/potel/move-integration branch April 15, 2025 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants