Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #100 from michaelgoin/remove-tracer-usage
Browse files Browse the repository at this point in the history
Remove tracer usage
  • Loading branch information
michaelgoin authored Jan 12, 2022
2 parents 12c399d + f04315b commit 0b082db
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 25 deletions.
2 changes: 1 addition & 1 deletion THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ This product includes source derived from [@newrelic/newrelic-oss-cli](https://g

### @newrelic/test-utilities

This product includes source derived from [@newrelic/test-utilities](https://github.com/newrelic/node-test-utilities) ([v5.1.0](https://github.com/newrelic/node-test-utilities/tree/v5.1.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-test-utilities/blob/v5.1.0/LICENSE):
This product includes source derived from [@newrelic/test-utilities](https://github.com/newrelic/node-test-utilities) ([v6.3.0](https://github.com/newrelic/node-test-utilities/tree/v6.3.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-test-utilities/blob/v6.3.0/LICENSE):

```
Apache License
Expand Down
14 changes: 8 additions & 6 deletions lib/instrumentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,20 @@ function wrapCreateContext(shim, fn, fnName, context) {

// match should never be undefined given _matchedRoute was set
if (match) {
const tx = shim.agent.tracer.getTransaction()
const currentSegment = shim.getActiveSegment()

// Transaction may be null, see:
// Segment/Transaction may be null, see:
// - https://github.com/newrelic/node-newrelic-koa/issues/32
// - https://github.com/newrelic/node-newrelic-koa/issues/33
if (tx) {
if (currentSegment) {
const transaction = currentSegment.transaction

if (context.__NR_matchedRoute) {
tx.nameState.popPath()
transaction.nameState.popPath()
}

tx.nameState.appendPath(match.path)
tx.nameState.markPath()
transaction.nameState.appendPath(match.path)
transaction.nameState.markPath()
}
}

Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"third-party-updates": "oss third-party manifest && oss third-party notices && git add THIRD_PARTY_NOTICES.md third_party_manifest.json",
"unit": "tap tests/unit/**/*.tap.js --no-coverage --reporter classic",
"versioned": "npm run versioned:npm7",
"versioned:major": "versioned-tests --major --all -i 2 'tests/versioned/*.tap.js'",
"versioned:npm6": "versioned-tests --minor -i 2 'tests/versioned/*.tap.js'",
"versioned:npm7": "versioned-tests --minor --all -i 2 'tests/versioned/*.tap.js'",
"lint": "eslint *.js lib tests",
Expand All @@ -34,7 +35,7 @@
"@koa/router": "^8.0.0",
"@newrelic/eslint-config": "^0.0.2",
"@newrelic/newrelic-oss-cli": "^0.1.2",
"@newrelic/test-utilities": "^5.1.0",
"@newrelic/test-utilities": "^6.3.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-header": "^3.1.1",
Expand Down
6 changes: 4 additions & 2 deletions tests/versioned/koa.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,12 @@ tap.test('Koa instrumentation', (t) => {
t.test('correctly records actions interspersed among middleware', (t) => {
t.plan(2)

const testShim = helper.getShim()

app.use(function one(ctx, next) {
helper.agent.tracer.createSegment('testSegment')
testShim.createSegment('testSegment')
return next().then(function () {
helper.agent.tracer.createSegment('nestedSegment')
testShim.createSegment('nestedSegment')
})
})
app.use(function two(ctx, next) {
Expand Down
14 changes: 7 additions & 7 deletions third_party_manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"lastUpdated": "Wed Aug 25 2021 11:33:08 GMT-0400 (Eastern Daylight Time)",
"lastUpdated": "Tue Jan 11 2022 15:20:31 GMT-0800 (Pacific Standard Time)",
"projectName": "New Relic Koa Instrumentation",
"projectUrl": "https://github.com/newrelic/node-newrelic-koa",
"includeDev": true,
"includeOptDeps": false,
"includeDev": true,
"dependencies": {},
"devDependencies": {
"@koa/[email protected]": {
Expand Down Expand Up @@ -44,15 +44,15 @@
"licenseTextSource": "file",
"publisher": "New Relic"
},
"@newrelic/test-utilities@5.1.0": {
"@newrelic/test-utilities@6.3.0": {
"name": "@newrelic/test-utilities",
"version": "5.1.0",
"range": "^5.1.0",
"version": "6.3.0",
"range": "^6.3.0",
"licenses": "Apache-2.0",
"repoUrl": "https://github.com/newrelic/node-test-utilities",
"versionedRepoUrl": "https://github.com/newrelic/node-test-utilities/tree/v5.1.0",
"versionedRepoUrl": "https://github.com/newrelic/node-test-utilities/tree/v6.3.0",
"licenseFile": "node_modules/@newrelic/test-utilities/LICENSE",
"licenseUrl": "https://github.com/newrelic/node-test-utilities/blob/v5.1.0/LICENSE",
"licenseUrl": "https://github.com/newrelic/node-test-utilities/blob/v6.3.0/LICENSE",
"licenseTextSource": "file",
"publisher": "New Relic Node.js agent team",
"email": "[email protected]"
Expand Down

0 comments on commit 0b082db

Please sign in to comment.