-
Notifications
You must be signed in to change notification settings - Fork 225
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
feat(elasticsearch): support @elastic/elasticsearch client #1877
Conversation
This commit is very incomplete, based on earlier work in: #1266
…oid false positives
This is ready to review now. There are a few "TODO" comments in there:
that I don't think all need to be done now. @delvedor You are welcome to review and/or play with this, but I don't expect you to. |
review note: the linting "error" will go away when these commits are squashed |
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.
I took an initial pass at this -- it looks like a solid start and captures the functionality of the previous instrumentation and @delvedor's first pass at this well. The use of the WeakMap
is a nice call-out as well -- Trust your Mechanic Garbage Collector :)
It doesn't look like sub-classing is the common approach for instrumentation in the agent -- normally we'd identify the request method, wrap it, start our business, call the original method, and then clean up our business.
I think the sub-classing/event approach can work though -- and in some ways seems less intrusive than the direct monkey-patching we normally do. There's a few additional defensive measures we'll want to take, but otherwise I'm down with this approach.
Improve the `pathIsAQuery` handling to determine if DB context is set: - add "_async_search" endpoints - clarify the regex: match a full URL path segment & no point in optionally matching "/template" suffix on "_search" Also some review feedback for fwd compat: - guard on CLient constructor function signature change - gracefully handle `.Client` being renamed
My understanding is this was intentional. The 'request' and 'response' events described at https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/observability.html were, at least in part, intended for this kind of thing. |
Remaining TODOs before merging:
Related TODOs that can be done separate from this PR (IMHO):
|
…e of the existing module instrumentations
I am moving the TODO item |
…e err.data' which can deopt
…visCI) that resulted in this test failing at least once
Recently on a run of the test suite on TravisCI it was observed that these tests failed a number of times. The tests are inherently relying on winning a race: that the setTimeout inside the elasticsearch client's code is created and fires (even with a short 1ms timeout) before the elasticsearch query completes. Clearly we can lose this race in test runs and sometimes frequently on over burdened test infra. It isn't worth having these flaky tests when we already have other tests for the error handling path.
jenkins run the module tests for elasticsearch,@elastic/elasticsearch |
jenkins run the module tests for elasticsearch,@elastic/elasticsearch |
jenkins run the module tests for elasticsearch,@elastic/elasticsearch |
jenkins run the module tests for ALL |
Since the last time y'all reviewed:
This is ready for re-review when you have the time. Thanks. |
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.
Looks good from here -- previous feedback's been address and it gets us instrumentation for the modern @elastic/elasticsearch
client. One dealer's choice comment on some additional test coverage, but I think we're good to go as it. Approving.
Based on earlier work in:
#1266
Fixes #968