open-telemetry / open-telemetry/opentelemetry-python-contrib

Django Intrumentation issues

Open
#715 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
1.1k
Forks
1.1k
Avg merge
4d 15h
Merged PRs (30d)
16

Description

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
# optional:
endpoint="http://localhost:9411/api/v2/spans"
# local_node_ipv4="192.168.0.1",
# local_node_ipv6="2001:db8::c001",
# local_node_port=31313,
# max_tag_value_length=256
# timeout=5 (in seconds)
)

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the instrumentation setup in manage.py, especially DjangoInstrumentor and the ZipkinExporter configuration. Reproduce the reported behavior while checking the expected parent and child spans for HTTP and database operations; done means a single transaction shows its component spans and the export path can be diagnosed.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
backend, observability
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.