-
Notifications
You must be signed in to change notification settings - Fork 609
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
Struggling to get Django Logging and Tracing working #572
Comments
https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/logging/logging.html logging.basicConfig() can be called to set a global logging level and format. Only the first ever call has any effect on the global logger. Any subsequent calls have no effect and do not override a previously configured global logger If your code or some other library/framework you are using calls logging.basicConfig before this integration is enabled, then this integration’s logging format will not be used and log statements will not contain tracing context. For this reason, you’ll need to make sure this integration is enabled as early as possible in the service lifecycle or your framework is configured to use a logging format with placeholders for tracing context. I believe somewhere in your application basicConfig called before opentelemetry instrumentation. |
@lonewolf3739 thanks, this is the part in which I'm struggling - I can't find the bit in Django that calls I'll keep looking for answers, as long as I know I'm on the right track! |
If I were you I would modify my python source in my virtualenv and raise exception in |
Good idea, thanks, I'll give that a go |
This issue was marked stale due to lack of activity. It will be closed in 30 days. |
Hi all, I'm trying to log Open Telemetry log data data from Django to Loki so I can get the traceid's required to look up stuff in Tempo and I'm struggling to get the logging library working
At the moment, my logging conf dict looks like this:
And my manage.py looks like this:
I'm pretty sure I've got my env vars setup correctly too:
Logging to Loki or the console without the Open telemetry fields works fine via the python loki logger, but as soon as I add in the Open Telemetry fields it dies claiming that they don't exist:
Obviously this is because the logged isn't being initialised properly (if at all?), but I can't for the life of me work out where I should be putting the call to
logging.basicConfig()
as that appears to be exactly what the config-dict is for!Have I missed a vitally important part of the OTEL docs somewhere?
The text was updated successfully, but these errors were encountered: