-
Notifications
You must be signed in to change notification settings - Fork 408
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
fix(langchain): type check chain.invoke() input argument name #8835
Conversation
f9b9d6a
to
6f8d9c7
Compare
Datadog ReportBranch report: ✅ 0 Failed, 272 Passed, 133 Skipped, 0s Wall Time |
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.
lgtm, one nonblocking question
6f8d9c7
to
37b90ae
Compare
BenchmarksBenchmark execution time: 2024-04-02 22:13:13 Comparing candidate commit 37b90ae in PR branch Found 7 performance improvements and 4 performance regressions! Performance is the same for 190 metrics, 9 unstable metrics. scenario:flasksimple-appsec-telemetry
scenario:flasksimple-tracer
scenario:httppropagationextract-datadog_tracecontext_tracestate_not_propagated_on_trace_id_no_match
scenario:httppropagationextract-invalid_span_id_header
scenario:httppropagationextract-medium_valid_headers_all
scenario:httppropagationextract-valid_headers_all
scenario:httppropagationextract-wsgi_invalid_trace_id_header
scenario:sethttpmeta-all-disabled
scenario:sethttpmeta-obfuscation-send-querystring-disabled
scenario:sethttpmeta-useragentvariant_exists_2
scenario:sethttpmeta-useragentvariant_exists_3
|
This PR fixes the langchain integration's patched chain method to check for the correct input argument name. In `LangChain<0.1`, we patch `langchain.Chain.__call__()`, which uses `inputs: Union[Dict[str, Any], str]` as the argument to the chain invocation. However in `LangChain>=0.1`, we patch `langchain.Chain.invoke()`, which uses `input: Dict[str, Any]` as the argument to the chain invocation. We use the same traced function to patch both methods, but this subtle change broke our argument parsing, which expected the name `inputs` instead of `input`. ## Checklist - [x] Change(s) are motivated and described in the PR description - [x] Testing strategy is described if automated tests are not included in the PR - [x] Risks are described (performance impact, potential for breakage, maintainability) - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed or label `changelog/no-changelog` is set - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)) - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) - [x] If this PR changes the public interface, I've notified `@DataDog/apm-tees`. - [x] If change touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from `@DataDog/security-design-and-guidance`. ## Reviewer Checklist - [x] Title is accurate - [x] All changes are related to the pull request's stated goal - [x] Description motivates each change - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - [x] Testing strategy adequately addresses listed risks - [x] Change is maintainable (easy to change, telemetry, documentation) - [X] Release note makes sense to a user of the library - [x] Author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - [x] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
… 2.8] (#8987) Backport #8835 to 2.8. This PR fixes the langchain integration's patched chain method to check for the correct input argument name. In `LangChain<0.1`, we patch `langchain.Chain.__call__()`, which uses `inputs: Union[Dict[str, Any], str]` as the argument to the chain invocation. However in `LangChain>=0.1`, we patch `langchain.Chain.invoke()`, which uses `input: Dict[str, Any]` as the argument to the chain invocation. We use the same traced function to patch both methods, but this subtle change broke our argument parsing, which expected the name `inputs` instead of `input`. ## Checklist - [x] Change(s) are motivated and described in the PR description - [x] Testing strategy is described if automated tests are not included in the PR - [x] Risks are described (performance impact, potential for breakage, maintainability) - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed or label `changelog/no-changelog` is set - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)) - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) - [x] If this PR changes the public interface, I've notified `@DataDog/apm-tees`. - [x] If change touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from `@DataDog/security-design-and-guidance`. ## Reviewer Checklist - [x] Title is accurate - [x] All changes are related to the pull request's stated goal - [x] Description motivates each change - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - [x] Testing strategy adequately addresses listed risks - [x] Change is maintainable (easy to change, telemetry, documentation) - [X] Release note makes sense to a user of the library - [x] Author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - [x] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
This PR fixes the langchain integration's patched chain method to check for the correct input argument name.
In
LangChain<0.1
, we patchlangchain.Chain.__call__()
, which usesinputs: Union[Dict[str, Any], str]
as the argument to the chain invocation. However inLangChain>=0.1
, we patchlangchain.Chain.invoke()
, which usesinput: Dict[str, Any]
as the argument to the chain invocation. We use the same traced function to patch both methods, but this subtle change broke our argument parsing, which expected the nameinputs
instead ofinput
.Checklist
changelog/no-changelog
is set@DataDog/apm-tees
.@DataDog/security-design-and-guidance
.Reviewer Checklist