-
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(patch): send log to Datadog to enable logs correlation
- Loading branch information
1 parent
0d21a87
commit 233b154
Showing
3 changed files
with
42 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const tracer = require('dd-trace') | ||
const formats = require('dd-trace/ext/formats') | ||
|
||
function log ({ level = 'alert', message }) { | ||
const span = tracer.scope().active() | ||
const time = new Date().toISOString() | ||
const record = { time, level, message } | ||
/* istanbul ignore if */ | ||
if (span) { | ||
tracer.inject(span.context(), formats.LOG, record) | ||
} | ||
console.log(record) | ||
} | ||
|
||
module.exports = { log } |
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