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

feat(aiohttp): add instrumentation of client requests #1761

Merged
merged 6 commits into from
Jun 28, 2023

Conversation

md384
Copy link
Contributor

@md384 md384 commented Nov 28, 2022

Adds instrumentation of client requests for aiohttp. See https://docs.aiohttp.org/en/stable/client_advanced.html#client-tracing for aiohttp documentation on tracing hooks for client requests.

This change could arguably go in a separate AioHttpClientIntegration but will leave that for discussion.

@acnebs
Copy link

acnebs commented Dec 11, 2022

Just wanted to comment and say it would be cool to get this merged, as we are using aiohttp entirely for making client requests in our app and not at all for the webserver side of it (we use FastAPI/Starlette for that).

@github-actions
Copy link

github-actions bot commented Jan 2, 2023

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@md384
Copy link
Contributor Author

md384 commented Jan 2, 2023

I would still like to see this PR merged. I think it has value for the community.

@sl0thentr0py sl0thentr0py added Status: Backlog Enhancement New feature or request labels Jan 3, 2023
@md384 md384 force-pushed the m.aiohttp-client-instrumentation branch 2 times, most recently from 27d1187 to 109be3a Compare February 28, 2023 17:04
@ccastleberry
Copy link

I'd like to bump this again because I'd love to see this merged.

@antonpirker
Copy link
Member

Hey @ccastleberry !

Thanks for bumping. We have now one more full time engineer that will spend time with the Python SDK, so we should get faster in the next couple of weeks (hopefully)

@sentrivana sentrivana self-assigned this Jun 22, 2023
@sentrivana
Copy link
Contributor

Hey @md384, thanks for this PR. I wanted to merge master into it to bring it up to the current SDK changes and run the tests, but it seems like the PR doesn't allow edits by others. Could you enable them or update the PR directly?

I'll take a look and test this locally today.

Copy link
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

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

Looks great! Couple of small things need changing (most of them have to do with changes that happened after this PR was opened -- sorry for the long wait!). @md384 please let us know if you have time to look at this. Alternatively you can set the PR branch to allow edits from us and then we can take it from here.

No worries if you don't have time to do either, we can also proceed by merging this and then making the changes on top.

Thanks again!

sentry_sdk/integrations/aiohttp.py Outdated Show resolved Hide resolved
sentry_sdk/integrations/aiohttp.py Outdated Show resolved Hide resolved
sentry_sdk/integrations/aiohttp.py Outdated Show resolved Hide resolved
sentry_sdk/integrations/aiohttp.py Outdated Show resolved Hide resolved
sentry_sdk/integrations/aiohttp.py Outdated Show resolved Hide resolved
sentry_sdk/integrations/aiohttp.py Outdated Show resolved Hide resolved
sentry_sdk/integrations/aiohttp.py Outdated Show resolved Hide resolved
@md384
Copy link
Contributor Author

md384 commented Jun 22, 2023

@sentrivana I can make these changes and will get them back to you soon

@md384 md384 force-pushed the m.aiohttp-client-instrumentation branch from 3a6198f to e1622b4 Compare June 22, 2023 21:31
@md384 md384 requested a review from sentrivana June 22, 2023 21:32
@md384
Copy link
Contributor Author

md384 commented Jun 22, 2023

@sentrivana some of the existing tests are failing for aiohttp for me. I think this is because we now use the aiohttp client for testing the aiohttp server integration where we try and set the sentry-trace header directly but my changes now create a span (and therefore a trace-id) for the client requests, resulting in a trace-id mismatch. I'll try and fix these up.

EDIT: I've added an extra commit to pull out the trace id that was added to the request automatically by the client instrumentation so we can compare to the trace-id on the server generated spans in the unit tests.

@sentrivana
Copy link
Contributor

@md384 Thanks a lot for the super fast fixes! The code looks good to me, I'll give it a spin next week and see if we need anything additional (like docs) and then we can merge this.

Copy link
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

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

Found two minor things.

sentry_sdk/integrations/aiohttp.py Outdated Show resolved Hide resolved
sentry_sdk/integrations/aiohttp.py Outdated Show resolved Hide resolved
@sentrivana sentrivana enabled auto-merge (squash) June 28, 2023 10:42
@sentrivana
Copy link
Contributor

sentrivana commented Jun 28, 2023

Thanks for your patience @md384. I've enabled automerge so this now only needs to be rebased on master or having master merged into it to apply cleanly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants