Skip to content

starlette: Remove maximum version constraint#3456

Merged
xrmx merged 19 commits intoopen-telemetry:mainfrom
MattiasDC:issue/3317
May 23, 2025
Merged

starlette: Remove maximum version constraint#3456
xrmx merged 19 commits intoopen-telemetry:mainfrom
MattiasDC:issue/3317

Conversation

@MattiasDC
Copy link
Copy Markdown
Contributor

@MattiasDC MattiasDC commented Apr 29, 2025

Description

Remove maximum version constraint on starlette, by fixing unit tests. Fixed some warnings in unit tests.

Problem was that the environment was patched only during the setUp execution, and not during the tests themselves. By putting the patch decorator on the class itself, the environment variables are patched during the test class, as is done in another place in the same file.

This PR also includes some small changes to reduce the amount of warnings encountered in the unit tests.

  • Get rid of deprecated calls to the route and route_websocket decorators
  • As StarletteInstrumentor._uninstrument can clear all instrumented apps, use a discard i.s.o. remove in the deletor of _InstrumentedStarlette to prevent a KeyError being raised

Fixes #3317

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

All existing unit tests pass with the newest version of starlette (0.46.2)

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • 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

… unit tests. Fixed some warnings in unit tests.
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Apr 29, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@MattiasDC MattiasDC requested a review from a team as a code owner April 29, 2025 20:06
@MattiasDC
Copy link
Copy Markdown
Contributor Author

@Kludex you mentioned you were interested in doing a review for #3317. If this is a bad time, would it be possible for you appoint someone else?

@MattiasDC
Copy link
Copy Markdown
Contributor Author

@aabmass could you review as well and are you able to upgrade the requirements? I'm not comfortable enough to update the lockfiles.

…trap/test-requirements. Use setUp/tearDown iso decorator on test class
@Kludex
Copy link
Copy Markdown
Member

Kludex commented May 2, 2025

We should test the min version.

@MattiasDC
Copy link
Copy Markdown
Contributor Author

MattiasDC commented May 2, 2025

We should test the min version.

Hi @Kludex thanks for joining,

Do you mean something else than this test:
'instrumentation-starlette-oldest 3.8 Ubuntu', which uses

Or am I missing something?

@MattiasDC
Copy link
Copy Markdown
Contributor Author

@Kludex those oldest tests were indeed failing. I've increased the minimal version to 0.37.2. This one is a year old and didn't cause any problems with me. Is this acceptable? Older versions were causing this issue for me Kludex/starlette#2770

@MattiasDC MattiasDC changed the title ISSUE-3317: Remove maximum version constraint on starlette, by fixing unit tests ISSUE-3317: Remove maximum version constraint, increase minimum version on starlette by fixing unit tests May 2, 2025
@MattiasDC
Copy link
Copy Markdown
Contributor Author

PR is ready to be reviewed again @emdneto, if anything needs a change, feel free to put me to work again ;)

Comment thread CHANGELOG.md Outdated
@xrmx xrmx moved this to Reviewed PR that needs fixing in Python PR digest May 5, 2025
@xrmx
Copy link
Copy Markdown
Contributor

xrmx commented May 5, 2025

@Kludex those oldest tests were indeed failing. I've increased the minimal version to 0.37.2. This one is a year old and didn't cause any problems with me. Is this acceptable? Older versions were causing this issue for me encode/starlette#2770

That maybe be fixed by using an older httpx in the requirements.

@MattiasDC
Copy link
Copy Markdown
Contributor Author

MattiasDC commented May 6, 2025

@Kludex those oldest tests were indeed failing. I've increased the minimal version to 0.37.2. This one is a year old and didn't cause any problems with me. Is this acceptable? Older versions were causing this issue for me encode/starlette#2770

That maybe be fixed by using an older httpx in the requirements.

Conditional dependencies are not supported in requirements.in files. Do you propose to add a .in file for latest and one for oldest?

@emdneto emdneto changed the title ISSUE-3317: Remove maximum version constraint, increase minimum version on starlette by fixing unit tests starlette: Remove maximum version constraint May 22, 2025
Comment thread CHANGELOG.md Outdated
Comment thread uv.lock
emdneto and others added 2 commits May 22, 2025 12:26
Signed-off-by: emdneto <[email protected]>
Co-authored-by: Riccardo Magliocchetti <[email protected]>
Comment thread CHANGELOG.md Outdated
Copy link
Copy Markdown
Contributor

@xrmx xrmx left a comment

Choose a reason for hiding this comment

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

With the changelog fixed

@xrmx xrmx requested a review from emdneto May 23, 2025 12:20
@xrmx xrmx enabled auto-merge (squash) May 23, 2025 12:21
@xrmx xrmx merged commit e2ba6d4 into open-telemetry:main May 23, 2025
720 checks passed
@github-project-automation github-project-automation Bot moved this from Reviewed PR that needs fixing to Done in Python PR digest May 23, 2025
@Kludex
Copy link
Copy Markdown
Member

Kludex commented May 23, 2025

I know this is not the right place, so please don't ask me to create an issue... But can't we somehow modify the starlette instrumentation to work with FastAPI and just have one instead of 2? It's a subclass anyway, and it seems it covers the same points.

Happy to talk or hack this at PyCon IT (cc @xrmx)

@xrmx
Copy link
Copy Markdown
Contributor

xrmx commented May 23, 2025

I know this is not the right place, so please don't ask me to create an issue... But can't we somehow modify the starlette instrumentation to work with FastAPI and just have one instead of 2? It's a subclass anyway, and it seems it covers the same points.

Happy to talk or hack this at PyCon IT (cc @xrmx)

Sure, we can discuss it at PyCon IT.

