Open itnazeer opened 3 years ago
Did you enable the instrumentation for DB Client and HTTP Client? Please add the list of dependencies and their version numbers of your pip packages.
Yes, I did add instrumentation for the DB client. As django instrumentation providing http traces, I did not add any http client. I will try adding that.
DB instrumentation:
import mysql.connector from opentelemetry.instrumentation.mysql import MySQLInstrumentor
MySQLInstrumentor().instrument()
DB connectivity in settings.py 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'django', 'USER': 'root', 'PASSWORD': 'test_4321', 'HOST': '127.0.0.1', 'PORT': '3306', } }
pip packages:
mysql-connector 2.2.9 mysql-connector-python 8.0.26 mysqlclient 2.0.3 opentelemetry-api 1.5.0 opentelemetry-distro 0.24b0 opentelemetry-exporter-otlp-proto-grpc 1.5.0 opentelemetry-exporter-zipkin-json 1.5.0 opentelemetry-instrumentation 0.24b0 opentelemetry-instrumentation-asgi 0.24b0 opentelemetry-instrumentation-dbapi 0.24b0 opentelemetry-instrumentation-django 0.24b0 opentelemetry-instrumentation-grpc 0.24b0 opentelemetry-instrumentation-logging 0.24b0 opentelemetry-instrumentation-mysql 0.24b0 opentelemetry-instrumentation-requests 0.24b0 opentelemetry-instrumentation-sqlite3 0.24b0 opentelemetry-instrumentation-urllib 0.24b0 opentelemetry-instrumentation-urllib3 0.24b0 opentelemetry-instrumentation-wsgi 0.24b0 opentelemetry-propagator-b3 1.5.0 opentelemetry-proto 1.5.0 opentelemetry-sdk 1.5.0 opentelemetry-semantic-conventions 0.24b0 opentelemetry-util-http 0.24b0
If you could share a simple reproducible app that would be very helpful.
I have created a simple Django project connecting MySQL using this doc. Then, I navigate to the site and create Django admin users and delete so that I can see the sql traces using the url localhost:8000/admin
@itnazeer it is hard to grasp all these snippets and try to figure out what and where the problem is. We would appreciate if you could share your project as a github repo so someone can look at it end ot end or try to run it in order to reproduce the issues. Thanks.
@owais I have just pushed the code to Git hub (https://github.com/itnazeer/mysql_django.git)
It's a basic Django application connecting MySQL database. I will be using Zipkin exporter but commented the code related to that and using console exporter to see the traces if they are as expected.
I am using Django instrumentor and able to push metrics to APM but there are some issues like, Firstly, every operation getting ingested as trace instead of spans and I can only see one span under a trace, Secondly, I can only see traces of http using Django instrumentation library but no db traces.
@itnazeer have you been able to find a solution ? I'm facing the same issue :(
See https://github.com/open-telemetry/opentelemetry-python-contrib/issues/1566#issuecomment-1412549611
My fix for this was to ensure the python mysql connector engine was in use (via the ENGINE
option)
https://dev.mysql.com/doc/connector-python/en/connector-python-django-backend.html
Describe your environment Describe any aspect of your environment relevant to the problem, including your Python version, platform, version numbers of installed dependencies, information about your cloud hosting provider, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main.
Hi Team, am trying to instrument Django python application using opentelemetry and Zipkin exporter, I am able to push metrics to APM but there are some issues like, Firstly, every operation getting ingested as trace instead of spans and I can only see one span under a trace, Secondly, I can only see traces of http using Django instrumentation library but no db traces. Any lead will be appreciated. Thanks!
Steps to reproduce I am using the below code in the manage.py file to instrument.
from opentelemetry.sdk.trace import TracerProvider from opentelemetry.instrumentation.django import DjangoInstrumentor from opentelemetry.sdk.trace.export import ( BatchSpanProcessor, ConsoleSpanExporter, )
trace.set_tracer_provider(TracerProvider(sampler=sampler)) tracer = trace.get_tracer(name)
create a ZipkinExporter
zipkin_exporter = ZipkinExporter(
version=Protocol.V2
)
Create a BatchExportSpanProcessor and add the exporter to it
span_processor = BatchSpanProcessor(zipkin_exporter)
trace.get_tracer_provider().add_span_processor(span_processor)
DjangoInstrumentor().instrument()
What is the expected behavior? I am execting multiple spans in single traces which inlcudes operation of single transaction and traces should of multiple components like db, http but all I see are from otel.library.name opentelemetry.instrumentation.django
What is the actual behavior? I see the traces only from opentelemetry.instrumentation.django and also I see only one span in a trace.
Additional context Also, I would like to know how to debug when the application not able to send traces to APM.