-
Notifications
You must be signed in to change notification settings - Fork 94
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
Add optional crash dumping on ConnectionError #1077
Changes from 10 commits
c0f3745
e6cbc10
ea9682b
1e12160
1830cf0
69f02cc
4903f7a
9e39b7a
47a16dc
e5d1415
d946180
f3d6aa2
b6fd11b
5c6888b
9dd556c
e41f3a1
feb769c
5af0b29
e6be326
61772b9
8bfe9a5
6743172
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"""Client for interacting with the LangSmith API. | ||
Check notice on line 1 in python/langsmith/client.py GitHub Actions / benchmarkBenchmark results
Check notice on line 1 in python/langsmith/client.py GitHub Actions / benchmarkComparison against main
|
||
|
||
Use the client to customize API keys / workspace ocnnections, SSl certs, | ||
etc. for tracing. | ||
|
@@ -731,7 +731,11 @@ | |
|
||
return self._settings | ||
|
||
def _content_above_size(self, content_length: Optional[int]) -> Optional[str]: | ||
def _content_above_size( | ||
self, | ||
content_length: Optional[int], | ||
request: Optional[requests.Request | requests.PreparedRequest], | ||
) -> Optional[str]: | ||
if content_length is None or self._info is None: | ||
return None | ||
info = cast(ls_schemas.LangSmithInfo, self._info) | ||
|
@@ -742,6 +746,14 @@ | |
if size_limit is None: | ||
return None | ||
if content_length > size_limit: | ||
should_debug_crash_dump = os.getenv("LANGSMITH_DEBUG_CRASH_DUMP") in [ | ||
"1", | ||
"true", | ||
] | ||
if should_debug_crash_dump and request is not None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't belong in a function that checks content length - it should go outside as the next step. Also I think we would benefit from seeing other things in the dump even if the payload size doesn't surpass (since these are also of interest) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think we should always dump? Had intended this to only dump if we exceeded the content length limit (and also potentially dump here if other errors occur) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only on error, but this is intended for debugging connection errors, correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes it's a connection error but specifically the one triggered by the content length limit.
Their input and output tokens and traces seem to be pretty small, so we wanted to see what else was in their payload which was causing them to exceed 20mb. We can also log more generically on ConnectionError though if you think that's better! It does make sense to log for other types of connection errors too |
||
with open("content_size_limit_crash_dump.jsonl", "a") as f: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to specify |
||
json.dump(request, f) | ||
f.write("\n") | ||
return ( | ||
f"The content length of {content_length} bytes exceeds the " | ||
f"maximum size limit of {size_limit} bytes." | ||
|
@@ -918,7 +930,7 @@ | |
if e.request | ||
else "" | ||
) | ||
size_rec = self._content_above_size(content_length) | ||
size_rec = self._content_above_size(content_length, e.request) | ||
if size_rec: | ||
recommendation = size_rec | ||
except ValueError: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use
get_env_var
in utils to cache thisThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wdyt of having the value be a file path?
LANGSMITH_DEBUG_CRASH_DUMP=my_file.jsonl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I like that!