-
Notifications
You must be signed in to change notification settings - Fork 633
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 Configuration from instrumentations #285
Conversation
Please update the title and description of the PR to be more informative. |
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.
PR looks pretty good, just waiting on responses to the comment about moving the excludelist code into the instrumentation package before approving.
.../opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware.py
Outdated
Show resolved
Hide resolved
Done! 👍 |
6e0caf0
to
2be6c6e
Compare
...on/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py
Outdated
Show resolved
Hide resolved
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.
Overall LGTM except the decision to move WSGI/ASGI middleware instrumentation libraries to util.
from opentelemetry.context import attach, detach | ||
from opentelemetry.instrumentation.django.version import __version__ | ||
from opentelemetry.instrumentation.utils import extract_attributes_from_object | ||
from opentelemetry.instrumentation.wsgi import ( |
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 believe this wsgi instrumentation library could be used for any wsgi framework to collect telemetry. For instance let's say I have a WSGI based framework X and there is no standalone instrumentation for it. If we remove this what would be the way for collecting telemetry?
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.
The WSGI code as it is now is not an instrumentation because it does no implement BaseInstrumentor
. There is no WSGI library that is instrumented by it as opposed to specific libraries like Flask, Django, etc. For that reason, the WSGI code should not be in opentelemetry.instrumentation
.
I don't understand what you mean with "For instance let's say I have a WSGI based framework X and there is no standalone instrumentation for it. If we remove this what would be the way for collecting telemetry?", can you explain, please?
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.
The WSGI and ASGI are different instrumentation libraries on their own as of now. I may be wrong but my understanding is that I can use opentelemetry-instrumentation-wsgi with any wsgi based web frameworks to collect telemetry. I will try to use an example to clarify the last part, We don't have the instrumentation library for cherrpy framework but I can still instrument my cherrpy
based application using opentelemetry-instrumentation-wsgi
. It would look something similar as followed
import cherrypy
from opentelemetry.instrumentation.wsgi import OpenTelemetryMiddleware
class HelloWorld(object):
@cherrypy.expose
def index(self):
return "Hello World!"
app = cherrypy.Application(HelloWorld(), '/')
app.wsgiapp = OpenTelemetryMiddleware(app.wsgiapp)
cherrypy.quickstart(app)
I didn't think of WSGI/ASGI OpenTelemetryMiddleware
as an util although there are some util functions in that package. It was easier to find that library, docs and use because it is very similar to any other popular middlewares flask-cache or bottle middlewares etc.. to name few. I thought may be util is not an ideal place to put middleware kind of stuff, just wanted to understand the motivation behind moving from individual packages to util. On the other hand I think it is good to move the helper functions under util.http
.
.../opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.py
Outdated
Show resolved
Hide resolved
...on/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py
Outdated
Show resolved
Hide resolved
util/opentelemetry-util-http/src/opentelemetry/util/http/asgi/__init__.py
Outdated
Show resolved
Hide resolved
util/opentelemetry-util-http/src/opentelemetry/util/http/wsgi/version.py
Outdated
Show resolved
Hide resolved
from opentelemetry.instrumentation.utils import http_status_to_status_code | ||
from opentelemetry.trace.propagation.textmap import DictGetter | ||
from opentelemetry.trace.status import Status, StatusCode | ||
from opentelemetry.util.http.asgi.version import __version__ # noqa |
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.
Not sure about moving the WSGI/ASGI OpenTelemetryMiddleware
classes to the opentelemetry-util-http
package. With this there are now 3 version.py
files in the package since both OpenTelemetryMiddleware
implementations are de facto instrumentations which require the version to get the tracer for producing spans.
Imo WSGI/ASGI OpenTelemetryMiddleware
should stay in their own dedicated packages (common helper methods for extracting span attriubtes, ... can be moved to the util package though), also for dependency reasons. E.g. if one wants instrument an arbitrary WSGI application with the WSGI OpenTelemetryMiddleware
from the opentelemetry-util-http
the asgiref
library will be pulled additionally even though it is not required.
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.
@mariojonke @lonewolf3739
I understand that the current ASGI and WSGI packages are closely related to instrumentation. Nevertheless, they are not complete instrumentations as the rest of the instrumentations because they are not instrumenting anything by themselves when auto instrumentation happens nor they implement BaseInstrumentor
. For that reason I believe they should not be part of any instrumentation
package. The idea of util
is pretty much to have a place where we can put anything that does not fit in the category of exporter, instrumentation, api, sdk, etc. I believe this to be the case, even when I see how this approach causes some concern because of the close relationship between the ASGI and WSGI and the instrumentation of other third party libraries.
Maybe having a util.instrumentation.asgi
/wsgi
package would be a better solution? 🤷
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.
Those are valid points for why asgi
/wsgi
middleware aren't really a otel instumentation
library. How does the versioning and packaging happen? Isn't it like util
lib as a whole bumps version even when there aren't any changes in middleware?
Maybe having a
util.instrumentation.asgi
/wsgi
package would be a better
+1. Probably we should have good documentation to make it is easier to find and use these middleware as a substitute when there is no stand alone instrumentation for third party ASGI/WSGI frameworks.
This moves the WSGI and ASGI instrumentations and some other functionality to a new package for HTTP-related functionality.
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.
For the sake of getting the configuration piece moved forward, please keep the asgi/wsgi packages as separate for now. I feel like that discussion can be had separately from removing the config.
Sure, separating this |
b246cce
to
9e97619
Compare
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.
Thanks for addressing my comments!
Description
As discussed here we are removing
Configuration
from the core repo. This means that it needs to be removed here as well. This PR does that.This also adds an
opentelemetry.util
namespace where util code can be added to. Should this go into a separate PR? I also think so. Nevertheless, I am adding this here because there was some non-configuration-related code in the oldConfiguration
class that I am moving into this namespace now. I understand that this can be controversial, so if you prefer this to be split into 2 PRs comment below, please. 👍Fixes #284
Type of change
Please delete options that are not relevant.
Does This PR Require a Core Repo Change?
Configuration
opentelemetry-python#1523Checklist:
See contributing.md for styleguide, changelog guidelines, and more.