census-instrumentation / opencensus-python

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

opencensus-ext-mysql does not seem to be sending data to Azure Monitor #782

Open arkataev opened 5 years ago

arkataev commented 5 years ago
# settings.py 
DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.mysql',
                'NAME': 'test_db',
                'USER': 'root',
                'HOST': 'mysqldb',
                'PASSWORD': 'secret',
                'PORT': '3306'
            },
        }
config_integration.trace_integrations(['mysql'])

tracer = Tracer(exporter=AzureExporter(instrumentation_key='secret'), sampler=ProbabilitySampler(1.0))
with tracer.span('db_span'):
    TestModel.objects.all()

Db call above does not export any data. While if used with config_integration.trace_integrations(['pymysql']) integration - does.

Can anyone, please give any comments on using opencensus-ext-mysql integration with django?

lzchen commented 5 years ago

If you are using Django >= v2.0 in your application, [#775] provides DB instrumentation to allow for trace data to be sent to Azure Monitor, instrumenting with Django Middleware. With this, you do not have to use config_integration.trace_integrations(['pymysql']) with any database that you use with Django.

This change is currently not released yet for opencensus-ext-django. I can do a minor release if this is the path that you would like to try.