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

Starlette midlleware trim body #1666

Closed
kvspb opened this issue Oct 13, 2022 · 3 comments
Closed

Starlette midlleware trim body #1666

kvspb opened this issue Oct 13, 2022 · 3 comments
Labels
agent-python community Issues opened by the community triage Issues awaiting triage

Comments

@kvspb
Copy link

kvspb commented Oct 13, 2022

Trimmed by utils.encoding.long_field(data)

  • Agent version: 6.12.0
@github-actions github-actions bot added agent-python community Issues opened by the community triage Issues awaiting triage labels Oct 13, 2022
@kvspb
Copy link
Author

kvspb commented Oct 13, 2022

CAPTURE_BODY = all

How to reproduce

import asyncio

import aiohttp.client
import uvicorn
from elasticapm.contrib.starlette import make_apm_client, ElasticAPM
from elasticapm.version import VERSION
import elasticapm
from fastapi import FastAPI, Request
from starlette.responses import PlainTextResponse
from starlette.routing import Route

print(VERSION)


async def homepage(request: Request):
    return PlainTextResponse("%d" % len(await request.body()))


async def rq():
    await asyncio.sleep(2)
    async with aiohttp.ClientSession() as session:
        async with session.post("http://127.0.0.1:8000/", data="1" * 50_000) as resp:
            assert await resp.text() == '50000'

async def test_request():
    asyncio.create_task(rq())


apm = make_apm_client({
"SERVICE_NAME": "ISSUE",
'CAPTURE_BODY': 'all',
})

app = FastAPI(routes=[Route("/", homepage, methods=["post"])], on_startup=[test_request])
app.add_middleware(ElasticAPM, client=apm)
uvicorn.run(app)
6.12.0
INFO:     Started server process [47566]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     127.0.0.1:49950 - "POST / HTTP/1.1" 200 OK
Task exception was never retrieved
future: <Task finished name='Task-3' coro=<rq() done, defined at issue.py:19> exception=AssertionError()>
Traceback (most recent call last):
  File "issue.py", line 23, in rq
    assert await resp.text() == '50000'
AssertionError

@basepi
Copy link
Contributor

basepi commented Oct 13, 2022

I think this has been fixed in #1635

Can you test with the main branch?

@beniwohli
Copy link
Contributor

Closing as we received no further feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-python community Issues opened by the community triage Issues awaiting triage
Projects
None yet
Development

No branches or pull requests

3 participants