Skip to content

Commit

Permalink
Merge pull request #19 from senecajs/improve-plugin
Browse files Browse the repository at this point in the history
Improve plugin
  • Loading branch information
rjrodger authored Jun 30, 2022
2 parents 8ce25e8 + 3b3b2be commit 9306ff7
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 407 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ jobs:
- run: npm install
- run: npm run build --if-present
- run: npm test
env:
NEW_RELIC_HOME: './test'

- name: Coveralls
if: ${{ false }}
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
12 changes: 10 additions & 2 deletions dist/tracing-collector.js

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

2 changes: 1 addition & 1 deletion dist/tracing-collector.js.map

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

33 changes: 17 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"url": "git://github.com/senecajs/seneca-telemetry-newrelic.git"
},
"scripts": {
"test": "jest --coverage",
"test": "jest",
"test-some": "jest -t",
"test-watch": "jest --coverage --watchAll",
"test-watch": "jest --watchAll",
"watch": "tsc -w -d",
"build": "tsc -d",
"doc": "seneca-doc",
Expand All @@ -35,25 +35,26 @@
"LICENSE"
],
"devDependencies": {
"@seneca/doc": "^4.0.1",
"@seneca/provider": "^0.2.0",
"@types/jest": "^27.0.3",
"@seneca/doc": "4.0.1",
"@seneca/provider": "0.2.0",
"@types/jest": "27.0.3",
"@types/newrelic": "7.0.3",
"@types/node": "16.11.36",
"esbuild": "^0.14.3",
"esbuild-jest": "^0.5.0",
"express": "^4.18.1",
"jest": "^27.4.4",
"newrelic": "^8.10.0",
"seneca": ">=3",
"seneca-entity": "^16.0.3",
"seneca-msg-test": "^3.2.0",
"seneca-promisify": ">=2",
"typescript": "^4.5.3"
"esbuild": "0.14.3",
"esbuild-jest": "0.5.0",
"express": "4.18.1",
"jest": "27.4.4",
"seneca": "3",
"seneca-entity": "16.0.3",
"seneca-msg-test": "3.2.0",
"seneca-promisify": "2",
"typescript": "4.5.3"
},
"peerDependencies": {
"seneca": ">=3",
"seneca-promisify": ">=2"
"seneca-promisify": ">=2",
"@newrelic/telemetry-sdk": ">=0.6",
"newrelic": ">=8"
},
"dependencies": {
"@newrelic/telemetry-sdk": "0.6.0",
Expand Down
2 changes: 1 addition & 1 deletion src/newrelic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,4 @@ export default newrelic

if ('undefined' !== typeof (module)) {
module.exports = newrelic
}
}
19 changes: 16 additions & 3 deletions src/tracing-collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class TracingCollector {
this.spanClient = new SpanClient({
apiKey,
});

this.seneca = seneca;
}

Expand Down Expand Up @@ -63,8 +64,8 @@ export class TracingCollector {
await this.sendTracing(spec);
spec.dispatched = true;
this._clearQueue();
} catch (error) {
this.seneca.log.error(error);
} catch (error: any) {
this.seneca.log.error(error.message || error.stack);
}
}
} else {
Expand All @@ -87,6 +88,7 @@ export class TracingCollector {
sendTracing(spec: TelemetrySpecMetadata): Promise<string|void|boolean> {
return new Promise((resolve, reject) => {
const spanBatch = new SpanBatch();

const span = new Span(
spec.mi_id,
spec.tx_id,
Expand All @@ -101,14 +103,25 @@ export class TracingCollector {
fullMessage: spec.fullMessage!,
}
);

spanBatch.addSpan(span);
this.spanClient.send(spanBatch, (error: any, res: any, body: any) => {

this.spanClient.send(spanBatch, (error: any, res: any, _body: any) => {
if (error) {
reject(error);
return;
}

if (!res) {
const error = new Error('There was no error but response has, nonetheless, come back as null');
reject(error);
return;
}

// TODO: QUESTION: Consider passing the response and body objects via the `resolve` call?
//
resolve(res.statusCode);
return;
})
})
}
Expand Down
59 changes: 0 additions & 59 deletions test/basic.js

This file was deleted.

51 changes: 0 additions & 51 deletions test/express-seneca.js

This file was deleted.

5 changes: 5 additions & 0 deletions test/hello_world.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

describe('testing', () => {
test('is configured ok', () => {
})
})
111 changes: 0 additions & 111 deletions test/http-cli.ts

This file was deleted.

Loading

0 comments on commit 9306ff7

Please sign in to comment.