-
Notifications
You must be signed in to change notification settings - Fork 599
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
Include Flask 2.0 as compatible with existing flask instrumentation #545
Include Flask 2.0 as compatible with existing flask instrumentation #545
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any thoughts on how to approach testing the various versions @NathanielRN? It would be great to have a test for each supported versions, at least for major versions.
I see some newly added async support in the changelog for version 2.0. I think we should have some tests around such major changes. |
@codeboten That's a good question. I was thinking about it especially since we got lucky this time that there were no breaking changes. If, for example, Flask 3 breaks
Then in terms of testing, we could:
I favor Option 2, it also has the added side effect that in @lonewolf3739 I tried for several hours today to try to get async tests to work but with little success 😕 I tried looking at some of the other examples of async tests that we have but I can't find an easy way to integrate them with the flask tests that already we have. But, I would say it's okay to skip the tests for now because:
The flask library introduced tests using pytest but I wasn't able to get their examples to work for us. As a last point, I tested this with a very simple app and found that it does work even with an The async stuff can be used to make an endpoint async very easily like this:
Even with async/await I can get traces reliably. Our tests test the basics and I assume that anything that would break the async/await routes would break the sync ones too so it can be said that our tests cover the main case and that's enough for what we care about as OTel. If we're sure we want tests, then I can close this PR and open it again at a later time when I figure out how to test it 😅 |
@codeboten I had a chance to ask OTel Java how they're doing auto instrumentation and they lead me to this example: Which means they go with Option 1 that I mentioned instead. This means tests would be separate and possible duplicated across packages. (Notice how they skipped I think it makes a lot of sense and could fit with OTel Python auto instrumentation nicely. It's just that we would have to deprecate |
This problem is common across instrumentations. I think this deserves a separate discussion on our approach towards addressing this. This will also need effort in terms of tooling, maintaining, and release, etc. |
@lonewolf3739 Sure I would love to add what I've discovered to any discussion. In the meantime for this PR it looks like we already follow this pattern of allowing multiple versions be supported by one package? Line 44 in 63e7561
We can bring this up at the SIG to decide whether we want this specific PR or not. |
Description
opentelemetry-instrumentation-flask
usesflask.Flask
to instrument theflask
package. Initially instrumentation worked forflask~=1.0
. About a month ago, Flask 2.0 was released and thankfully our instrumentation still works with it!We need to manually update
package.py
to indicate that our instrumentation still works for auto-instrumentation. Auto-instrumentation will only instrumentation packages and versions which match what we have ininstrumentations/
.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
The packages found by Auto Instrumentation can be found by running
opentelemetry-bootstrap
after installingpip opentelemetry-instrumentation
.Before the change:
If you have
pip install flask~=1.0
then runningopentelemetry-bootstrap
returns at least:If you have
pip install flask ~=2.0
then runningopentelemetry-bootstrap
returns nothing.After the change:
Both
pip install flask~=1.0
andpip install flask~=2.0
will make runningopentelemetry-bootstrap
return at least:Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.
- [ ] Unit tests have been added- [ ] Documentation has been updated