Skip to content

starlette: add missing configuration params from ASGI Middleware#4566

Open
Fiery-Fenix wants to merge 4 commits into
open-telemetry:mainfrom
Fiery-Fenix:feat/strarlette_exclude_spans
Open

starlette: add missing configuration params from ASGI Middleware#4566
Fiery-Fenix wants to merge 4 commits into
open-telemetry:mainfrom
Fiery-Fenix:feat/strarlette_exclude_spans

Conversation

@Fiery-Fenix
Copy link
Copy Markdown

@Fiery-Fenix Fiery-Fenix commented May 11, 2026

Description

Unlike FastAPI instrumentation, Starlette manual instrumentation is missing several configuration parameters available in underlying ASGI OpenTelemetryMiddleware.
This PR is adding passthrough of the following OpenTelemetryMiddleware parameters to the Starlette instrument_app function:

  • excluded_urls
  • http_capture_headers_server_request
  • http_capture_headers_server_response
  • http_capture_headers_sanitize_fields
  • exclude_spans

Changes in this PR are mostly port of respective functionality from FastAPI inbstrumentation.
Additional tests were added to high-level coverage of the new configuration parameters.

Partially fixing #3725, at least for manual instrumentation

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Tests has passed for all supported platforms:

for p in "10" "11" "12" "13" "14"; do for v in "oldest" "latest"; do tox -e "py3${p}-test-instrumentation-starlette-${v}"; done; done

Does This PR Require a Core Repo Change?

  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@Fiery-Fenix Fiery-Fenix requested a review from a team as a code owner May 11, 2026 12:44
@emdneto
Copy link
Copy Markdown
Member

emdneto commented May 12, 2026

Thanks for the PR!

Just a heads-up: we no longer update CHANGELOG.md directly. The changelog is now generated from changelog fragments using Towncrier.

Please add the appropriate changelog fragment for this change instead of editing CHANGELOG.md manually. You can find the instructions and expected format in CONTRIBUTING.md.

@Fiery-Fenix Fiery-Fenix force-pushed the feat/strarlette_exclude_spans branch from 47090ed to d9081d4 Compare May 13, 2026 11:38
@Fiery-Fenix Fiery-Fenix force-pushed the feat/strarlette_exclude_spans branch from d9081d4 to 6a36ed4 Compare May 13, 2026 11:41
@Fiery-Fenix
Copy link
Copy Markdown
Author

Thanks for the PR!

Just a heads-up: we no longer update CHANGELOG.md directly. The changelog is now generated from changelog fragments using Towncrier.

Please add the appropriate changelog fragment for this change instead of editing CHANGELOG.md manually. You can find the instructions and expected format in CONTRIBUTING.md.

Thanks for note! I have updated PR with correct changelog fragment

Copy link
Copy Markdown
Contributor

@tammy-baylis-swi tammy-baylis-swi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lgtm!

The typecheck failure is coming from genAI instrumentation, not this code. Continuing to use schema url for 1.11.0 makes sense as Starlette instrumentation hasn't yet migrated to new semconv. I appreciate the tests.

@github-project-automation github-project-automation Bot moved this to Approved PRs in Python PR digest May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Approved PRs

Development

Successfully merging this pull request may close these issues.

3 participants