Skip to content

Commit ead8c25

Browse files
authoredFeb 22, 2024··
refactor: Updated instrumentation to construct specs at source instead of within the shim methods (#2035)
* Simplified the logic in `shim.recordQuery` and `shim.recordOperation` to reduce merging of spec properties and rely on the constructed spec
1 parent 695d10e commit ead8c25

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+623
-425
lines changed
 

‎THIRD_PARTY_NOTICES.md

+20-7
Original file line numberDiff line numberDiff line change
@@ -1266,18 +1266,31 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12661266

12671267
### https-proxy-agent
12681268

1269-
This product includes source derived from [https-proxy-agent](https://github.com/TooTallNate/proxy-agents) ([v7.0.2](https://github.com/TooTallNate/proxy-agents/tree/v7.0.2)), distributed under the [MIT License](https://github.com/TooTallNate/proxy-agents/blob/v7.0.2/README.md):
1269+
This product includes source derived from [https-proxy-agent](https://github.com/TooTallNate/proxy-agents) ([v7.0.3](https://github.com/TooTallNate/proxy-agents/tree/v7.0.3)), distributed under the [MIT License](https://github.com/TooTallNate/proxy-agents/blob/v7.0.3/LICENSE):
12701270

12711271
```
1272-
MIT License
1272+
(The MIT License)
12731273
1274-
Copyright (c) <year> <copyright holders>
1274+
Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
12751275
1276-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1276+
Permission is hereby granted, free of charge, to any person obtaining
1277+
a copy of this software and associated documentation files (the
1278+
'Software'), to deal in the Software without restriction, including
1279+
without limitation the rights to use, copy, modify, merge, publish,
1280+
distribute, sublicense, and/or sell copies of the Software, and to
1281+
permit persons to whom the Software is furnished to do so, subject to
1282+
the following conditions:
12771283
1278-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
1284+
The above copyright notice and this permission notice shall be
1285+
included in all copies or substantial portions of the Software.
12791286
1280-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1287+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
1288+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1289+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1290+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
1291+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
1292+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1293+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12811294
```
12821295

12831296
### import-in-the-middle
@@ -2933,7 +2946,7 @@ SOFTWARE.
29332946

29342947
### lockfile-lint
29352948

2936-
This product includes source derived from [lockfile-lint](https://github.com/lirantal/lockfile-lint) ([v4.12.1](https://github.com/lirantal/lockfile-lint/tree/v4.12.1)), distributed under the [Apache-2.0 License](https://github.com/lirantal/lockfile-lint/blob/v4.12.1/LICENSE):
2949+
This product includes source derived from [lockfile-lint](https://github.com/lirantal/lockfile-lint) ([v4.13.1](https://github.com/lirantal/lockfile-lint/tree/v4.13.1)), distributed under the [Apache-2.0 License](https://github.com/lirantal/lockfile-lint/blob/v4.13.1/LICENSE):
29372950

29382951
```
29392952

‎lib/instrumentation/@elastic/elasticsearch.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*/
55

66
'use strict'
7+
8+
const { QuerySpec } = require('../../shim/specs')
79
const semver = require('semver')
810
const logger = require('../../logger').child({ component: 'ElasticSearch' })
911
const { isNotEmpty } = require('../../util/objects')
@@ -33,14 +35,14 @@ module.exports = function initialize(_agent, elastic, _moduleName, shim) {
3335

3436
shim.recordQuery(elastic.Transport.prototype, 'request', function wrapQuery(shim, _, __, args) {
3537
const ctx = this
36-
return {
38+
return new QuerySpec({
3739
query: JSON.stringify(args?.[0]),
3840
promise: true,
3941
opaque: true,
4042
inContext: function inContext() {
4143
getConnection.call(ctx, shim)
4244
}
43-
}
45+
})
4446
})
4547
}
4648

0 commit comments

Comments
 (0)
Please sign in to comment.