Skip to content
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

Teach fastapi instrumentation about fastapi-slim #2702

Merged
merged 22 commits into from
Jul 23, 2024

Conversation

zhihali
Copy link
Contributor

@zhihali zhihali commented Jul 12, 2024

Description

Fixes #2683

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

test with running the fastapi locally with the updated code

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

@zhihali zhihali requested a review from a team July 12, 2024 11:27
@zhihali zhihali changed the title Add dependency for fastapi-slim [wip]Add dependency for fastapi-slim Jul 12, 2024
@zhihali zhihali changed the title [wip]Add dependency for fastapi-slim Add dependency for fastapi-slim Jul 12, 2024
@zhihali
Copy link
Contributor Author

zhihali commented Jul 13, 2024

@xrmx Thanks for the review, always appreciate your quick reply and guidance!

Copy link
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.

LGTM, I would just add a test requirements file with fastapi-slim installed so we check that we support that

instrumentation/README.md Outdated Show resolved Hide resolved
@zhihali zhihali requested review from xrmx and emdneto July 15, 2024 12:05
tox.ini Show resolved Hide resolved
@xrmx
Copy link
Contributor

xrmx commented Jul 15, 2024 via email

@zhihali zhihali changed the title Add dependency for fastapi-slim [wip]Add dependency for fastapi-slim Jul 15, 2024
@zhihali
Copy link
Contributor Author

zhihali commented Jul 15, 2024

I would not add new tox environment, just add a test requirement for the current fastapi one

Hey @xrmx, I think we should create a new tox environment for this. The issue is that FastAPI-Slim uses the same import statement as FastAPI (import fastapi). This means we can't just add a new test file under the current FastAPI environment and expect it to work correctly with FastAPI-Slim.

To properly test FastAPI-Slim, we need to:

  1. Create a new tox environment.
  2. Update the requirements.txt to include FastAPI-Slim but not FastAPI.
  3. Run the FastAPI instrumentation tests in this new environment.
    We should also add this new environment to our CI pipeline.

@xrmx
Copy link
Contributor

xrmx commented Jul 16, 2024

@zhihali So the issue is that fastapi and fastapi-slim does not conflict with each other and so installing one will not remove the other. Right?

@zhihali
Copy link
Contributor Author

zhihali commented Jul 22, 2024

@zhihali So the issue is that fastapi and fastapi-slim does not conflict with each other and so installing one will not remove the other. Right?

@xrmx
So, the original issue is some user would like to use the fastapi-slim, and use the otel-fastapi-instrumentation, but our instrumentation doesn't support it. I add the support for fastapi-slim. This should solve the issue. In this case, I supporse add a new test env and a CI for fastapi-slim is reasonable.

But for now, I think we solve the OR problem, for AND, this is a bit complex.

Python's import system will typically use the package that was installed last or the one that appears first in the Python path.

So it's defo not recommand to use both fastapi and fastapi-slim(since the import all be import fastapi). I think the current change will support AND, but it's not recommand to use it.

What's your opinion? Any further discussion is welcomed!

@zhihali zhihali changed the title [wip]Add dependency for fastapi-slim Add dependency for fastapi-slim Jul 22, 2024
@xrmx
Copy link
Contributor

xrmx commented Jul 22, 2024

@zhihali So the issue is that fastapi and fastapi-slim does not conflict with each other and so installing one will not remove the other. Right?

@xrmx So, the original issue is some user would like to use the fastapi-slim, and use the otel-fastapi-instrumentation, but our instrumentation doesn't support it. I add the support for fastapi-slim. This should solve the issue. In this case, I supporse add a new test env and a CI for fastapi-slim is reasonable.

But for now, I think we solve the OR problem, for AND, this is a bit complex.

Python's import system will typically use the package that was installed last or the one that appears first in the Python path.

So it's defo not recommand to use both fastapi and fastapi-slim(since the import all be import fastapi). I think the current change will support AND, but it's not recommand to use it.

What's your opinion? Any further discussion is welcomed!

I was talking specifically to the inability to use the same tox environment, sorry for not being more clear. PR is fine for me

tox.ini Show resolved Hide resolved
tox.ini Show resolved Hide resolved
@xrmx xrmx changed the title Add dependency for fastapi-slim Teach fastapi instrumentation about fastapi-slim Jul 22, 2024
zhihali and others added 3 commits July 22, 2024 16:08
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
@zhihali zhihali requested review from emdneto and xrmx July 22, 2024 15:38
CHANGELOG.md Outdated Show resolved Hide resolved
@lzchen lzchen merged commit 38e4ea4 into open-telemetry:main Jul 23, 2024
383 checks passed
@gryevns gryevns mentioned this pull request Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fastapi-slim support
4 participants