dd-trace 5.51.0 → 5.52.0

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.
Files changed (67) hide show
  1. package/LICENSE-3rdparty.csv +0 -6
  2. package/index.d.ts +35 -1
  3. package/package.json +3 -9
  4. package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +391 -0
  5. package/packages/datadog-instrumentations/src/cucumber.js +3 -0
  6. package/packages/datadog-instrumentations/src/dns.js +16 -14
  7. package/packages/datadog-instrumentations/src/fs.js +37 -46
  8. package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
  9. package/packages/datadog-instrumentations/src/jest.js +5 -0
  10. package/packages/datadog-instrumentations/src/mocha/utils.js +5 -0
  11. package/packages/datadog-instrumentations/src/net.js +24 -28
  12. package/packages/datadog-instrumentations/src/pg.js +19 -5
  13. package/packages/datadog-instrumentations/src/playwright.js +6 -0
  14. package/packages/datadog-instrumentations/src/vitest.js +18 -4
  15. package/packages/datadog-plugin-confluentinc-kafka-javascript/src/batch-consumer.js +11 -0
  16. package/packages/datadog-plugin-confluentinc-kafka-javascript/src/consumer.js +11 -0
  17. package/packages/datadog-plugin-confluentinc-kafka-javascript/src/index.js +19 -0
  18. package/packages/datadog-plugin-confluentinc-kafka-javascript/src/producer.js +11 -0
  19. package/packages/datadog-plugin-cucumber/src/index.js +3 -0
  20. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +3 -0
  21. package/packages/datadog-plugin-dns/src/lookup.js +10 -5
  22. package/packages/datadog-plugin-dns/src/lookup_service.js +6 -2
  23. package/packages/datadog-plugin-dns/src/resolve.js +5 -2
  24. package/packages/datadog-plugin-dns/src/reverse.js +6 -2
  25. package/packages/datadog-plugin-fs/src/index.js +9 -2
  26. package/packages/datadog-plugin-jest/src/index.js +3 -0
  27. package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +2 -1
  28. package/packages/datadog-plugin-kafkajs/src/consumer.js +12 -21
  29. package/packages/datadog-plugin-kafkajs/src/producer.js +6 -2
  30. package/packages/datadog-plugin-kafkajs/src/utils.js +27 -0
  31. package/packages/datadog-plugin-langchain/src/index.js +0 -1
  32. package/packages/datadog-plugin-mocha/src/index.js +3 -0
  33. package/packages/datadog-plugin-net/src/ipc.js +6 -4
  34. package/packages/datadog-plugin-net/src/tcp.js +15 -9
  35. package/packages/datadog-plugin-pg/src/index.js +5 -1
  36. package/packages/datadog-plugin-playwright/src/index.js +3 -0
  37. package/packages/datadog-plugin-vitest/src/index.js +15 -3
  38. package/packages/dd-trace/src/appsec/api_security_sampler.js +20 -12
  39. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +14 -9
  40. package/packages/dd-trace/src/appsec/index.js +1 -1
  41. package/packages/dd-trace/src/baggage.js +36 -0
  42. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +4 -2
  43. package/packages/dd-trace/src/config.js +13 -1
  44. package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +2 -0
  45. package/packages/dd-trace/src/debugger/devtools_client/state.js +1 -1
  46. package/packages/dd-trace/src/exporters/common/docker.js +13 -31
  47. package/packages/dd-trace/src/guardrails/telemetry.js +2 -5
  48. package/packages/dd-trace/src/llmobs/writers/base.js +33 -12
  49. package/packages/dd-trace/src/noop/proxy.js +5 -0
  50. package/packages/dd-trace/src/opentelemetry/context_manager.js +2 -0
  51. package/packages/dd-trace/src/opentracing/propagation/text_map.js +17 -9
  52. package/packages/dd-trace/src/plugin_manager.js +2 -0
  53. package/packages/dd-trace/src/plugins/index.js +3 -0
  54. package/packages/dd-trace/src/plugins/log_plugin.js +9 -20
  55. package/packages/dd-trace/src/plugins/outbound.js +11 -3
  56. package/packages/dd-trace/src/plugins/tracing.js +8 -4
  57. package/packages/dd-trace/src/plugins/util/test.js +1 -1
  58. package/packages/dd-trace/src/profiling/exporter_cli.js +1 -1
  59. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookup.js +1 -1
  60. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookupservice.js +1 -1
  61. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_resolve.js +2 -2
  62. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_reverse.js +1 -1
  63. package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +15 -14
  64. package/packages/dd-trace/src/proxy.js +12 -0
  65. package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +8 -0
  66. package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +8 -0
  67. package/packages/dd-trace/src/standalone/product.js +3 -5