mxiamxia pushed a commit to aws-observability/aws-otel-python-instrumentation that referenced this pull request Oct 30, 2025
…58b0 (#524)

This PR updates the upstream OpenTelemetry Python dependency to its
September 2025 release; Upgrading from version 1.33.1/0.54b1 to
1.37.0/0.58b0.

It also resolves several conflicts between the following OTel PRs and
existing ADOT patches:

starlette: Remove maximum version constraint  

open-telemetry/opentelemetry-python-contrib#3456

Make a BatchProcessor class which both BatchSpanRecordProcessor and
BatchLogRecordProcessor can use
open-telemetry/opentelemetry-python#4562

Make exporter timeout encompass retries/backoffs, add jitter to
backoffs, cleanup code a bit
open-telemetry/opentelemetry-python#4564

Update BatchSpanProcessor to use new BatchProcessor class 
open-telemetry/opentelemetry-python#4580

Fix issue where deadlock can occur over logging._lock 
open-telemetry/opentelemetry-python#4636

Tests Performed

tox -e lint
tox -e spellcheck
tox -e 3.9-test-aws-opentelemetry-distro
tox -e 3.10-test-aws-opentelemetry-distro
tox -e 3.11-test-aws-opentelemetry-distro
tox -e 3.12-test-aws-opentelemetry-distro
tox -e 3.13-test-aws-opentelemetry-distro

Smoke/contract tests: ./gradlew
appsignals-tests:contract-tests:contractTests

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
liustve added a commit to aws-observability/aws-otel-python-instrumentation that referenced this pull request Feb 4, 2026
Automated update of OpenTelemetry dependencies.

**Build Status:** ❌
[failure](https://github.com/aws-observability/aws-otel-python-instrumentation/actions/runs/21465140126)

**Updated versions:**
- [OpenTelemetry
Python](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.39.1):
1.39.1
- [OpenTelemetry
Contrib](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.60b1):
0.60b1
-
[opentelemetry-sdk-extension-aws](https://pypi.org/project/opentelemetry-sdk-extension-aws/2.1.0/):
2.1.0
-
[opentelemetry-propagator-aws-xray](https://pypi.org/project/opentelemetry-propagator-aws-xray/1.0.2/):
1.0.2

**Upstream releases with breaking changes:**
Note: the mechanism to detect upstream breaking changes is not perfect.
Be sure to check all new releases and understand if any additional
changes need to be addressed.

**opentelemetry-python:**
- [Version
1.35.0/0.56b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.35.0)

**opentelemetry-python-contrib:**
- [Version
1.34.0/0.55b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.55b0)

*Description of changes:*

- Un-reverts changes done in this PR:
#531

- Removed patches for Bedrock following the changes applied in these
PRs:
open-telemetry/opentelemetry-python-contrib#3544,
open-telemetry/opentelemetry-python-contrib#3548,
open-telemetry/opentelemetry-python-contrib#3875,
open-telemetry/opentelemetry-python-contrib#3990

- Removes patches for Secrets Manager, SNS, and Step Functions following
the changes applied in these PRs:
open-telemetry/opentelemetry-python-contrib#3734,
open-telemetry/opentelemetry-python-contrib#3737,
open-telemetry/opentelemetry-python-contrib#3765,

- Removes patches for Starlette following the changes applied in this
PR:
open-telemetry/opentelemetry-python-contrib#3456

- Changes imports and implementation of `OTLPAwsLogExporter`,
`AwsCloudWatchOtlpBatchLogRecordProcessor`, and
`CompactConsoleLogExporter` following these PRs:
open-telemetry/opentelemetry-python#4580,
open-telemetry/opentelemetry-python#4535,
open-telemetry/opentelemetry-python#4562,
open-telemetry/opentelemetry-python#4647,
open-telemetry/opentelemetry-python#4676

- Removes a few AWS semantic conventions from `_aws_attribute_keys ` and
replaces them with equivalent ones from upstream following the changes
in this PR:
open-telemetry/opentelemetry-python#4791

- Fix Lambda instrumentation test to set `AWS_LAMBDA_FUNCTION_NAME` env
var following changes in:
open-telemetry/opentelemetry-python-contrib#3183

- Adds a few more contract tests to verify upstream's botocore
instrumentation library


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.

---------

Co-authored-by: github-actions <[email protected]>
Co-authored-by: Thomas Pierce <[email protected]>
Co-authored-by: Steve Liu <[email protected]>
sightseeker added a commit to sightseeker/opentelemetry-python-contrib that referenced this pull request Mar 11, 2026
* ISSUE-3317: Remove maximum version constraint on starlette, by fixing unit tests. Fixed some warnings in unit tests.

* Updae changelog

* Implement code review remarks: update starlette dependencies in bootstrap/test-requirements. Use setUp/tearDown iso decorator on test class

* Increase minimal version of starlette to 0.37.2 to have functional 'oldest' tests.

* add uv.lock

* Revert "add uv.lock"

This reverts commit 08df2be.

* Prevent massive changes of uv.lock due to newer uv which adds upload-time keyword

* Update test-requirements.in file of starlette instrumentation

* fixes

Signed-off-by: emdneto <[email protected]>

* fix tests

Signed-off-by: emdneto <[email protected]>

* increase delta

Signed-off-by: emdneto <[email protected]>

* using same delta as fastapi

Signed-off-by: emdneto <[email protected]>

* commit uv.lock back

Signed-off-by: emdneto <[email protected]>

* Update CHANGELOG.md

Co-authored-by: Riccardo Magliocchetti <[email protected]>

* Update CHANGELOG.md

---------

Signed-off-by: emdneto <[email protected]>
Co-authored-by: emdneto <[email protected]>
Co-authored-by: Riccardo Magliocchetti <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Starlette instrumentation tests fail recent versions starlette >= 0.15.0

4 participants