Repository navigation
Description
How do you use Sentry?
Sentry Saas (sentry.io)
Version
1.28.1
Steps to Reproduce
I made an example program to show this error:
from hashlib import sha256
import requests
import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration
from sentry_sdk.integrations.pure_eval import PureEvalIntegration
from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration
def download() -> tuple[str, str]:
"""Download the timetable JS file."""
response = requests.get("https://projekti.gimvic.org/urnik/data.js")
response.raise_for_status()
content = response.content
return content.decode("utf8"), sha256(content).hexdigest()
def main():
sentry_sdk.init(
dsn="DSN",
max_breadcrumbs=100,
traces_sample_rate=1,
profiles_sample_rate=1,
integrations=[
FlaskIntegration(transaction_style="url"),
SqlalchemyIntegration(),
PureEvalIntegration(),
],
environment="production",
release="0.0.0",
)
with sentry_sdk.start_transaction(name="test") as transaction:
# Download the document
content, sha = download()
# Do some other processing
with transaction.start_child(op="work") as child:
child.set_tag("hash", sha)
print(sha)
main()The code in production is different and more complicated as it's integrated into a larger project. However, the same problem still happens.
Interestingly, it does not happen with all URLs, but it happens consistently with this URL (and a few others).
Expected Result
Sentry should auto-instrument all requests code and assign http.client span.
Actual Result
Sentry instruments only a part of requests.get as http.client. The rest of the HTTP request handling does not have a span assigned, which can make Sentry show "Missing span instrumentation", even though the profiler shows that the code is related to the HTTP request and comes from the requests library.
Screenshots of traces and running my example program:
Links to a few traces/profiles running my example program:
- https://filips.sentry.io/performance/test-python:2d0e3643d5a14da1b3a5b90ef92716fa/
- https://filips.sentry.io/performance/test-python:8917dd11244a41f6ae33e3cf5d214a29/
- https://filips.sentry.io/performance/test-python:cf115d65bf7743b8868970d605664375/
Link to a few traces/profiles showing the problem in production:
- https://gimvicurnik.sentry.io/profiling/profile/gimvicurnik-backend/1265c4653871452ab7ab5e304d142e7c/flamechart/
- https://gimvicurnik.sentry.io/profiling/profile/gimvicurnik-backend/297ab1144461415c82ec8757021c68ca/flamechart/
- https://gimvicurnik.sentry.io/profiling/profile/gimvicurnik-backend/547c159ad49e47ee8d28df51945d80dc/flamechart/
- https://gimvicurnik.sentry.io/profiling/profile/gimvicurnik-backend/c8114becf41f4aeb9cebff179929ac03/flamechart/
Metadata
Metadata
Assignees
Projects
- StatusShow more project fieldsWaiting for: Product Owner


Activity
sentrivana commentedon Jul 28, 2023
Hey @filips123, thanks a ton for the super detailed bug report, this will make it much easier for us to debug! We're a bit swamped at the moment but will take a look when time permits.
antonpirker commentedon Oct 2, 2023
Looks like reading a big chunked response using
response.contentis not instrumented and this is the thing that causes the "missing instrumentation" (maybe, I just looked at it very briefly)szokeasaurusrex commentedon Jun 3, 2024
We should not add a requests integration; rather, we should improve our support for instrumenting streaming responses
sentrivana commentedon Apr 22, 2026
Hey all. We're currently working on streaming spans, rather than sending them all at once -- I wonder if that would also solve this issue. I'll also need to recheck whether it's still an issue after all this time. I'll investigate when I get a moment and update.
sentrivana commentedon Apr 23, 2026
Since the link from the original repro doesn't work anymore, here's a workaround to repro:
server.pywithRun the file ^
Change the URL in the repro example above to
"http://127.0.0.1:8000"and run it.sentrivana commentedon Apr 23, 2026
So the problem is that we're closing the span too early. The
Missing instrumentationpart should be part of the client span. This is most visible when dealing with longer chunked responses -- reading the body is not included.Working on a way to improve this.
fix(stdlib): Instrument response body read for chunked HTTP responses (…
fix(stdlib): Instrument response body read for chunked HTTP responses (…
fix(stdlib): Instrument response body read for chunked HTTP responses (…