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 some support for programmatic instrumentation #554

Closed
ocelotl opened this issue Apr 6, 2020 · 1 comment · Fixed by #579
Closed

Add some support for programmatic instrumentation #554

ocelotl opened this issue Apr 6, 2020 · 1 comment · Fixed by #579
Assignees
Labels
instrumentation Related to the instrumentation of third party libraries or frameworks

Comments

@ocelotl
Copy link
Contributor

ocelotl commented Apr 6, 2020

This comment in #551 raised the concern about making it possible to use the instrumentors in a programmatic way too, not only automatically.

Using them programmatically means adding code directly in the application that performs instrumentation, for example, this or this.

It is very likely that this programmatic use of the instrumentors needs to be implemented in a framework-specific way, this means that the way we can do this kind of instrumentation is different for Flask and is different too for Django, for example. That means that it is possible that we end up having just special code for each framework as opposed to having a universal mechanism that works for every framework (this would mean that this issue could end up being closed without any fix).

This programmatic instrumentation mechanisms can be more sophisticated, for example, in an OpenTracing-related project here it is shown how the programmatic instrumentation mechanism allows the user to select which application functions are to be traced.

In summary, what we want to introduce with this issue, is the capability to perform instrumentation without having to directly write the code that creates the spans but also without using the opentelemetry-auto-instrumentation command, but with a different mechanism (probably specifically tailored for each framework (Django, Flask, etc.)) like decorators or maybe Python context managers (the ones that use with, to avoid any confusion with the OpenTelemetry concept of context 🙂).

@mauriciovasquezbernal @codeboten we have just talked about this 👍

Also, to make things clear, with this approach we would have 3 ways of doing instrumentation:

  1. The "normal" way (instantiating the spans directly with OpenTelemetry-provided functions)
  2. The automatic way (using the opentelemetry-auto-instrumentation command)
  3. The programmatic way (using a mechanism as described here to instrument specific frameworks)
@ocelotl ocelotl self-assigned this Apr 6, 2020
@ocelotl ocelotl added the instrumentation Related to the instrumentation of third party libraries or frameworks label Apr 6, 2020
@ocelotl ocelotl changed the title Introduce a mechanism for manual, framework-specific instrumentation Introduce a mechanism for programmatic instrumentation Apr 6, 2020
ocelotl added a commit to ocelotl/opentelemetry-python that referenced this issue Apr 14, 2020
@ocelotl ocelotl changed the title Introduce a mechanism for programmatic instrumentation Add some support for programmatic instrumentation Apr 14, 2020
@ocelotl
Copy link
Contributor Author

ocelotl commented Apr 14, 2020

I am renaming this and using the word "some" because I think programmatic instrumentation is very third-party-library dependent and can be implemented in several different ways. #579 just adds some functionality that can be useful for programmatic instrumentation developers.

ocelotl added a commit to ocelotl/opentelemetry-python that referenced this issue Apr 15, 2020
ocelotl added a commit to ocelotl/opentelemetry-python that referenced this issue Apr 20, 2020
ocelotl added a commit to ocelotl/opentelemetry-python that referenced this issue Apr 21, 2020
toumorokoshi pushed a commit that referenced this issue Apr 22, 2020
Fixes #554

This makes it possible to call the instrument method with arguments that make programmatic instrumentation possible.

This also makes the children of BaseInstrumentors to be singletons. In this way regardless of how many times the programmatic instrumentation or uninstrumentation methods are called they will only be executed once.
codeboten pushed a commit to codeboten/opentelemetry-python that referenced this issue Apr 23, 2020
…try#579)

Fixes open-telemetry#554

This makes it possible to call the instrument method with arguments that make programmatic instrumentation possible.

This also makes the children of BaseInstrumentors to be singletons. In this way regardless of how many times the programmatic instrumentation or uninstrumentation methods are called they will only be executed once.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
instrumentation Related to the instrumentation of third party libraries or frameworks
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant