Skip to content
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

Remove pkg_resource and replace for importlib.metadata in autoinstrumentation #2181

Conversation

Rodrigo-Novas
Copy link
Contributor

@Rodrigo-Novas Rodrigo-Novas commented Feb 14, 2024

Description

Pkgresource dependency is deprecated, on this pr i replaced pkg_resource for importlib.metadata.

Fixes #2180

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Run with tox the unit tests

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@Rodrigo-Novas Rodrigo-Novas requested a review from a team February 14, 2024 20:43
Copy link

linux-foundation-easycla bot commented Feb 14, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@ocelotl
Copy link
Contributor

ocelotl commented Feb 14, 2024

@Rodrigo-Novas please sign the CLA ✌️

@andre-meneses-fivestars
Copy link

Is there an expected ETA on this?

@WillDaSilva
Copy link

I believe this would also fix:

@psi29a
Copy link

psi29a commented May 13, 2024

Hope this gets picked back up! Great work so far!

@@ -19,7 +19,7 @@
from re import sub
from shutil import which

from pkg_resources import iter_entry_points
from importlib.metadata import entry_points
Copy link

Choose a reason for hiding this comment

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

You are adding importlib-metadata to the dependencies, but this import is from the Python standard library. There is a discussion here: open-telemetry/opentelemetry-python#3234 about using importlib-metadata and its implications. Note my comment at the end.

Copy link
Contributor Author

@Rodrigo-Novas Rodrigo-Novas Jul 11, 2024

Choose a reason for hiding this comment

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

Hello, sorry for the delay.
If I understand correctly, you mean having a standard library with its own constraint within Opentelemetry would be wrong. I think that the change of importlib-metadata version could be made later if an error is reported.

#2181 (comment)

#2181 (comment)

Choose a reason for hiding this comment

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

IMHO its fine to depend on importlib-metadata, as its the python-version independent backport of the stdlib feature.
it will be easier to develop against.

@pablo-sumup
Copy link

Hey there! Could you prioritize the code review for this PR? It's for migrating to Python 3.12. Thanks a bunch! :D

@theunkn0wn1
Copy link

Any ETA on this?
the package is broken in modern python versions due to undeclared pkg_resources usage.

@lzchen
Copy link
Contributor

lzchen commented Aug 13, 2024

@Rodrigo-Novas

Are you still working on this? If so we can prioritize getting this reviewed and merged. It is difficult to know what the current status is so please close the conversations that you think have been resolved and note down the open topics that still need to be discussed. Feel free to also join the Python SIG if you want to bring this issue up to the community specifically.

@michaelgmiller1
Copy link

We are also getting hit with this on every unit test run. It would be great to get a fix in.

@Rodrigo-Novas
Copy link
Contributor Author

@Rodrigo-Novas

Are you still working on this? If so we can prioritize getting this reviewed and merged. It is difficult to know what the current status is so please close the conversations that you think have been resolved and note down the open topics that still need to be discussed. Feel free to also join the Python SIG if you want to bring this issue up to the community specifically.

@lzchen

Its ok for me, you can review it!

@Rodrigo-Novas
Copy link
Contributor Author

We are also getting hit with this on every unit test run. It would be great to get a fix in.

i will try to fix it

CHANGELOG.md Outdated Show resolved Hide resolved
@lzchen lzchen changed the title Remove pkg_resource and replace for importlib.metadata Remove pkg_resource and replace for importlib.metadata in autoinstrumentaiton Aug 28, 2024
@lzchen lzchen changed the title Remove pkg_resource and replace for importlib.metadata in autoinstrumentaiton Remove pkg_resource and replace for importlib.metadata in autoinstrumentation Aug 28, 2024
"wrapt >= 1.0.0, < 2.0.0",
"importlib-metadata >= 6.0, < 8.0",
Copy link

@Arnatious Arnatious Aug 29, 2024

Choose a reason for hiding this comment

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

importlib-metadata is already aliased in opentelemetry-api (https://github.com/open-telemetry/opentelemetry-python/blob/main/opentelemetry-api/src/opentelemetry/util/_importlib_metadata.py) - should we reuse this rather than re-introduce the dependency?

Copy link
Contributor

Choose a reason for hiding this comment

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

There is at:

    "importlib-metadata >= 6.0, <= 8.4.0",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@serkan-ozal
Copy link

Switching from pkg_resource to importlib.metadata also helps us to reduce OTEL Python layer Lambda coldstart.

@bhaskarbanerjee
Copy link

When is this PR expected to be approved and merged?

@xrmx
Copy link
Contributor

xrmx commented Sep 3, 2024

When is this PR expected to be approved and merged?

When it's ready

@ocelotl
Copy link
Contributor

ocelotl commented Sep 5, 2024

When is this PR expected to be approved and merged?

We are trying to get more eyes on this PR, we realize it is important for many people. The issue at hand here is not particularly easy to solve (kudos to @Rodrigo-Novas for the work so far!) since it deals with replacing an old library with a new one where there is not necessarily a 1:1 relationship between old library and new library components. To make matters even more complicated, the new library has been implemented very inconsistently, so its behavior for Python 3.x is not the same as for Python 3.y.

We are working on this and we'll merge as soon as we can 🙂

@Arnatious
Copy link

For anyone following - this is currently blocked by (at minimum) open-telemetry/opentelemetry-python#4177, as well as a new release needed for open-telemetry/opentelemetry-python#4181 . Some of our assumptions in the previous discussions mentioned need to be re-addressed if we swap to relying on the stdlib in python <= 3.11, which will delay this a bit further.

@xrmx
Copy link
Contributor

xrmx commented Sep 23, 2024

For anyone following - this is currently blocked by (at minimum) open-telemetry/opentelemetry-python#4177, as well as a new release needed for open-telemetry/opentelemetry-python#4181 . Some of our assumptions in the previous discussions mentioned need to be re-addressed if we swap to relying on the stdlib in python <= 3.11, which will delay this a bit further.

We're keeping importlib_metadata as dependency and PRs run against main of branch of core repo so no need for releases. The current blocker for me is this #2181 (comment)

@xrmx xrmx closed this Sep 23, 2024
@xrmx xrmx reopened this Sep 23, 2024
@xrmx xrmx requested a review from a team as a code owner September 23, 2024 07:24
@xrmx xrmx mentioned this pull request Oct 17, 2024
11 tasks
@multani
Copy link

multani commented Oct 20, 2024

@xrmx I think this should have been closed by #2871, right?

@xrmx
Copy link
Contributor

xrmx commented Oct 21, 2024

Closing, since this has been included in #2871. Thanks everyone!

@xrmx xrmx closed this Oct 21, 2024
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.

Remove pkg_resource and replace for importlib.metadata