Skip to content

Fix opentelemetry-distro version - #2349

Closed
rominf wants to merge 1 commit into
getsentry:masterfrom
rominf:rominf-opentelemetry-integration-deps
Closed

rominf wants to merge 1 commit into
getsentry:masterfrom
rominf:rominf-opentelemetry-integration-deps

Conversation

@rominf

@rominf rominf commented Sep 4, 2023

Copy link
Copy Markdown
Contributor

Current version of the dependency is incorrect, since integration code:

from opentelemetry.instrumentation.auto_instrumentation._load import ( # type: ignore

requires:

opentelemetry.instrumentation.auto_instrumentation._load

module to be present, but it was introduced only in 0.40b:
https://github.com/open-telemetry/opentelemetry-python-contrib/commits/main/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py

@rominf
rominf marked this pull request as ready for review September 4, 2023 14:50
@sentrivana

Copy link
Copy Markdown
Collaborator

Hey @rominf, the integration code that you linked is meant to be used with the opentelemetry-experimental target, not opentelemetry. There the version is correct:

"opentelemetry-distro~=0.40b0",

@sentrivana

Copy link
Copy Markdown
Collaborator

We can still look into updating the distro version for the opentelemetry target though, so feel free to keep this open.

@rominf

rominf commented Sep 4, 2023 •

Copy link
Copy Markdown
Contributor Author

@sentrivana Ah, OK, I was a bit wrong. Here is what happened: I was in the process of packaging the latest version for Fedora (https://src.fedoraproject.org/rpms/python-sentry-sdk) and the build failed because of import error in the referenced place. Previously, it worked because all the modules sentry_sdk.integrations.opentelemetry.* were importable (I assumed that I can and should check these modules, since opentelemetry integration lived there). However, a new module with unsatisfied dependency (Fedora version of opentelemetry-distro is lower than 0.40b0) broke the build. I can of course add this module (sentry_sdk.integrations.opentelemetry.integration) to the ignore-list for import checking, however it's likely that other packagers will bump into the same issue (maybe it'll be the problem somewhere else). What do you think?

@sentrivana

sentrivana commented Sep 5, 2023 •

Copy link
Copy Markdown
Collaborator

@rominf Gotcha, thanks for the extra context! 👍🏻

I'd prefer if we could keep the opentelemetry-distro>=0.35b0 lower bound as is to not cut off folks with older opentelemetry-distro versions. The new module that was added (sentry_sdk.integrations.opentelemetry.integration) is part of an experimental opt-in feature, so it shouldn't dictate the lower bound on an actual existing feature/dependency that was there before.

It seems that the functions exist almost in the same shape in 0.35b0, they're just in a different place and one of them is named slightly differently. If we were to do a conditional import in sentry_sdk.integrations.opentelemetry.integration like this...

try:
    # for opentelemetry-distro 0.40b0
    from opentelemetry.instrumentation.auto_instrumentation._load import _load_distro, _load_instrumentors
except ImportError:
    # for opentelemetry-distro versions between 0.35b0 and 0.39b0
    from opentelemetry.old_fun_location import _load_distros as _load_distro, _load_instrumentors  

...would that work from a packaging perspective?

Alternatively, do you see anything else we can do SDK-side to mark the _load import or the whole sentry_sdk.integrations.opentelemetry.integration module as optional?

Adding the module to the ignore list for import checks sounds like the way to go to me atm, but would like to have your opinion on the above.

@rominf

rominf commented Sep 5, 2023

Copy link
Copy Markdown
Contributor Author

I'd prefer if we could keep the opentelemetry-distro>=0.35b0 lower bound as is to not cut off folks with older opentelemetry-distro versions.

I agree!

It seems that the functions exist almost in the same shape in 0.35b0, they're just in a different place and one of them is named slightly differently. If we were to do a conditional import in sentry_sdk.integrations.opentelemetry.integration like this...

try:
    # for opentelemetry-distro 0.40b0
    from opentelemetry.instrumentation.auto_instrumentation._load import _load_distro, _load_instrumentors
except ImportError:
    # for opentelemetry-distro versions between 0.35b0 and 0.39b0
    from opentelemetry.old_fun_location import _load_distros as _load_distro, _load_instrumentors

...would that work from a packaging perspective?

Yes, it should work. Thank you for the investigation!

Adding the module to the ignore list for import checks sounds like the way to go to me atm

👍

I am closing the PR as no longer required.

@rominf rominf closed this Sep 5, 2023
@rominf
rominf deleted the rominf-opentelemetry-integration-deps branch September 5, 2023 09:23
@sentrivana

Copy link
Copy Markdown
Collaborator

So the conditional import won't work since there's some top level unguarded function running in the original module.

I think putting sentry_sdk.integrations.opentelemetry.integration on the ignore list sounds good for now.

@rominf
rominf restored the rominf-opentelemetry-integration-deps branch September 14, 2023 09:52
@rominf rominf reopened this Sep 14, 2023
@rominf
rominf force-pushed the rominf-opentelemetry-integration-deps branch from 668bd99 to e204c23 Compare September 14, 2023 09:54
@rominf

rominf commented Sep 14, 2023

Copy link
Copy Markdown
Contributor Author

Hi @sentrivana! I am back.

I think putting sentry_sdk.integrations.opentelemetry.integration on the ignore list sounds good for now.

No, this does not work neither for packaging, nor for end users of opentelemetry integration with opentelemetry-distro versions between 0.35b0 and 0.39b0 because of this line:

from sentry_sdk.integrations.opentelemetry.integration import ( # noqa: F401
, which is imported while importing:

from sentry_sdk.integrations.opentelemetry import SentrySpanProcessor, SentryPropagator

This is an issue for Fedora packaging in particular, since there is no opentelemetry-distro>=0.40b0 for actual Fedoras (Fedora Rawhide is incubating version of Fedora, all other versions are actual), also I cannot simply drop opentelemetry integration from a new version. Currently I am stuck with sentry-sdk==1.29.2 because of this.

Any suggestions?

@sentrivana

Copy link
Copy Markdown
Collaborator

Hey @rominf, sorry for the wait, was out of office last week.

We can definitely remove the offending import from __init__.py. Does that look good to you?

@rominf

rominf commented Sep 18, 2023

Copy link
Copy Markdown
Contributor Author

Hey @sentrivana. Thank you! I think it should work fine.

@sentrivana

Copy link
Copy Markdown
Collaborator

Thanks for checking! Merged it now, it'll be out with the next release, likely next week at the latest.

@sentrivana sentrivana closed this Sep 18, 2023
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.

2 participants