-
Notifications
You must be signed in to change notification settings - Fork 84
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
Issue: traceable decorator errors crash application code #1306
Comments
@nikkogg thanks for raising! 100% agree that observability shouldn't impact your app execution. Could you confirm a few things with me?
All the API calls in When I run any app I can create with no internet or with incorrect credentials and get a 403, the app runs as expected but warning logs are emitted, as expected. Or perhaps @billpku, @viones1995,@jlcstephens, or @ukyen8, it seems from your reactions that you also are running into this? My apologies if so! Do you have more information? |
@hinthornw Thank you for your quick response. Let me provide details about our setup and solution:
Initial Implementation from langsmith import traceable
@traceable(
project_name=LANGSMITH_PROJECT_NAME,
tags=[ENVIRONMENT_NAME]
)
def search(self, query: str) -> dict: Issue Identified Solution Implementation
from langsmith import Client, traceable
from langsmith.utils import Retry
from functools import wraps
SEARCH_LANGSMITH_CLIENT = Client(
retry_config=Retry(total=1),
)
def safe_traceable(project_name, tags, client):
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
try:
# Test LangSmith connectivity
info = client.request_with_retries("GET", "/info", stop_after_attempt=1)
logger.info(f"[SearchAgentInvoker] Langsmith info: {info}")
return traceable(project_name=project_name, tags=tags, client=client)(func)(
*args, **kwargs
)
except Exception as e:
logger.warning(
f"Langsmith tracing failed, continuing without tracing. Error: {str(e)}",
exc_info=True,
)
# Fallback to original function
return func(*args, **kwargs)
return wrapper
return decorator
@safe_traceable(
project_name=LANGSMITH_PROJECT_NAME,
tags=[ENVIRONMENT_NAME],
client=SEARCH_LANGSMITH_CLIENT
)
def search(self, query: str) -> dict: Feel free to share any suggestions to help us ensure our LangSmith logging implementation is robust and efficient, with minimal impact on service performance and latency, thanks |
@billpku what service is timing out in your case? I wouldn't recommend the proposed wrapper, since that adds an unchached, blocking IO request in the main thread. Tracing already occurs in a background thread, meaning that while it will finish up ingestion before the program exits, it shouldn't be adding noticeable latency or errors to your program's execution. I'd also recommend updating your langsmith SDK version since we've made a number of serialization and speed improvements in the intermediating releases. |
@hinthornw Thank you for your feedback. Let me clarify our specific issue: Connection Timeout IssueWe encountered blocking behavior when the LangSmith API URL is unreachable. Here's how we reproduced the issue using a mock API URL:
Our Findings
We plan to upgrade to |
We've made progress after updating our dependencies:
After testing two scenarios:
Results: The Highly recommend upgrading to |
Thank you for your patience! |
Issue you'd like to raise.
During the recent outage, we have noticed a rather weird behaviour:
we are using
traceable
decorator in our Python code, like so:and during recent outage we have noticed, that error raised in the decorator, crashes the application code. I believe this should not be the case, as tracing should not impact availability of our services.
In our case error raised was
403 Forbidden
returned by LangSmith API.Thank you
Suggestion:
I think although important tracing is not imperative to the functionality of the application and error raised in tracing decorator should not take out the entire/service/endpoint/feature. Maybe a warning log, or a notification through email/langsmith UI would be a better option than crashing?
The text was updated successfully, but these errors were encountered: