OpenTelemetry Logging with Django #4294
willianantunes
started this conversation in
Show and tell
Replies: 1 comment
-
|
Hi Willian, I'm trying to get it working with Django and facing an issue with the log. I'm using the latest library version, so syntax might have changed. I'd really appreciate it if you could take a look at my discussion thread once - #4792 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Django uses the dictionary
LOGGINGto configure the logging system (check its documentation). Talking about programmatically configuration, OpenTelemetry Logging Instrumentation can be configured in themanage.pyfile andgunicorn_config.pyfile if you are using Gunicorn. If you setLoggingInstrumentor().instrument(tracer_provider=provider, set_logging_format=True)in both files, it won't work properly, because Django will calllogging.config.dictConfig(LOGGING)later, and it will overwrite the configuration set by OpenTelemetry. To solve this issue, you can create a class like the following:Then you can set the
LOGGINGdictionary like this:Notice the custom handler named
otlp. Remember, according to the documentation, the APIs withinopentelemetry.sdk._logsare subject to change. So, it is important to keep an eye on the updates. Libraries I used at the time I posted this comment:Sample project.
Beta Was this translation helpful? Give feedback.
All reactions