traceloop / traceloop/openllmetry
๐ Bug Report: dont_throw has no effect on async functions in VertexAI instrumentation
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up โ it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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