dd-trace 4.53.0 → 4.53.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dd-trace",
3
- "version": "4.53.0",
3
+ "version": "4.53.1",
4
4
  "description": "Datadog APM tracing client for JavaScript",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -3,7 +3,7 @@
3
3
  const { channel } = require('dc-polyfill')
4
4
 
5
5
  const Level = {
6
- trace: 20,
6
+ trace: 10,
7
7
  debug: 20,
8
8
  info: 30,
9
9
  warn: 40,
@@ -12,6 +12,7 @@ const Level = {
12
12
  off: 100
13
13
  }
14
14
 
15
+ const traceChannel = channel('datadog:log:trace')
15
16
  const debugChannel = channel('datadog:log:debug')
16
17
  const infoChannel = channel('datadog:log:info')
17
18
  const warnChannel = channel('datadog:log:warn')
@@ -31,6 +32,9 @@ class LogChannel {
31
32
  }
32
33
 
33
34
  subscribe (logger) {
35
+ if (Level.trace >= this._level) {
36
+ traceChannel.subscribe(logger.trace)
37
+ }
34
38
  if (Level.debug >= this._level) {
35
39
  debugChannel.subscribe(logger.debug)
36
40
  }
@@ -46,6 +50,9 @@ class LogChannel {
46
50
  }
47
51
 
48
52
  unsubscribe (logger) {
53
+ if (traceChannel.hasSubscribers) {
54
+ traceChannel.unsubscribe(logger.trace)
55
+ }
49
56
  if (debugChannel.hasSubscribers) {
50
57
  debugChannel.unsubscribe(logger.debug)
51
58
  }
@@ -63,7 +70,7 @@ class LogChannel {
63
70
 
64
71
  module.exports = {
65
72
  LogChannel,
66
-
73
+ traceChannel,
67
74
  debugChannel,
68
75
  infoChannel,
69
76
  warnChannel,
@@ -2,7 +2,7 @@
2
2
 
3
3
  const coalesce = require('koalas')
4
4
  const { isTrue } = require('../util')
5
- const { debugChannel, infoChannel, warnChannel, errorChannel } = require('./channels')
5
+ const { traceChannel, debugChannel, infoChannel, warnChannel, errorChannel } = require('./channels')
6
6
  const logWriter = require('./writer')
7
7
  const { Log } = require('./log')
8
8
 
@@ -56,6 +56,16 @@ const log = {
56
56
  return this
57
57
  },
58
58
 
59
+ trace (...args) {
60
+ if (traceChannel.hasSubscribers) {
61
+ const logRecord = {}
62
+ Error.captureStackTrace(logRecord, this.trace)
63
+ const stack = logRecord.stack.split('\n')[1].replace(/^\s+at ([^\s]) .+/, '$1')
64
+ traceChannel.publish(Log.parse('Trace', args, { stack }))
65
+ }
66
+ return this
67
+ },
68
+
59
69
  debug (...args) {
60
70
  if (debugChannel.hasSubscribers) {
61
71
  debugChannel.publish(Log.parse(...args))
@@ -4,6 +4,7 @@ const { storage } = require('../../../datadog-core')
4
4
  const { LogChannel } = require('./channels')
5
5
  const { Log } = require('./log')
6
6
  const defaultLogger = {
7
+ trace: msg => console.trace(msg), /* eslint-disable-line no-console */
7
8
  debug: msg => console.debug(msg), /* eslint-disable-line no-console */
8
9
  info: msg => console.info(msg), /* eslint-disable-line no-console */
9
10
  warn: msg => console.warn(msg), /* eslint-disable-line no-console */
@@ -23,7 +24,7 @@ function withNoop (fn) {
23
24
  }
24
25
 
25
26
  function unsubscribeAll () {
26
- logChannel.unsubscribe({ debug: onDebug, info: onInfo, warn: onWarn, error: onError })
27
+ logChannel.unsubscribe({ trace: onTrace, debug: onDebug, info: onInfo, warn: onWarn, error: onError })
27
28
  }
28
29
 
29
30
  function toggleSubscription (enable, level) {
@@ -31,7 +32,7 @@ function toggleSubscription (enable, level) {
31
32
 
32
33
  if (enable) {
33
34
  logChannel = new LogChannel(level)
34
- logChannel.subscribe({ debug: onDebug, info: onInfo, warn: onWarn, error: onError })
35
+ logChannel.subscribe({ trace: onTrace, debug: onDebug, info: onInfo, warn: onWarn, error: onError })
35
36
  }
36
37
  }
37
38
 
@@ -88,6 +89,12 @@ function onDebug (log) {
88
89
  if (cause) withNoop(() => logger.debug(cause))
89
90
  }
90
91
 
92
+ function onTrace (log) {
93
+ const { formatted, cause } = getErrorLog(log)
94
+ if (formatted) withNoop(() => logger.trace(formatted))
95
+ if (cause) withNoop(() => logger.trace(cause))
96
+ }
97
+
91
98
  function error (...args) {
92
99
  onError(Log.parse(...args))
93
100
  }
@@ -110,4 +117,8 @@ function debug (...args) {
110
117
  onDebug(Log.parse(...args))
111
118
  }
112
119
 
113
- module.exports = { use, toggle, reset, error, warn, info, debug }
120
+ function trace (...args) {
121
+ onTrace(Log.parse(...args))
122
+ }
123
+
124
+ module.exports = { use, toggle, reset, error, warn, info, debug, trace }
@@ -1,5 +1,6 @@
1
1
  'use strict'
2
2
 
3
+ const log = require('./log')
3
4
  const RateLimiter = require('./rate_limiter')
4
5
  const Sampler = require('./sampler')
5
6
  const { setSamplingRules } = require('./startup-log')
@@ -44,16 +45,19 @@ class PrioritySampler {
44
45
  this.update({})
45
46
  }
46
47
 
47
- configure (env, { sampleRate, provenance = undefined, rateLimit = 100, rules = [] } = {}) {
48
+ configure (env, opts = {}) {
49
+ const { sampleRate, provenance = undefined, rateLimit = 100, rules = [] } = opts
48
50
  this._env = env
49
51
  this._rules = this._normalizeRules(rules, sampleRate, rateLimit, provenance)
50
52
  this._limiter = new RateLimiter(rateLimit)
51
53
 
54
+ log.trace(env, opts)
52
55
  setSamplingRules(this._rules)
53
56
  }
54
57
 
55
58
  isSampled (span) {
56
59
  const priority = this._getPriorityFromAuto(span)
60
+ log.trace(span)
57
61
  return priority === USER_KEEP || priority === AUTO_KEEP
58
62
  }
59
63
 
@@ -67,6 +71,8 @@ class PrioritySampler {
67
71
  if (context._sampling.priority !== undefined) return
68
72
  if (!root) return // noop span
69
73
 
74
+ log.trace(span, auto)
75
+
70
76
  const tag = this._getPriorityFromTags(context._tags, context)
71
77
 
72
78
  if (this.validate(tag)) {
@@ -94,6 +100,8 @@ class PrioritySampler {
94
100
  samplers[DEFAULT_KEY] = samplers[DEFAULT_KEY] || defaultSampler
95
101
 
96
102
  this._samplers = samplers
103
+
104
+ log.trace(rates)
97
105
  }
98
106
 
99
107
  validate (samplingPriority) {
@@ -117,6 +125,8 @@ class PrioritySampler {
117
125
  context._sampling.mechanism = mechanism
118
126
 
119
127
  const root = context._trace.started[0]
128
+
129
+ log.trace(span, samplingPriority, mechanism)
120
130
  this._addDecisionMaker(root)
121
131
  }
122
132