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

[Quart] [ASGI] Cardinality of traces increases on the basis of path parameters

Open
#2,131 0 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

Problem:
While instrumenting Quart-based application using OpenTelemetryMiddleware I am not able to group traces based on url consisting of path parameters which increases cardinality on the observability platform. The span name consists of URL endpoints like below

  • GET /reminders/public/check/100
  • GET /reminders/public/check/99

I am using Python 3.9.12

I am using the following versions for instrumentation

  • opentelemetry-distro==0.43b0
  • opentelemetry-exporter-otlp==1.22.0
  • opentelemetry-instrumentation-asgi==0.43b0

Application

  • Quart==0.17.0
from opentelemetry.instrumentation.asgi import OpenTelemetryMiddleware
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter

trace.set_tracer_provider(TracerProvider())
tracer = trace.get_tracer(__name__)
span_processor = BatchSpanProcessor(OTLPSpanExporter())
trace.get_tracer_provider().add_span_processor(span_processor)

app = Quart(__name__)
app.asgi_app = OpenTelemetryMiddleware(app.asgi_app)

Is there any subtle way of achieving this? Since FastAPI does the thing and blocks the path parameter unlike Quart

  • GET /reminders/public/check/{item_id}

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 OpenTelemetryMiddleware entry point used to wrap Quart's app.asgi_app and reproduce the two example requests with different path parameter values. Compare the resulting span names with the route-template form shown for FastAPI; done means equivalent requests are grouped without exposing the parameter value in the span name.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.