Skip to content

Commit 82e5822

Browse files
committed
try dd-trace logging auto-inject
1 parent 77c9307 commit 82e5822

File tree

2 files changed

+2
-17
lines changed

2 files changed

+2
-17
lines changed

bufflog.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import tracer from "dd-trace";
2-
import formats from "dd-trace/ext/formats";
31

42
export class BuffLog {
53
pinoLogger: any;
6-
defaultLevel = String.prototype.toLowerCase.apply(process.env.LOG_LEVEL) || "notice";;
4+
defaultLevel = process.env.LOG_LEVEL ? String.prototype.toLowerCase.apply(process.env.LOG_LEVEL) : "notice";
75

86
constructor() {
97
this.pinoLogger = require('pino')({
@@ -16,19 +14,6 @@ export class BuffLog {
1614
// soon: remove the `v` field https://github.com/pinojs/pino/issues/620
1715
base: {},
1816

19-
mixin () {
20-
// Check here if a current trace exist to inject it in the log
21-
// `tracer` is a singleton, will no-op if no tracer was initialized
22-
var span = tracer.scope().active()
23-
if (span) {
24-
const traceInfo = {}
25-
tracer.inject(span.context(), formats.LOG, traceInfo);
26-
return traceInfo;
27-
} else {
28-
return {}
29-
}
30-
},
31-
3217
// notice doesn't exist in pino, let's add it
3318
customLevels: {
3419
notice: 35

index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import tracer from "dd-trace";
22
import express from 'express';
3-
import bufflog from './bufflog';
3+
import bufflog from './bufflog';
44

55
tracer.init({
66
hostname: "dd-agent-hostname",

0 commit comments

Comments
 (0)