POC: support target dependencies for instrumentations #1741
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.
Description
This is a POC solution for the problem discussed in #1729 and #1563
Details
Instead of specifying instrumented libraries (target dependencies) as regular dependencies, instrumentation packages can specify such dependencies as extras with the label
target
. For example,opentelemetry-instrumentation-aiohttp-client
can specifyaoihttp
as a target dependencies instead of a regular one:opentelemetry-instrumentation-aiohttp-client
installable without automatically installing or updatingaiohttp
.opentelemetry-instrument
command will be able to tell that the instrumentor needsaiohttp ~= 3.0
. It'll only load the instrumentor if this requirement is satisfied i.e,aiohttp ~= 3.0
is installed as well.[target]
to the instrumentation package nameopentelemetry-instrumentation-aiohttp-client[target]
- Purely a packaging change. Does not require any interface or code changes to instrumentors.package_name
method.The instrument command will not require instrumentors to specify target dependencies. If an instrumentor does not specify any target dependencies, the instrument command will always load and apply the instrumentor.
Changes required to be made to instrumentations
Every instrumentation will need two changes.
package_name() -> str
method. This method would return the Python package name of the instrumentor. For exampleRequestsInstrumentor().package_name()
would returnopentelemetry-instrumentation-requests
.This demo contrib PR showcases what changes every instrumentation package would need: https://github.com/open-telemetry/opentelemetry-python-contrib/pull/397/files
Considerations
target
to represent instrumented libraries. I just picked something to allow me to move forward with the POC. What would be a better name for such deps?package_name()
method that returns the Python package name of the instrumentor, we can have the instrumentors define apackage_name() -> str
method that just returns the package name of the instrumentor itself. We can implement it either way and it has almost no impact on the implementation. The question is what makes more sense for instrumentation authors.vs
Future iterations