Skip to content

Commit

Permalink
chore: Attached specs to the Shim.prototype for use in custom instr…
Browse files Browse the repository at this point in the history
…umentation and instrumentation outside of the agent (newrelic#2038)
  • Loading branch information
bizob2828 authored Feb 22, 2024
1 parent 71ffa37 commit 2c97488
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 32 deletions.
27 changes: 7 additions & 20 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1266,31 +1266,18 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

### https-proxy-agent

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):
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):

```
(The MIT License)
MIT License
Copyright (c) 2013 Nathan Rajlich <[email protected]>
Copyright (c) <year> <copyright holders>
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:
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:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.
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.
```

### import-in-the-middle
Expand Down Expand Up @@ -2946,7 +2933,7 @@ SOFTWARE.

### lockfile-lint

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):
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):

```
Expand Down
1 change: 1 addition & 0 deletions lib/shim/shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ Shim.prototype.prefixRouteParameters = prefixRouteParameters
Shim.prototype.interceptPromise = interceptPromise
Shim.prototype.fixArity = arity.fixArity
Shim.prototype.assignId = assignId
Shim.prototype.specs = specs

// Internal methods.
Shim.prototype.getExport = getExport
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
"lint": "eslint ./*.{js,mjs} lib test bin examples",
"lint:fix": "eslint --fix, ./*.{js,mjs} lib test bin examples",
"lint:lockfile": "lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https --validate-integrity",
"public-docs": "jsdoc -c ./jsdoc-conf.json --tutorials examples/shim api.js lib/shim/**/* lib/transaction/handle.js && cp examples/shim/*.png out/",
"public-docs": "jsdoc -c ./jsdoc-conf.json --tutorials examples/shim api.js lib/shim/* lib/shim/specs/params/* lib/transaction/handle.js && cp examples/shim/*.png out/",
"publish-docs": "./bin/publish-docs.sh",
"services": "docker compose up -d --wait",
"smoke": "npm run ssl && time tap test/smoke/**/**/*.tap.js --timeout=180 --no-coverage",
Expand Down
25 changes: 25 additions & 0 deletions test/unit/shim/shim.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3105,4 +3105,29 @@ tap.test('Shim', function (t) {
})
t.end()
})

t.test('shim.specs', (t) => {
const agent = helper.loadMockedAgent()
t.teardown(() => {
helper.unloadAgent(agent)
})

const shim = new Shim(agent, 'test-mod')
t.ok(shim.specs, 'should assign specs to an instance of shim')
t.ok(shim.specs.ClassWrapSpec)
t.ok(shim.specs.MessageSpec)
t.ok(shim.specs.MessageSubscribeSpec)
t.ok(shim.specs.MiddlewareMounterSpec)
t.ok(shim.specs.MiddlewareSpec)
t.ok(shim.specs.OperationSpec)
t.ok(shim.specs.QuerySpec)
t.ok(shim.specs.RecorderSpec)
t.ok(shim.specs.RenderSpec)
t.ok(shim.specs.SegmentSpec)
t.ok(shim.specs.TransactionSpec)
t.ok(shim.specs.WrapSpec)
t.ok(shim.specs.params.DatastoreParameters)
t.ok(shim.specs.params.QueueMessageParameters)
t.end()
})
})
22 changes: 11 additions & 11 deletions third_party_manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"lastUpdated": "Wed Feb 21 2024 15:51:23 GMT-0600 (Central Standard Time)",
"lastUpdated": "Thu Feb 22 2024 13:46:35 GMT-0500 (Eastern Standard Time)",
"projectName": "New Relic Node Agent",
"projectUrl": "https://github.com/newrelic/node-newrelic",
"includeOptDeps": true,
Expand Down Expand Up @@ -159,16 +159,16 @@
"publisher": "Max Ogden",
"email": "[email protected]"
},
"[email protected].3": {
"[email protected].2": {
"name": "https-proxy-agent",
"version": "7.0.3",
"version": "7.0.2",
"range": "^7.0.1",
"licenses": "MIT",
"repoUrl": "https://github.com/TooTallNate/proxy-agents",
"versionedRepoUrl": "https://github.com/TooTallNate/proxy-agents/tree/v7.0.3",
"licenseFile": "node_modules/https-proxy-agent/LICENSE",
"licenseUrl": "https://github.com/TooTallNate/proxy-agents/blob/v7.0.3/LICENSE",
"licenseTextSource": "file",
"versionedRepoUrl": "https://github.com/TooTallNate/proxy-agents/tree/v7.0.2",
"licenseFile": "node_modules/https-proxy-agent/README.md",
"licenseUrl": "https://github.com/TooTallNate/proxy-agents/blob/v7.0.2/README.md",
"licenseTextSource": "spdx",
"publisher": "Nathan Rajlich",
"email": "[email protected]",
"url": "http://n8.io/"
Expand Down Expand Up @@ -570,15 +570,15 @@
"publisher": "Andrey Okonetchnikov",
"email": "[email protected]"
},
"lockfile-lint@4.13.1": {
"lockfile-lint@4.12.1": {
"name": "lockfile-lint",
"version": "4.13.1",
"version": "4.12.1",
"range": "^4.9.6",
"licenses": "Apache-2.0",
"repoUrl": "https://github.com/lirantal/lockfile-lint",
"versionedRepoUrl": "https://github.com/lirantal/lockfile-lint/tree/v4.13.1",
"versionedRepoUrl": "https://github.com/lirantal/lockfile-lint/tree/v4.12.1",
"licenseFile": "node_modules/lockfile-lint/LICENSE",
"licenseUrl": "https://github.com/lirantal/lockfile-lint/blob/v4.13.1/LICENSE",
"licenseUrl": "https://github.com/lirantal/lockfile-lint/blob/v4.12.1/LICENSE",
"licenseTextSource": "file",
"publisher": "Liran Tal",
"email": "[email protected]",
Expand Down

0 comments on commit 2c97488

Please sign in to comment.