@sentry/node integration to wrap bunyan log calls as breadcrumbs
Sentry by defaults has integration for console.log
to make it part of breadcrumbs:
Link: Import name: Sentry.Integrations.Console
How can we make it to work for bunyan logger as well, like:
const koa = require('koa');
const app = new koa();
const bunyan = require('bunyan');
const log = bunyan.createLogger(
name: 'app',
..... other settings go here ....
);
const Sentry = require('@sentry/node');
Sentry.init(
dsn: MY_DSN_HERE,
integrations: integrations =>
// should anything be handled here & how?
return [...integrations];
,
release: 'xxxx-xx-xx'
);
app.on('error', (err) =>
Sentry.captureException(err);
);
// I am trying all to be part of sentry breadcrumbs
// but only console.log('foo'); is working
console.log('foo');
log.info('bar');
log.warn('baz');
log.debug('any');
log.error('many');
throw new Error('help!');
P.S. I have already tried bunyan-sentry-stream but no success with @sentry/node, it just pushes entries instead of treating them as breadcrumbs.
javascript node.js logging sentry bunyan
add a comment |
Sentry by defaults has integration for console.log
to make it part of breadcrumbs:
Link: Import name: Sentry.Integrations.Console
How can we make it to work for bunyan logger as well, like:
const koa = require('koa');
const app = new koa();
const bunyan = require('bunyan');
const log = bunyan.createLogger(
name: 'app',
..... other settings go here ....
);
const Sentry = require('@sentry/node');
Sentry.init(
dsn: MY_DSN_HERE,
integrations: integrations =>
// should anything be handled here & how?
return [...integrations];
,
release: 'xxxx-xx-xx'
);
app.on('error', (err) =>
Sentry.captureException(err);
);
// I am trying all to be part of sentry breadcrumbs
// but only console.log('foo'); is working
console.log('foo');
log.info('bar');
log.warn('baz');
log.debug('any');
log.error('many');
throw new Error('help!');
P.S. I have already tried bunyan-sentry-stream but no success with @sentry/node, it just pushes entries instead of treating them as breadcrumbs.
javascript node.js logging sentry bunyan
add a comment |
Sentry by defaults has integration for console.log
to make it part of breadcrumbs:
Link: Import name: Sentry.Integrations.Console
How can we make it to work for bunyan logger as well, like:
const koa = require('koa');
const app = new koa();
const bunyan = require('bunyan');
const log = bunyan.createLogger(
name: 'app',
..... other settings go here ....
);
const Sentry = require('@sentry/node');
Sentry.init(
dsn: MY_DSN_HERE,
integrations: integrations =>
// should anything be handled here & how?
return [...integrations];
,
release: 'xxxx-xx-xx'
);
app.on('error', (err) =>
Sentry.captureException(err);
);
// I am trying all to be part of sentry breadcrumbs
// but only console.log('foo'); is working
console.log('foo');
log.info('bar');
log.warn('baz');
log.debug('any');
log.error('many');
throw new Error('help!');
P.S. I have already tried bunyan-sentry-stream but no success with @sentry/node, it just pushes entries instead of treating them as breadcrumbs.
javascript node.js logging sentry bunyan
Sentry by defaults has integration for console.log
to make it part of breadcrumbs:
Link: Import name: Sentry.Integrations.Console
How can we make it to work for bunyan logger as well, like:
const koa = require('koa');
const app = new koa();
const bunyan = require('bunyan');
const log = bunyan.createLogger(
name: 'app',
..... other settings go here ....
);
const Sentry = require('@sentry/node');
Sentry.init(
dsn: MY_DSN_HERE,
integrations: integrations =>
// should anything be handled here & how?
return [...integrations];
,
release: 'xxxx-xx-xx'
);
app.on('error', (err) =>
Sentry.captureException(err);
);
// I am trying all to be part of sentry breadcrumbs
// but only console.log('foo'); is working
console.log('foo');
log.info('bar');
log.warn('baz');
log.debug('any');
log.error('many');
throw new Error('help!');
P.S. I have already tried bunyan-sentry-stream but no success with @sentry/node, it just pushes entries instead of treating them as breadcrumbs.
javascript node.js logging sentry bunyan
javascript node.js logging sentry bunyan
asked Nov 15 '18 at 0:01
Zeeshan Hassan MemonZeeshan Hassan Memon
5,02832446
5,02832446
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Bunyan supports custom streams, and those streams are just function calls. See https://github.com/trentm/node-bunyan#streams
Below is an example custom stream that simply writes to the console. It would be straight forward to use this example to instead write to the Sentry module, likely calling Sentry.addBreadcrumb()
or similar function.
Please note though that the variable record
in my example below is a JSON string, so you would likely want to parse it to get the log level, message, and other data out of it for submission to Sentry.
level: 'debug',
stream:
(function ()
return
write: function(record)
console.log('Hello: ' + record);
)()
1
thanks - it worked :)
– Zeeshan Hassan Memon
Nov 15 '18 at 21:39
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53310580%2fsentry-node-integration-to-wrap-bunyan-log-calls-as-breadcrumbs%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Bunyan supports custom streams, and those streams are just function calls. See https://github.com/trentm/node-bunyan#streams
Below is an example custom stream that simply writes to the console. It would be straight forward to use this example to instead write to the Sentry module, likely calling Sentry.addBreadcrumb()
or similar function.
Please note though that the variable record
in my example below is a JSON string, so you would likely want to parse it to get the log level, message, and other data out of it for submission to Sentry.
level: 'debug',
stream:
(function ()
return
write: function(record)
console.log('Hello: ' + record);
)()
1
thanks - it worked :)
– Zeeshan Hassan Memon
Nov 15 '18 at 21:39
add a comment |
Bunyan supports custom streams, and those streams are just function calls. See https://github.com/trentm/node-bunyan#streams
Below is an example custom stream that simply writes to the console. It would be straight forward to use this example to instead write to the Sentry module, likely calling Sentry.addBreadcrumb()
or similar function.
Please note though that the variable record
in my example below is a JSON string, so you would likely want to parse it to get the log level, message, and other data out of it for submission to Sentry.
level: 'debug',
stream:
(function ()
return
write: function(record)
console.log('Hello: ' + record);
)()
1
thanks - it worked :)
– Zeeshan Hassan Memon
Nov 15 '18 at 21:39
add a comment |
Bunyan supports custom streams, and those streams are just function calls. See https://github.com/trentm/node-bunyan#streams
Below is an example custom stream that simply writes to the console. It would be straight forward to use this example to instead write to the Sentry module, likely calling Sentry.addBreadcrumb()
or similar function.
Please note though that the variable record
in my example below is a JSON string, so you would likely want to parse it to get the log level, message, and other data out of it for submission to Sentry.
level: 'debug',
stream:
(function ()
return
write: function(record)
console.log('Hello: ' + record);
)()
Bunyan supports custom streams, and those streams are just function calls. See https://github.com/trentm/node-bunyan#streams
Below is an example custom stream that simply writes to the console. It would be straight forward to use this example to instead write to the Sentry module, likely calling Sentry.addBreadcrumb()
or similar function.
Please note though that the variable record
in my example below is a JSON string, so you would likely want to parse it to get the log level, message, and other data out of it for submission to Sentry.
level: 'debug',
stream:
(function ()
return
write: function(record)
console.log('Hello: ' + record);
)()
answered Nov 15 '18 at 4:26
Nicholas BlasgenNicholas Blasgen
482412
482412
1
thanks - it worked :)
– Zeeshan Hassan Memon
Nov 15 '18 at 21:39
add a comment |
1
thanks - it worked :)
– Zeeshan Hassan Memon
Nov 15 '18 at 21:39
1
1
thanks - it worked :)
– Zeeshan Hassan Memon
Nov 15 '18 at 21:39
thanks - it worked :)
– Zeeshan Hassan Memon
Nov 15 '18 at 21:39
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53310580%2fsentry-node-integration-to-wrap-bunyan-log-calls-as-breadcrumbs%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown