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

opentelemetry-instrumentation-asyncpg: allow opting out of instrumentation for async cursors #3109

Open
krishnan-chandra opened this issue Dec 13, 2024 · 1 comment

Comments

@krishnan-chandra
Copy link

What problem do you want to solve?

Currently, the AsyncPGInstrumentor instruments these async methods, including CursorIterator.__anext__.

In conjunction with this, it means that a span is fired for every single row that is iterated over from an async cursor. This causes certain traces to become unsustainably large and contain a massive number of spans like the one below:

Screenshot 2024-12-13 at 2 24 58 PM

Describe the solution you'd like

Allow opting out of instrumentation for CursorIterator.__anext__, or implement instrumentation at the network request level so that every fetch to the database triggers a span rather than every single row that is iterated over.

Describe alternatives you've considered

No response

Additional Context

No response

Would you like to implement a fix?

None

@krishnan-chandra krishnan-chandra changed the title opentelemetry-instrumentation-asyncpg: allow opting out of instrumentation for async cursors opentelemetry-instrumentation-asyncpg: allow opting out of instrumentation for async cursors Dec 13, 2024
@alexmojaki
Copy link
Contributor

Long-lived versions of the code links:

for method in [
"Cursor.fetch",
"Cursor.forward",
"Cursor.fetchrow",
"CursorIterator.__anext__",
]:
wrapt.wrap_function_wrapper(
"asyncpg.cursor", method, self._do_cursor_execute
)

"""Wrap cursor based functions. For every call this will generate a new span."""

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

No branches or pull requests

2 participants