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

Pyramid instrumentation includes high cardinality URLs in the span name when using Traversal

Open
#1,914 0 comments 1 reaction 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

Pyramid application using Traversal algorithms to handle HTTP routing.

Steps to reproduce
Create an app using Pyramid's Traversal based routing to setup HTTP routes, see the span names being created with high cardinality.

What is the expected behavior?
Span name with name GET.

What is the actual behavior?
Span name with name GET /resouce/9ea43cd7-bd77-494d-8fac-209c0dc7a438

Additional information

While using Pyramid's Traversal algorithm to handle HTTP routing, span names end up with high cardinality.
Looking at the code, the pyramid instrumention defaults to the WSGI span name if no route is found (i.e. Traversal is used), the WSGI behavior is to use the PATH_INFO variable which will contain the full path used for the request.

This results in span names such as GET /resouce/9ea43cd7-bd77-494d-8fac-209c0dc7a438 which are very undesirable.

According to the HTTP semantic conventions, the Instrumentation MUST NOT default to using URI path as span name
.

If desired, I can make a PR to remove the default path behavior of WSGI.

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 in instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py, especially the fallback span-name handling, and compare it with instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/init.py where PATH_INFO is used. The change is done when Pyramid Traversal requests produce a span name of GET rather than including the high-cardinality URL path.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability-sre
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.