census-instrumentation / opencensus-python

A stats collection and distributed tracing framework
Apache License 2.0
669 stars 250 forks source link

Tracing django system-loggers with operation_id #774

Open arkataev opened 5 years ago

arkataev commented 5 years ago

Python 2.7.13 django==1.11.20 opencensus == 0.7.1 opencensus-ext-django == 0.7.0 opencensus-ext-azure == 0.7.0 opencensus-ext-logging == 0.1.0

Seems like at least some django system-loggers (like, django.db.backends) are logged AFTER span, opened in Middleware, was closed. That means no operation_id is set in trace record produced by django logger.

is there any way to produce django system-log traces related to http-request?

p.s config_integration.trace_integrations(['logging']) is set inside settings.py in django-project before any loggers are created.

arkataev commented 5 years ago

I have elaborated, that In order to trace request related db queries the manual call to django.db.connection.queries within django middleware can be made. Result can be set as a current span attribute and send to Azure Monitor. That will work, but relating django.db.backends log to request is still uncertain.