@@ -10,43 +10,25 @@ const uuidSource =
10
10
  '[0-9a-f]{8}[-_][0-9a-f]{4}[-_][0-9a-f]{4}[-_][0-9a-f]{4}[-_][0-9a-f]{12}|[0-9a-f]{8}(?:-[0-9a-f]{4}){4}$'
11
11
  const containerSource = '[0-9a-f]{64}'
12
12
  const taskSource = '[0-9a-f]{32}-\\d+'
13
- const lineReg = /^(\d+):([^:]*):(.+)$/
13
+ const lineReg = /^(\d+):([^:]*):(.+)$/m
14
14
  const entityReg = new RegExp(`.*(${uuidSource}|${containerSource}|${taskSource})(?:\\.scope)?$`, 'm')
15
15
 
16
- const cgroup = readControlGroup()
17
- const entityId = getEntityId()
18
- const inode = getInode()
16
+ let inode = 0
17
+ let cgroup = ''
18
+ let entityId
19
19
 
20
- function getEntityId () {
21
- const match = cgroup.match(entityReg) || []
20
+ try {
21
+ cgroup = fs.readFileSync('/proc/self/cgroup', 'utf8').trim()
22
+ entityId = cgroup.match(entityReg)?.[1]
23
+ } catch { /* Ignore error */ }
22
24
 
23
- return match[1]
24
- }
25
-
26
- function getInode () {
27
- const match = cgroup.match(lineReg) || []
28
-
29
- return readInode(match[3])
30
- }
25
+ const inodePath = cgroup.match(lineReg)?.[3]
26
+ if (inodePath) {
27
+ const strippedPath = inodePath.replace(/^\/|\/$/g, '')
31
28
 
32
- function readControlGroup () {
33
29
  try {
34
- return fs.readFileSync('/proc/self/cgroup').toString().trim()
35
- } catch (err) {
36
- return ''
37
- }
38
- }
39
-
40
- function readInode (path) {
41
- if (!path) return 0
42
-
43
- const strippedPath = path.replace(/^\//, '').replace(/\/$/, '')
44
-
45
- try {
46
- return fs.statSync(`/sys/fs/cgroup/${strippedPath}`).ino
47
- } catch (err) {
48
- return 0
49
- }
30
+ inode = fs.statSync(`/sys/fs/cgroup/${strippedPath}`).ino
31
+ } catch { /* Ignore error */ }
50
32
  }
51
33
 
52
34
  module.exports = {
@@ -14,11 +14,8 @@ if (!process.env.DD_INJECTION_ENABLED) {
14
14
  module.exports = function () {}
15
15
  }
16
16
 
17
- if (!process.env.DD_TELEMETRY_FORWARDER_PATH) {
18
- module.exports = function () {}
19
- }
20
-
21
- if (!fs.existsSync(process.env.DD_TELEMETRY_FORWARDER_PATH)) {
17
+ var telemetryForwarderPath = process.env.DD_TELEMETRY_FORWARDER_PATH
18
+ if (typeof telemetryForwarderPath !== 'string' || !fs.existsSync(telemetryForwarderPath)) {
22
19
  module.exports = function () {}
23
20
  }
24
21
 
@@ -41,6 +41,18 @@ class BaseLLMObsWriter {
41
41
  this._destroyed = false
42
42
  }
43
43
 
44
+ get url () {
45
+ if (this._agentless == null) return null
46
+
47
+ const baseUrl = this._baseUrl.href
48
+ const endpoint = this._endpoint
49
+
50
+ // Split on protocol separator to preserve it
51
+ // path.join will remove some slashes unnecessarily
52
+ const [protocol, rest] = baseUrl.split('://')
53
+ return protocol + '://' + path.join(rest, endpoint)
54
+ }
55
+
44
56
  append (event, byteLength) {
45
57
  if (this._buffer.length >= this._bufferLimit) {
46
58
  logger.warn(`${this.constructor.name} event buffer full (limit is ${this._bufferLimit}), dropping event`)
@@ -69,7 +81,7 @@ class BaseLLMObsWriter {
69
81
  const options = this._getOptions()
70
82
 
71
83
  request(payload, options, (err, resp, code) => {
72
- parseResponseAndLog(err, code, events.length, options.url.href, this._eventType)
84
+ parseResponseAndLog(err, code, events.length, this.url, this._eventType)
73
85
  })
74
86
  }
75
87
 
@@ -87,17 +99,23 @@ class BaseLLMObsWriter {
87
99
 
88
100
  setAgentless (agentless) {
89
101
  this._agentless = agentless
90
- this._url = this._getUrl()
91
- logger.debug(`Configuring ${this.constructor.name} to ${this._url.href}`)
102
+ const { url, endpoint } = this._getUrlAndPath()
103
+
104
+ this._baseUrl = url
105
+ this._endpoint = endpoint
106
+
107
+ logger.debug(`Configuring ${this.constructor.name} to ${this.url}`)
92
108
  }
93
109
 
94
- _getUrl () {
110
+ _getUrlAndPath () {
95
111
  if (this._agentless) {
96
- return new URL(format({
97
- protocol: 'https:',
98
- hostname: `${this._intake}.${this._config.site}`,
99
- pathname: this._endpoint
100
- }))
112
+ return {
113
+ url: new URL(format({
114
+ protocol: 'https:',
115
+ hostname: `${this._intake}.${this._config.site}`
116
+ })),
117
+ endpoint: this._endpoint
118
+ }
101
119
  }
102
120
 
103
121
  const { hostname, port } = this._config
@@ -107,8 +125,10 @@ class BaseLLMObsWriter {
107
125
  port
108
126
  }))
109
127
 
110
- const proxyPath = path.join(EVP_PROXY_AGENT_BASE_PATH, this._endpoint)
111
- return new URL(proxyPath, base)
128
+ return {
129
+ url: base,
130
+ endpoint: path.join(EVP_PROXY_AGENT_BASE_PATH, this._endpoint)
131
+ }
112
132
  }
113
133
 
114
134
  _getOptions () {
@@ -118,7 +138,8 @@ class BaseLLMObsWriter {
118
138
  },
119
139
  method: 'POST',
120
140
  timeout: this._timeout,
121
- url: this._url
141
+ url: this._baseUrl,
142
+ path: this._endpoint
122
143
  }
123
144
 
124
145
  if (this._agentless) {
@@ -16,6 +16,11 @@ class NoopProxy {
16
16
  this.appsec = noopAppsec
17
17
  this.dogstatsd = noopDogStatsDClient
18
18
  this.llmobs = noopLLMObs
19
+ this.setBaggageItem = () => {}
20
+ this.getBaggageItem = () => {}
21
+ this.getAllBaggageItems = () => {}
22
+ this.removeBaggageItem = () => {}
23
+ this.removeAllBaggageItems = () => {}
19
24
  }
20
25
 
21
26
  init () {
@@ -12,6 +12,7 @@ class ContextManager {
12
12
  this._store = storage('opentelemetry')
13
13
  }
14
14
 
15
+ // converts dd to otel
15
16
  active () {
16
17
  const activeSpan = tracer.scope().active()
17
18
  const store = this._store.getStore()
@@ -54,6 +55,7 @@ class ContextManager {
54
55
  : wrappedContext
55
56
  }
56
57
 
58
+ // converts otel to dd
57
59
  with (context, fn, thisArg, ...args) {
58
60
  const span = trace.getSpan(context)
59
61
  const ddScope = tracer.scope()
@@ -7,6 +7,7 @@ const log = require('../../log')
7
7
  const TraceState = require('./tracestate')
8
8
  const tags = require('../../../../../ext/tags')
9
9
  const { channel } = require('dc-polyfill')
10
+ const { setBaggageItem, getAllBaggageItems, removeAllBaggageItems } = require('../../baggage')
10
11
 
11
12
  const { AUTO_KEEP, AUTO_REJECT, USER_KEEP } = require('../../../../../ext/priority')
12
13
 
@@ -55,9 +56,10 @@ class TextMapPropagator {
55
56
  }
56
57
 
57
58
  inject (spanContext, carrier) {
58
- if (!spanContext || !carrier) return
59
-
59
+ if (!carrier) return
60
60
  this._injectBaggageItems(spanContext, carrier)
61
+ if (!spanContext) return
62
+
61
63
  this._injectDatadog(spanContext, carrier)
62
64
  this._injectB3MultipleHeaders(spanContext, carrier)
63
65
  this._injectB3SingleHeader(spanContext, carrier)
@@ -125,7 +127,7 @@ class TextMapPropagator {
125
127
 
126
128
  _injectBaggageItems (spanContext, carrier) {
127
129
  if (this._config.legacyBaggageEnabled) {
128
- spanContext._baggageItems && Object.keys(spanContext._baggageItems).forEach(key => {
130
+ spanContext?._baggageItems && Object.keys(spanContext._baggageItems).forEach(key => {
129
131
  carrier[baggagePrefix + key] = String(spanContext._baggageItems[key])
130
132
  })
131
133
  }
@@ -134,7 +136,9 @@ class TextMapPropagator {
134
136
  let itemCounter = 0
135
137
  let byteCounter = 0
136
138
 
137
- for (const [key, value] of Object.entries(spanContext._baggageItems)) {
139
+ const baggageItems = spanContext ? spanContext._baggageItems : getAllBaggageItems()
140
+ if (!baggageItems) return
141
+ for (const [key, value] of Object.entries(baggageItems)) {
138
142
  const item = `${this._encodeOtelBaggageKey(String(key).trim())}=${encodeURIComponent(String(value).trim())},`
139
143
  itemCounter += 1
140
144
  byteCounter += item.length
@@ -627,23 +631,27 @@ class TextMapPropagator {
627
631
  _extractBaggageItems (carrier, spanContext) {
628
632
  if (!this._hasPropagationStyle('extract', 'baggage')) return
629
633
  if (!carrier || !carrier.baggage) return
630
- if (!spanContext) return
634
+ if (!spanContext) removeAllBaggageItems()
631
635
  const baggages = carrier.baggage.split(',')
632
636
  for (const keyValue of baggages) {
633
637
  if (!keyValue.includes('=')) {
634
- spanContext._baggageItems = {}
638
+ if (spanContext) spanContext._baggageItems = {}
635
639
  return
636
640
  }
637
641
  let [key, value] = keyValue.split('=')
638
642
  key = this._decodeOtelBaggageKey(key.trim())
639
643
  value = decodeURIComponent(value.trim())
640
644
  if (!key || !value) {
641
- spanContext._baggageItems = {}
645
+ if (spanContext) spanContext._baggageItems = {}
642
646
  return
643
647
  }
644
648
  // the current code assumes precedence of ot-baggage- (legacy opentracing baggage) over baggage
645
- if (key in spanContext._baggageItems) return
646
- spanContext._baggageItems[key] = value
649
+ if (spanContext) {
650
+ if (key in spanContext._baggageItems) return
651
+ spanContext._baggageItems[key] = value
652
+ } else {
653
+ setBaggageItem(key, value)
654
+ }
647
655
  }
648
656
  }
649
657
 
@@ -130,6 +130,7 @@ module.exports = class PluginManager {
130
130
  site,
131
131
  url,
132
132
  headerTags,
133
+ codeOriginForSpans,
133
134
  dbmPropagationMode,
134
135
  dsmEnabled,
135
136
  clientIpEnabled,
@@ -143,6 +144,7 @@ module.exports = class PluginManager {
143
144
  } = this._tracerConfig
144
145
 
145
146
  const sharedConfig = {
147
+ codeOriginForSpans,
146
148
  dbmPropagationMode,
147
149
  dsmEnabled,
148
150
  memcachedCommandEnabled,
@@ -57,6 +57,9 @@ module.exports = {
57
57
  get koa () { return require('../../../datadog-plugin-koa/src') },
58
58
  get 'koa-router' () { return require('../../../datadog-plugin-koa/src') },
59
59
  get kafkajs () { return require('../../../datadog-plugin-kafkajs/src') },
60
+ get '@confluentinc/kafka-javascript' () {
61
+ return require('../../../datadog-plugin-confluentinc-kafka-javascript/src')
62
+ },
60
63
  get langchain () { return require('../../../datadog-plugin-langchain/src') },
61
64
  get mariadb () { return require('../../../datadog-plugin-mariadb/src') },
62
65
  get memcached () { return require('../../../datadog-plugin-memcached/src') },
@@ -4,31 +4,21 @@ const { LOG } = require('../../../../ext/formats')
4
4
  const Plugin = require('./plugin')
5
5
  const { storage } = require('../../../datadog-core')
6
6
 
7
- const hasOwn = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop)
8
-
9
7
  function messageProxy (message, holder) {
10
8
  return new Proxy(message, {
11
- get (target, p, receiver) {
12
- if (p === Symbol.toStringTag) {
13
- return Object.prototype.toString.call(target).slice(8, -1)
14
- }
15
-
16
- if (shouldOverride(target, p)) {
9
+ get (target, key) {
10
+ if (shouldOverride(target, key)) {
17
11
  return holder.dd
18
12
  }
19
13
 
20
- // This is a workaround for a V8 bug that surfaced in Node.js 22
21
- if (p === 'stack') {
22
- return target.stack
23
- }
24
-
25
- return Reflect.get(target, p, receiver)
14
+ return target[key]
26
15
  },
27
16
  ownKeys (target) {
28
17
  const ownKeys = Reflect.ownKeys(target)
29
- return hasOwn(target, 'dd') || !Reflect.isExtensible(target)
30
- ? ownKeys
31
- : ['dd', ...ownKeys]
18
+ if (!Object.hasOwn(target, 'dd') && Reflect.isExtensible(target)) {
19
+ ownKeys.push('dd')
20
+ }
21
+ return ownKeys
32
22
  },
33
23
  getOwnPropertyDescriptor (target, p) {
34
24
  return Reflect.getOwnPropertyDescriptor(shouldOverride(target, p) ? holder : target, p)
@@ -37,7 +27,7 @@ function messageProxy (message, holder) {
37
27
  }
38
28
 
39
29
  function shouldOverride (target, p) {
40
- return p === 'dd' && !Reflect.has(target, p) && Reflect.isExtensible(target)
30
+ return p === 'dd' && !Object.hasOwn(target, p) && Reflect.isExtensible(target)
41
31
  }
42
32
 
43
33
  module.exports = class LogPlugin extends Plugin {
@@ -45,8 +35,7 @@ module.exports = class LogPlugin extends Plugin {
45
35
  super(...args)
46
36
 
47
37
  this.addSub(`apm:${this.constructor.id}:log`, (arg) => {
48
- const store = storage('legacy').getStore()
49
- const span = store && store.span
38
+ const span = storage('legacy').getStore()?.span
50
39
 
51
40
  // NOTE: This needs to run whether or not there is a span
52
41
  // so service, version, and env will always get injected.
@@ -28,7 +28,10 @@ class OutboundPlugin extends TracingPlugin {
28
28
 
29
29
  startSpan (...args) {
30
30
  const span = super.startSpan(...args)
31
- if (this._tracerConfig.codeOriginForSpans.enabled) {
31
+ if (
32
+ this._tracerConfig.codeOriginForSpans.enabled &&
33
+ this._tracerConfig.codeOriginForSpans.experimental.exit_spans.enabled
34
+ ) {
32
35
  span.addTags(exitTags(this.startSpan))
33
36
  }
34
37
  return span
@@ -84,8 +87,13 @@ class OutboundPlugin extends TracingPlugin {
84
87
  return peerData
85
88
  }
86
89
 
87
- finish () {
88
- this.tagPeerService(this.activeSpan)
90
+ bindFinish (ctx) {
91
+ return ctx.parentStore
92
+ }
93
+
94
+ finish (ctx) {
95
+ const span = ctx?.currentStore?.span || this.activeSpan
96
+ this.tagPeerService(span)
89
97
  super.finish(...arguments)
90
98
  }
91
99
 
@@ -53,8 +53,9 @@ class TracingPlugin extends Plugin {
53
53
 
54
54
  start () {} // implemented by individual plugins
55
55
 
56
- finish () {
57
- this.activeSpan?.finish()
56
+ finish (ctx) {
57
+ const span = ctx?.currentStore?.span || this.activeSpan
58
+ span?.finish()
58
59
  }
59
60
 
60
61
  error (ctxOrError) {
@@ -101,7 +102,7 @@ class TracingPlugin extends Plugin {
101
102
  }
102
103
  }
103
104
 
104
- startSpan (name, { childOf, kind, meta, metrics, service, resource, type } = {}, enter = true) {
105
+ startSpan (name, { childOf, kind, meta, metrics, service, resource, type } = {}, enterOrCtx = true) {
105
106
  const store = storage('legacy').getStore()
106
107
  if (store && childOf === undefined) {
107
108
  childOf = store.span
@@ -125,8 +126,11 @@ class TracingPlugin extends Plugin {
125
126
  analyticsSampler.sample(span, this.config.measured)
126
127
 
127
128
  // TODO: Remove this after migration to TracingChannel is done.
128
- if (enter) {
129
+ if (enterOrCtx === true) {
129
130
  storage('legacy').enterWith({ ...store, span })
131
+ } else if (enterOrCtx) {
132
+ enterOrCtx.parentStore = store
133
+ enterOrCtx.currentStore = { ...store, span }
130
134
  }
131
135
 
132
136
  return span
@@ -786,7 +786,7 @@ function getLibraryCapabilitiesTags (testFramework, isParallel) {
786
786
  [DD_CAPABILITIES_TEST_MANAGEMENT_QUARANTINE]: '1',
787
787
  [DD_CAPABILITIES_TEST_MANAGEMENT_DISABLE]: '1',
788
788
  [DD_CAPABILITIES_TEST_MANAGEMENT_ATTEMPT_TO_FIX]: isAttemptToFixSupported(testFramework, isParallel)
789
- ? '2'
789
+ ? '4'
790
790
  : undefined
791
791
  }
792
792
  }
@@ -10,7 +10,7 @@ const fs = require('fs')
10
10
  const { fileURLToPath } = require('url')
11
11
 
12
12
  const logger = new ConsoleLogger()
13
- const timeoutMs = 10 * 1000
13
+ const timeoutMs = 15 * 1000
14
14
 
15
15
  function exporterFromURL (url) {
16
16
  if (url.protocol === 'file:') {
@@ -7,7 +7,7 @@ class DNSLookupPlugin extends DNSPlugin {
7
7
 
8
8
  extendEvent (event, startEvent) {
9
9
  event.name = 'lookup'
10
- event.detail = { hostname: startEvent[0] }
10
+ event.detail = { hostname: startEvent.args[0] }
11
11
 
12
12
  return event
13
13
  }
@@ -7,7 +7,7 @@ class DNSLookupServicePlugin extends DNSPlugin {
7
7
 
8
8
  extendEvent (event, startEvent) {
9
9
  event.name = 'lookupService'
10
- event.detail = { host: startEvent[0], port: startEvent[1] }
10
+ event.detail = { host: startEvent.args[0], port: startEvent.args[1] }
11
11
 
12
12
  return event
13
13
  }
@@ -8,14 +8,14 @@ class DNSResolvePlugin extends DNSPlugin {
8
8
  }
9
9
 
10
10
  extendEvent (event, startEvent) {
11
- const rrtype = startEvent[1]
11
+ const rrtype = startEvent.args[1]
12
12
  let name = queryNames.get(rrtype)
13
13
  if (!name) {
14
14
  name = `query${rrtype}`
15
15
  queryNames.set(rrtype, name)
16
16
  }
17
17
  event.name = name
18
- event.detail = { host: startEvent[0] }
18
+ event.detail = { host: startEvent.args[0] }
19
19
 
20
20
  return event
21
21
  }
@@ -7,7 +7,7 @@ class DNSReversePlugin extends DNSPlugin {
7
7
 
8
8
  extendEvent (event, startEvent) {
9
9
  event.name = 'getHostByAddr'
10
- event.detail = { host: startEvent[0] }
10
+ event.detail = { host: startEvent.args[0] }
11
11
 
12
12
  return event
13
13
  }
@@ -1,37 +1,38 @@
1
- const { storage } = require('../../../../../datadog-core')
2
1
  const TracingPlugin = require('../../../plugins/tracing')
3
2
  const { performance } = require('perf_hooks')
4
3
 
5
4
  // We are leveraging the TracingPlugin class for its functionality to bind
6
5
  // start/error/finish methods to the appropriate diagnostic channels.
6
+ // TODO: Decouple this from TracingPlugin.
7
7
  class EventPlugin extends TracingPlugin {
8
8
  constructor (eventHandler, eventFilter) {
9
9
  super()
10
10
  this.eventHandler = eventHandler
11
11
  this.eventFilter = eventFilter
12
- this.store = storage('profiling')
12
+ this.contextData = new WeakMap()
13
13
  this.entryType = this.constructor.entryType
14
14
  }
15
15
 
16
- start (startEvent) {
17
- this.store.enterWith({
18
- startEvent,
16
+ start (ctx) {
17
+ this.contextData.set(ctx, {
18
+ startEvent: ctx,
19
19
  startTime: performance.now()
20
20
  })
21
21
  }
22
22
 
23
- error () {
24
- const store = this.store.getStore()
25
- if (store) {
26
- store.error = true
23
+ error (ctx) {
24
+ const data = this.contextData.get(ctx)
25
+ if (data) {
26
+ data.error = true
27
27
  }
28
28
  }
29
29
 
30
- finish () {
31
- const store = this.store.getStore()
32
- if (!store) return
30
+ finish (ctx) {
31
+ const data = this.contextData.get(ctx)
33
32
 
34
- const { startEvent, startTime, error } = store
33
+ if (!data) return
34
+
35
+ const { startEvent, startTime, error } = data
35
36
  if (error || this.ignoreEvent(startEvent)) {
36
37
  return // don't emit perf events for failed operations or ignored events
37
38
  }
@@ -47,7 +48,7 @@ class EventPlugin extends TracingPlugin {
47
48
  return
48
49
  }
49
50
 
50
- const context = this.activeSpan?.context()
51
+ const context = (ctx.currentStore?.span || this.activeSpan)?.context()
51
52
  event._ddSpanId = context?.toSpanId()
52
53
  event._ddRootSpanId = context?._trace.started[0]?.context().toSpanId() || event._ddSpanId
53
54
 
@@ -10,6 +10,13 @@ const telemetry = require('./telemetry')
10
10
  const nomenclature = require('./service-naming')
11
11
  const PluginManager = require('./plugin_manager')
12
12
  const NoopDogStatsDClient = require('./noop/dogstatsd')
13
+ const {
14
+ setBaggageItem,
15
+ getBaggageItem,
16
+ getAllBaggageItems,
17
+ removeBaggageItem,
18
+ removeAllBaggageItems
19
+ } = require('./baggage')
13
20
 
14
21
  class LazyModule {
15
22
  constructor (provider) {
@@ -65,6 +72,11 @@ class Tracer extends NoopProxy {
65
72
  this.dogstatsd = new NoopDogStatsDClient()
66
73
  this._tracingInitialized = false
67
74
  this._flare = new LazyModule(() => require('./flare'))
75
+ this.setBaggageItem = setBaggageItem
76
+ this.getBaggageItem = getBaggageItem
77
+ this.getAllBaggageItems = getAllBaggageItems
78
+ this.removeBaggageItem = removeBaggageItem
79
+ this.removeAllBaggageItems = removeAllBaggageItems
68
80
 
69
81
  // these requires must work with esm bundler
70
82
  this._modules = {
@@ -22,6 +22,10 @@ const messaging = {
22
22
  opName: () => 'kafka.produce',
23
23
  serviceName: ({ tracerService }) => `${tracerService}-kafka`
24
24
  },
25
+ '@confluentinc/kafka-javascript': {
26
+ opName: () => 'kafka.produce',
27
+ serviceName: ({ tracerService }) => `${tracerService}-kafka`
28
+ },
25
29
  rhea: {
26
30
  opName: () => 'amqp.send',
27
31
  serviceName: ({ tracerService }) => `${tracerService}-amqp-producer`
@@ -52,6 +56,10 @@ const messaging = {
52
56
  opName: () => 'kafka.consume',
53
57
  serviceName: ({ tracerService }) => `${tracerService}-kafka`
54
58
  },
59
+ '@confluentinc/kafka-javascript': {
60
+ opName: () => 'kafka.consume',
61
+ serviceName: ({ tracerService }) => `${tracerService}-kafka`
62
+ },
55
63
  rhea: {
56
64
  opName: () => 'amqp.receive',
57
65
  serviceName: identityService
@@ -22,6 +22,10 @@ const messaging = {
22
22
  opName: () => 'kafka.send',
23
23
  serviceName: identityService
24
24
  },
25
+ '@confluentinc/kafka-javascript': {
26
+ opName: () => 'kafka.send',
27
+ serviceName: identityService
28
+ },
25
29
  rhea: amqpOutbound,
26
30
  sqs: {
27
31
  opName: () => 'aws.sqs.send',
@@ -43,6 +47,10 @@ const messaging = {
43
47
  opName: () => 'kafka.process',
44
48
  serviceName: identityService
45
49
  },
50
+ '@confluentinc/kafka-javascript': {
51
+ opName: () => 'kafka.process',
52
+ serviceName: identityService
53
+ },
46
54
  rhea: amqpInbound,
47
55
  sqs: {
48
56
  opName: () => 'aws.sqs.process',
@@ -3,14 +3,12 @@
3
3
  const { SAMPLING_MECHANISM_APPSEC } = require('../constants')
4
4
  const RateLimiter = require('../rate_limiter')
5
5
 
6
- const dropAll = new RateLimiter(0)
7
- const onePerMinute = new RateLimiter(1, 'minute')
8
-
9
6
  function getProductRateLimiter (config) {
10
7
  if (config?.appsec?.enabled || config?.iast?.enabled) {
11
- return onePerMinute
8
+ return new RateLimiter(1, 'minute') // onePerMinute
12
9
  }
13
- return dropAll
10
+
11
+ return new RateLimiter(0) // dropAll
14
12
  }
15
13
 
16
14
  const PRODUCTS = {