-
Notifications
You must be signed in to change notification settings - Fork 666
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
Allow customizing instrumentation loading #1751
Conversation
0f1b149
to
1574908
Compare
Is this ready for review? |
No, not ready yet. I wanted to get initial feedback on the approach before preparing it for actual review. Context here: https://cloud-native.slack.com/archives/C01PD4HUVBL/p1617697664091300 |
Updated description. |
I'm having a bit of a hard time understanding this. The idea is for allowing instrumentations to receive configurable options, right? A few questions:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this is something we should define another entrypoint for or if it would be better to have a configuration object that includes a loader be returned from the distro configuration.
instrumentation_loader(entry_points) | ||
|
||
|
||
def _default_instrumentation_loader(entry_points): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we go this route, we should define an interface for what makes a loader
1574908
to
1304cd5
Compare
I like this idea. We already have a way to let distributions customize behavior. No need to introduce more. Updated the implementation. One implication of using distro here is that loading instrumentations now depends on a Distro being installed while as before they'd be loaded even without one. This means users will have to at least install |
Yes but it's mainly for distributions to configure instrumentations according to their needs. Flask accepts a "span name callback" for example which can be used to customize the name FlaskInstrumentor generated spans should use. This also enables other use cases that were not possible before like distributions not wanted to support a specific version of an instrumentation. Let's say instrumentation X v0.25 has a known but that is not acceptable for a distribution, it can inspect the entrypoint and skip loading it or even load a fork instead. I'm just thinking out load :) but the point is that this gives distributions control over an important aspect of the
It is possible but not very nice and it may requires changes to instrumentations themselves. For example, we can specify excluded urls for Flask as an env var but we cannot specify a "span name callback" or "response callback" function via env vars or CLI args. Well, technically we can but then flask instrumentor will have to read a string and dynamically import a function from the path described by the string. That's not very convenient for an instrumentor to implement. |
1304cd5
to
983ad4e
Compare
ac376cc
to
27b0839
Compare
This commit makes the following changes: - Introduces a new `load_instrumentor(EntryPoint) -> None:` with a default implementation method to the `BaseDistro` class. - The default implementation loads the insrumentor from the provided entry point and calls applies it without any arguments. (same as before) - sitecustomize now calls Distro's `load_instrumentor` method to load and activate an instrumentor instead of doing it directly. - Added a new `DefaultDistro` implementation which is used if not distro is found by entry points.
27b0839
to
fb35915
Compare
Actually, we have been using entry points to allow for environment variables to point to functions or classes (they can point to any Python object). So, any callback can be specified with an environment variable in this way. |
Moved PR to contrib: open-telemetry/opentelemetry-python-contrib#480 |
Description
This feature allows distros to customize instrumentation initialization when using automatically instrumenting with the
opentelemetry-instrument
command.Type of change
Please delete options that are not relevant.
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
Does This PR Require a Contrib Repo Change?
Checklist: