traceloop / traceloop/openllmetry

๐Ÿ› Bug Report: dont_throw has no effect on async functions in VertexAI instrumentation

Open Beginner friendly
#4,414 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.4k
Forks
1.1k
Avg merge
8d 14h
Merged PRs (30d)
2

Description

Which component is this bug for?

VertexAI Instrumentation

๐Ÿ“œ Description

dont_throw in opentelemetry/instrumentation/vertexai/utils.py defines only a synchronous wrapper:

def dont_throw(func):
    logger = logging.getLogger(func.__module__)

    def wrapper(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except Exception as e:
            logger.debug(...)

    return wrapper

Calling an async def returns a coroutine immediately, so the try block exits before the function body runs and the caller awaits the coroutine outside the guard. The decorator has no effect on async functions.

It is applied to async functions in this package: span_utils.set_input_attributes and _handle_request in __init__.py. _handle_request is awaited with no surrounding try, and before the wrapped model call, so an instrumentation error in async prompt capture propagates into the user's application and the LLM call never happens.

The Anthropic, OpenAI and google-generativeai packages all branch on asyncio.iscoroutinefunction and return an async wrapper. VertexAI and Cohere do not.

๐Ÿ‘Ÿ Reproduction steps
from opentelemetry.instrumentation.vertexai.utils import dont_throw
import asyncio

@dont_throw
async def boom():
    raise RuntimeError("instrumentation failed")

asyncio.run(boom())
๐Ÿ‘ Expected behavior

The exception is logged and swallowed, as it is for synchronous functions.

๐Ÿ‘Ž Actual Behavior with Screenshots
RuntimeError: instrumentation failed

The exception reaches the caller. Applied to _handle_request, that means the user's Vertex AI call is never made.

๐Ÿค– Python Version

3.12

๐Ÿ“ƒ Provide any additional context for the Bug.

Cohere has the same gap, but its async streaming entry points are async generators and need a third branch, so it is worth handling separately.

๐Ÿ‘€ Have you spent some time to check if this bug has been raised before?
  • I checked and didn't find similar issue
๐Ÿข Have you read the Contributing Guidelines?
  • I have read the Contributing Guidelines
Are you willing to submit PR?

Yes I am willing to submit a PR!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up โ€” it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in opentelemetry/instrumentation/vertexai/utils.py and inspect the async uses in span_utils.set_input_attributes and _handle_request in init.py. Run the provided async reproduction first, then verify that exceptions from async functions are logged and swallowed while the caller's Vertex AI request still proceeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.