-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable breadcrumbs and context-scoped calls for node
- Loading branch information
Dan Skinner
committed
Feb 17, 2023
1 parent
a72509f
commit 000c454
Showing
13 changed files
with
165 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
Feature: contextualize plugin | ||
|
||
Background: | ||
Given I store the api key in the environment variable "BUGSNAG_API_KEY" | ||
And I store the notify endpoint in the environment variable "BUGSNAG_NOTIFY_ENDPOINT" | ||
And I store the sessions endpoint in the environment variable "BUGSNAG_SESSIONS_ENDPOINT" | ||
|
||
Scenario: using contextualize to add context to an error | ||
And I run the service "contextualize" with the command "node scenarios/contextualize" | ||
And I wait to receive 2 errors | ||
|
||
Then the error is valid for the error reporting API version "4" for the "Bugsnag Node" notifier | ||
And the event "unhandled" is false | ||
And the event "severity" equals "warning" | ||
And the event "severityReason.type" equals "handledException" | ||
And the exception "errorClass" equals "Error" | ||
And the exception "message" equals "manual notify" | ||
And the exception "type" equals "nodejs" | ||
And the "file" of stack frame 0 equals "scenarios/contextualize.js" | ||
And the "lineNumber" of stack frame 0 equals 15 | ||
And the event "metaData.subsystem.name" equals "manual notify" | ||
And the event has a "manual" breadcrumb named "manual notify" | ||
|
||
And I discard the oldest error | ||
|
||
Then the error is valid for the error reporting API version "4" for the "Bugsnag Node" notifier | ||
And the event "unhandled" is true | ||
And the event "severity" equals "error" | ||
And the event "severityReason.type" equals "unhandledException" | ||
And the exception "errorClass" equals "Error" | ||
And the exception "message" equals "ENOENT: no such file or directory, open 'does not exist'" | ||
And the exception "type" equals "nodejs" | ||
And the "file" of stack frame 0 equals "scenarios/contextualize.js" | ||
And the "lineNumber" of stack frame 0 equals 20 | ||
And the event "metaData.subsystem.name" equals "fs reader" | ||
And the event has a "manual" breadcrumb named "opening file" | ||
And the event does not have a "manual" breadcrumb with message "manual notify" | ||
|
||
@skip_before_node_16 | ||
Scenario: using contextualize with an unhandled rejection (with context added) | ||
And I run the service "contextualize" with the command "node scenarios/contextualize-unhandled-rejection" | ||
And I wait to receive an error | ||
Then the error is valid for the error reporting API version "4" for the "Bugsnag Node" notifier | ||
And the event "unhandled" is true | ||
And the event "severity" equals "error" | ||
And the event "severityReason.type" equals "unhandledPromiseRejection" | ||
And the exception "errorClass" equals "Error" | ||
And the exception "message" equals "unhandled rejection" | ||
And the exception "type" equals "nodejs" | ||
And the "file" of stack frame 0 equals "scenarios/contextualize-unhandled-rejection.js" | ||
And the "lineNumber" of stack frame 0 equals 12 | ||
And the event "metaData.subsystem.name" equals "fs reader" | ||
And the event "metaData.subsystem.widgetsAdded" equals "cat,dog,mouse" | ||
|
||
Scenario: using contextualize with an unhandled rejection (no context added) | ||
And I run the service "contextualize" with the command "node scenarios/contextualize-unhandled-rejection" | ||
And I wait to receive an error | ||
Then the error is valid for the error reporting API version "4" for the "Bugsnag Node" notifier | ||
And the event "unhandled" is true | ||
And the event "severity" equals "error" | ||
And the event "severityReason.type" equals "unhandledPromiseRejection" | ||
And the exception "errorClass" equals "Error" | ||
And the exception "message" equals "unhandled rejection" | ||
And the exception "type" equals "nodejs" | ||
And the "file" of stack frame 0 equals "scenarios/contextualize-unhandled-rejection.js" | ||
And the "lineNumber" of stack frame 0 equals 12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
ARG NODE_VERSION=8 | ||
FROM node:$NODE_VERSION-alpine | ||
|
||
WORKDIR /app | ||
|
||
COPY package* ./ | ||
RUN npm install | ||
|
||
COPY . ./ | ||
|
||
RUN npm install --no-package-lock --no-save bugsnag-node*.tgz |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "bugsnag-test" | ||
} |
File renamed without changes.
27 changes: 27 additions & 0 deletions
27
test/node/features/fixtures/contextualize/scenarios/contextualize.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
var fs = require('fs') | ||
var Bugsnag = require('@bugsnag/node') | ||
Bugsnag.start({ | ||
apiKey: process.env.BUGSNAG_API_KEY, | ||
endpoints: { | ||
notify: process.env.BUGSNAG_NOTIFY_ENDPOINT, | ||
sessions: process.env.BUGSNAG_SESSIONS_ENDPOINT | ||
} | ||
}) | ||
|
||
var contextualize = Bugsnag.getPlugin('contextualize') | ||
|
||
contextualize(function () { | ||
Bugsnag.leaveBreadcrumb('manual notify', { message: 'manual notify' }) | ||
Bugsnag.notify(new Error('manual notify')) | ||
}, function (event) { | ||
event.addMetadata('subsystem', { name: 'manual notify' }) | ||
}) | ||
|
||
contextualize(function () { | ||
Bugsnag.leaveBreadcrumb('opening file', { message: 'opening file' }) | ||
setTimeout(function () { | ||
fs.createReadStream('does not exist') | ||
}, 100) | ||
}, function (event) { | ||
event.addMetadata('subsystem', { name: 'fs reader' }) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
test/node/features/fixtures/unhandled/scenarios/contextualize.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters