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

Remove Configuration from instrumentations #285

Merged
merged 11 commits into from
Feb 4, 2021

Conversation

ocelotl
Copy link
Contributor

@ocelotl ocelotl commented Jan 12, 2021

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 old Configuration 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.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Does This PR Require a Core Repo Change?

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@ocelotl ocelotl self-assigned this Jan 12, 2021
@ocelotl ocelotl marked this pull request as ready for review January 12, 2021 06:25
@ocelotl ocelotl requested a review from a team as a code owner January 12, 2021 06:25
@ocelotl ocelotl requested review from owais and lzchen and removed request for a team January 12, 2021 06:25
@lzchen
Copy link
Contributor

lzchen commented Jan 12, 2021

Please update the title and description of the PR to be more informative.

@ocelotl ocelotl changed the title Issue 284 Remove Configuration from instrumentations Jan 12, 2021
Copy link
Contributor

@codeboten codeboten left a 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.

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@ocelotl
Copy link
Contributor Author

ocelotl commented Jan 16, 2021

Please update the title and description of the PR to be more informative.

Done! 👍

@ocelotl ocelotl force-pushed the issue_284 branch 10 times, most recently from 6e0caf0 to 2be6c6e Compare January 21, 2021 23:26
Copy link
Member

@srikanthccv srikanthccv left a 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 (
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

@srikanthccv srikanthccv Jan 23, 2021

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.

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
Copy link
Contributor

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.

Copy link
Contributor Author

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? 🤷

Copy link
Member

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.

@ocelotl ocelotl closed this Jan 27, 2021
This moves the WSGI and ASGI instrumentations and some other
functionality to a new package for HTTP-related functionality.
Copy link
Contributor

@codeboten codeboten left a 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.

@ocelotl
Copy link
Contributor Author

ocelotl commented Feb 2, 2021

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

@ocelotl ocelotl force-pushed the issue_284 branch 14 times, most recently from b246cce to 9e97619 Compare February 4, 2021 06:51
Copy link
Contributor

@codeboten codeboten left a 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!

@codeboten codeboten merged commit 2fd68a2 into open-telemetry:main Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove usage of Configuration
6 participants