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

Add dependency information in setup.py for instrumentation #749

Closed
lucemia opened this issue Oct 16, 2021 · 2 comments
Closed

Add dependency information in setup.py for instrumentation #749

lucemia opened this issue Oct 16, 2021 · 2 comments

Comments

@lucemia
Copy link

lucemia commented Oct 16, 2021

Before opening a feature request against this repo, consider whether the feature should/could be implemented in the other OpenTelemetry client libraries. If so, please open an issue on opentelemetry-specification first.

Is your feature request related to a problem?
If so, provide a concise description of the problem.

Describe the solution you'd like
What do you want to happen instead? What is the expected behavior?

Add version requirement info in setup.py, so the dependency requirements/conflicts can be solved automatically.

setup(
...
 install_requires=[
        "httpx>=0.18.0,<0.19.0",
         ...

Describe alternatives you've considered
Which alternative solutions or features have you considered?

Additional context
Add any other context about the feature request here.

@owais
Copy link
Contributor

owais commented Oct 16, 2021

It would be ideal if an instrumentation package could provide hints about which other packages it is compatible with without forcing users to install those packages. Unfortunately, the Python packaging ecosystem does not allow that and the only thing it allows is to specify another package as a dependency. This makes things tricky for instrumentation pacakges. We delibrately made the decision to not specify instrumented libs/frameworks as dependencies in order to allow a lot more flexibility into how instrumentation is installed, bundled and used on a wide variety of environments. More details here: open-telemetry/opentelemetry-python#1729

That said, all instrumentation packages do specify all the packages they instrument as optional dependencies under instruments extra requires section. If you want pip to ensure installing only compatible versions at install time, you can run pip install opentelemetry-instrumentation-httpx[instruments] and it'll behave exactly how you want it to.

For example, the following raises errors at install time

❯ pip install opentelemetry-instrumentation-falcon[instruments]==0.25b0 falcon==1.0.0
Requirement already satisfied: opentelemetry-instrumentation-falcon[instruments]==0.25b0 in ./venv/lib/python3.9/site-packages (0.25b0)
Collecting falcon==1.0.0
  Using cached falcon-1.0.0-py2.py3-none-any.whl (107 kB)
Requirement already satisfied: six>=1.4.0 in ./venv/lib/python3.9/site-packages (from falcon==1.0.0) (1.16.0)
Requirement already satisfied: python-mimeparse in ./venv/lib/python3.9/site-packages (from falcon==1.0.0) (1.6.0)
Requirement already satisfied: opentelemetry-util-http==0.25b0 in ./venv/lib/python3.9/site-packages (from opentelemetry-instrumentation-falcon[instruments]==0.25b0) (0.25b0)
Requirement already satisfied: opentelemetry-instrumentation-wsgi==0.25b0 in ./venv/lib/python3.9/site-packages (from opentelemetry-instrumentation-falcon[instruments]==0.25b0) (0.25b0)
Requirement already satisfied: opentelemetry-semantic-conventions==0.25b0 in ./venv/lib/python3.9/site-packages (from opentelemetry-instrumentation-falcon[instruments]==0.25b0) (0.25b0)
Requirement already satisfied: opentelemetry-instrumentation==0.25b0 in ./venv/lib/python3.9/site-packages (from opentelemetry-instrumentation-falcon[instruments]==0.25b0) (0.25b0)
Requirement already satisfied: opentelemetry-api~=1.3 in ./venv/lib/python3.9/site-packages (from opentelemetry-instrumentation-falcon[instruments]==0.25b0) (1.6.0)
INFO: pip is looking at multiple versions of falcon to determine which version is compatible with other requirements. This could take a while.
ERROR: Cannot install falcon==1.0.0 and opentelemetry-instrumentation-falcon[instruments]==0.25b0 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested falcon==1.0.0
    opentelemetry-instrumentation-falcon[instruments] 0.25b0 depends on falcon<4.0.0 and >=2.0.0; extra == "instruments"

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies

But this works:

❯ pip install opentelemetry-instrumentation-falcon==0.25b0 falcon==1.0.0
Requirement already satisfied: opentelemetry-instrumentation-falcon==0.25b0 in ./venv/lib/python3.9/site-packages (0.25b0)
Collecting falcon==1.0.0
  Using cached falcon-1.0.0-py2.py3-none-any.whl (107 kB)
Requirement already satisfied: opentelemetry-semantic-conventions==0.25b0 in ./venv/lib/python3.9/site-packages (from opentelemetry-instrumentation-falcon==0.25b0) (0.25b0)
Requirement already satisfied: opentelemetry-instrumentation==0.25b0 in ./venv/lib/python3.9/site-packages (from opentelemetry-instrumentation-falcon==0.25b0) (0.25b0)
Requirement already satisfied: opentelemetry-api~=1.3 in ./venv/lib/python3.9/site-packages (from opentelemetry-instrumentation-falcon==0.25b0) (1.6.0)
Requirement already satisfied: opentelemetry-instrumentation-wsgi==0.25b0 in ./venv/lib/python3.9/site-packages (from opentelemetry-instrumentation-falcon==0.25b0) (0.25b0)
Requirement already satisfied: opentelemetry-util-http==0.25b0 in ./venv/lib/python3.9/site-packages (from opentelemetry-instrumentation-falcon==0.25b0) (0.25b0)
Requirement already satisfied: six>=1.4.0 in ./venv/lib/python3.9/site-packages (from falcon==1.0.0) (1.16.0)
Requirement already satisfied: python-mimeparse in ./venv/lib/python3.9/site-packages (from falcon==1.0.0) (1.6.0)
Requirement already satisfied: wrapt<2.0.0,>=1.0.0 in ./venv/lib/python3.9/site-packages (from opentelemetry-instrumentation==0.25b0->opentelemetry-instrumentation-falcon==0.25b0) (1.12.1)
Requirement already satisfied: Deprecated>=1.2.6 in ./venv/lib/python3.9/site-packages (from opentelemetry-api~=1.3->opentelemetry-instrumentation-falcon==0.25b0) (1.2.13)
Installing collected packages: falcon
  Attempting uninstall: falcon
    Found existing installation: falcon 3.0.1
    Uninstalling falcon-3.0.1:
      Successfully uninstalled falcon-3.0.1
Successfully installed falcon-1.0.0

@lucemia
Copy link
Author

lucemia commented Oct 17, 2021

The opentelemetry-instrumentation-httpx[instruments] solutions works! thanks

@lucemia lucemia closed this as completed Oct 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants