-
Notifications
You must be signed in to change notification settings - Fork 624
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
Integrating sql commenter into otel_django_instrumentation #896
Integrating sql commenter into otel_django_instrumentation #896
Conversation
Q: Any reason to not add this in psycopg2/mysql/dbapi instrumentations so all frameworks/libraries can benefit instead of only Django? SQL client instrumentations look like a better place to me to host this feature. |
Thanks @owais for taking a look. It would be great to understand your views on which approach is preferable ?
cc: @lonewolf3739, @aabmass |
I would vote for incrementally addition.
We can't directly import code as is from commenter because there will be conflicting wrappers (ex: |
Incremental would definitely be better, easier to review and faster merge. |
👍 👍 👍 |
Agree, for sqlAlchemy, we have to update the existing instrumentation controlled by a flag. But as many of the instrumentations rely on Thanks, then we can start with commenting the So, we have to tag along with the existing opentelementry-django middleware and update it to comment queries with |
We already have instrumentations for the popular DB backends (Sqlite, Postgres, MariaDB etc..) supported by Django. The query middleware might double comment and doesn't enrich comment significantly. As suggested by Owais let's start with sql client instrumentations. Let's make a simplest plan that covers the 90% real world use cases and then improve on top of it, what do you think? |
@lonewolf3739 I agree to that. I believe we already have the tracecontext information in otel sql client libraries. So, it should be just appending these tracecontext values into sql comment. |
…hon-contrib into sqlcommenter-django-integration-solution-a
…hon-contrib into sqlcommenter-django-integration-solution-a
- Added Changelog
…github.com/Thiyagu55/opentelemetry-python-contrib into sqlcommenter-django-integration-solution-a
...tation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py
Outdated
Show resolved
Hide resolved
...tation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py
Outdated
Show resolved
Hide resolved
...tation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py
Outdated
Show resolved
Hide resolved
...tation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py
Outdated
Show resolved
Hide resolved
...tation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py
Outdated
Show resolved
Hide resolved
...tation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py
Outdated
Show resolved
Hide resolved
...tation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py
Outdated
Show resolved
Hide resolved
...tation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py
Outdated
Show resolved
Hide resolved
...tation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py
Outdated
Show resolved
Hide resolved
...tation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py
Outdated
Show resolved
Hide resolved
...tation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py
Outdated
Show resolved
Hide resolved
...tation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py
Outdated
Show resolved
Hide resolved
...tation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py
Outdated
Show resolved
Hide resolved
...tation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py
Outdated
Show resolved
Hide resolved
...tation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py
Outdated
Show resolved
Hide resolved
...tation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py
Outdated
Show resolved
Hide resolved
...tation-django/src/opentelemetry/instrumentation/django/middleware/sqlcommenter_middleware.py
Outdated
Show resolved
Hide resolved
instrumentation/opentelemetry-instrumentation-django/tests/test_sqlcommenter.py
Outdated
Show resolved
Hide resolved
…github.com/Thiyagu55/opentelemetry-python-contrib into sqlcommenter-django-integration-solution-a
…github.com/Thiyagu55/opentelemetry-python-contrib into sqlcommenter-django-integration-solution-a
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.
LGTM, some minor comments around word choices.
...on/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py
Outdated
Show resolved
Hide resolved
...on/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py
Outdated
Show resolved
Hide resolved
...on/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py
Outdated
Show resolved
Hide resolved
...on/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py
Outdated
Show resolved
Hide resolved
...on/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py
Outdated
Show resolved
Hide resolved
@Thiyagu55 |
Yes I can cc: @sjs994 |
Description
This PR describes one possible way to integrate
[sqlcommenter-django](https://open-telemetry.github.io/opentelemetry-sqlcommenter/)
library intoopentelemetry-django
One of the ways in which we can implement this is adding the SQLCommenter middleware into django instrumentation when a flag
enable_sqlcommenter=True
is added. This is similar to how other middlewares are added in opentelemetry-djangoWhen this flag is enabled the SQLCommenter middleware is appended to the django’s existing middlewares. See reference
So for each request, SQLCommenter middleware appends additional infos to the postgresql query logs whenever any db call is made from the controller
We can customize the info to be added at the logs using variables defined in settings.py
It is enabled by adding
DjangoInstrumentor().instrument(tracer_provider=provider, is_sql_commentor_enabled=True)
in django’s settings.pyType of change
Please delete options that are not relevant.
How Has This Been Tested?
Unit test cases has been added for sqlcommenter integration
Does This PR Require a Core Repo Change?
Checklist: