Skip to content

(excluded_urls) 'str' object has no attribute 'url_disabled' in OpenTelemetryMiddleware #3562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
CarlosRCDev opened this issue Jun 5, 2025 · 4 comments · May be fixed by #3567
Open

(excluded_urls) 'str' object has no attribute 'url_disabled' in OpenTelemetryMiddleware #3562

CarlosRCDev opened this issue Jun 5, 2025 · 4 comments · May be fixed by #3567
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@CarlosRCDev
Copy link

Describe your environment

OS: Red Hat Enterprise Linux Server release 7.8
Python version: Python 3.12.1
SDK version: 1.34.0
API version: 1.33.1
opentelemetry.instrumentation.asgi version: 0.54b1

What happened?

If set value "excluded_urls" in OpenTelemetryMiddleware, class fails: 'str' object has no attribute 'url_disabled'.
I'am using Quart, but i think the problem is here:
lib/python3.12/site-packages/opentelemetry/instrumentation/asgi/init.py -> Line 684

if self.excluded_urls and self.excluded_urls.url_disabled(url):
    return await self.app(scope, receive, send)

Steps to Reproduce

OpenTelemetryMiddleware(
        app.asgi_app,
        excluded_urls="ping,v2/api-docs"
    )

Expected Result

no errors and filter by comma-separated text

Actual Result

OpenTelemetryMiddleware, class fails: 'str' object has no attribute 'url_disabled'.

Additional context

No response

Would you like to implement a fix?

None

@CarlosRCDev CarlosRCDev added the bug Something isn't working label Jun 5, 2025
@CarlosRCDev
Copy link
Author

To fix this:
in the file: lib/python3.12/site-packages/opentelemetry/instrumentation/asgi/init.py
add import

from opentelemetry.util.http import parse_excluded_urls

Line 621 add:

if excluded_urls is not None:
    excluded_urls = parse_excluded_urls(excluded_urls)

i found this solution reading the code of:
instrumentation/opentelemetry-instrumentation-fastapi

@xrmx
Copy link
Contributor

xrmx commented Jun 5, 2025

@CarlosRCDev care to open a PR?

@xrmx xrmx added the good first issue Good for newcomers label Jun 5, 2025
@CarlosRCDev
Copy link
Author

Ok, this weekend I open a PR

@CarlosRCDev
Copy link
Author

I create the PR:
I add 2 tests.
#3567

@emdneto emdneto linked a pull request Jun 9, 2025 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants