dd-trace 5.7.0 → 5.9.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 (116) hide show
  1. package/LICENSE-3rdparty.csv +0 -1
  2. package/ci/init.js +3 -3
  3. package/index.d.ts +35 -0
  4. package/package.json +4 -5
  5. package/packages/datadog-esbuild/index.js +2 -2
  6. package/packages/datadog-instrumentations/src/apollo-server.js +1 -1
  7. package/packages/datadog-instrumentations/src/apollo.js +103 -0
  8. package/packages/datadog-instrumentations/src/aws-sdk.js +4 -1
  9. package/packages/datadog-instrumentations/src/cassandra-driver.js +1 -1
  10. package/packages/datadog-instrumentations/src/cucumber.js +6 -2
  11. package/packages/datadog-instrumentations/src/fs.js +0 -1
  12. package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +1 -1
  13. package/packages/datadog-instrumentations/src/helpers/hooks.js +57 -56
  14. package/packages/datadog-instrumentations/src/helpers/instrument.js +2 -2
  15. package/packages/datadog-instrumentations/src/http/client.js +1 -0
  16. package/packages/datadog-instrumentations/src/jest.js +12 -13
  17. package/packages/datadog-instrumentations/src/kafkajs.js +2 -1
  18. package/packages/datadog-instrumentations/src/ldapjs.js +2 -1
  19. package/packages/datadog-instrumentations/src/mocha.js +1 -1
  20. package/packages/datadog-instrumentations/src/mongodb-core.js +4 -6
  21. package/packages/datadog-instrumentations/src/net.js +1 -1
  22. package/packages/datadog-instrumentations/src/passport-utils.js +1 -0
  23. package/packages/datadog-instrumentations/src/playwright.js +158 -7
  24. package/packages/datadog-instrumentations/src/rhea.js +5 -2
  25. package/packages/datadog-instrumentations/src/tedious.js +1 -1
  26. package/packages/datadog-plugin-apollo/src/gateway/execute.js +12 -0
  27. package/packages/datadog-plugin-apollo/src/gateway/fetch.js +36 -0
  28. package/packages/datadog-plugin-apollo/src/gateway/index.js +36 -0
  29. package/packages/datadog-plugin-apollo/src/gateway/plan.js +12 -0
  30. package/packages/datadog-plugin-apollo/src/gateway/postprocessing.js +12 -0
  31. package/packages/datadog-plugin-apollo/src/gateway/request.js +124 -0
  32. package/packages/datadog-plugin-apollo/src/gateway/validate.js +25 -0
  33. package/packages/datadog-plugin-apollo/src/index.js +15 -0
  34. package/packages/datadog-plugin-aws-sdk/src/base.js +3 -3
  35. package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +1 -1
  36. package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +2 -2
  37. package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +1 -1
  38. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +1 -1
  39. package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +1 -1
  40. package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +1 -1
  41. package/packages/datadog-plugin-aws-sdk/src/services/s3.js +1 -1
  42. package/packages/datadog-plugin-aws-sdk/src/services/sns.js +1 -1
  43. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +2 -2
  44. package/packages/datadog-plugin-child_process/src/index.js +1 -1
  45. package/packages/datadog-plugin-couchbase/src/index.js +2 -1
  46. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +1 -0
  47. package/packages/datadog-plugin-fetch/src/index.js +1 -1
  48. package/packages/datadog-plugin-graphql/src/resolve.js +1 -1
  49. package/packages/datadog-plugin-grpc/src/client.js +2 -2
  50. package/packages/datadog-plugin-grpc/src/server.js +2 -2
  51. package/packages/datadog-plugin-http/src/client.js +2 -2
  52. package/packages/datadog-plugin-http2/src/client.js +4 -3
  53. package/packages/datadog-plugin-jest/src/index.js +1 -0
  54. package/packages/datadog-plugin-kafkajs/src/consumer.js +1 -1
  55. package/packages/datadog-plugin-kafkajs/src/producer.js +1 -1
  56. package/packages/datadog-plugin-next/src/index.js +1 -1
  57. package/packages/datadog-plugin-openai/src/index.js +4 -4
  58. package/packages/datadog-plugin-playwright/src/index.js +16 -3
  59. package/packages/datadog-plugin-rhea/src/consumer.js +1 -1
  60. package/packages/datadog-plugin-rhea/src/producer.js +1 -1
  61. package/packages/datadog-plugin-router/src/index.js +1 -1
  62. package/packages/datadog-plugin-tedious/src/index.js +1 -1
  63. package/packages/dd-trace/src/appsec/blocking.js +1 -1
  64. package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +17 -17
  65. package/packages/dd-trace/src/appsec/iast/analyzers/cookie-analyzer.js +1 -0
  66. package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secrets-rules.js +132 -132
  67. package/packages/dd-trace/src/appsec/iast/analyzers/hsts-header-missing-analyzer.js +1 -0
  68. package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +1 -1
  69. package/packages/dd-trace/src/appsec/iast/overhead-controller.js +2 -1
  70. package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +3 -3
  71. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +4 -4
  72. package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +1 -1
  73. package/packages/dd-trace/src/appsec/iast/telemetry/namespaces.js +27 -18
  74. package/packages/dd-trace/src/appsec/iast/telemetry/span-tags.js +1 -1
  75. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/sql-sensitive-analyzer.js +1 -1
  76. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +7 -4
  77. package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +2 -2
  78. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +0 -1
  79. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -1
  80. package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +1 -0
  81. package/packages/dd-trace/src/config.js +13 -13
  82. package/packages/dd-trace/src/datastreams/pathway.js +1 -1
  83. package/packages/dd-trace/src/datastreams/processor.js +15 -15
  84. package/packages/dd-trace/src/encode/agentless-ci-visibility.js +2 -2
  85. package/packages/dd-trace/src/encode/coverage-ci-visibility.js +1 -1
  86. package/packages/dd-trace/src/exporters/common/request.js +1 -0
  87. package/packages/dd-trace/src/exporters/span-stats/writer.js +0 -1
  88. package/packages/dd-trace/src/external-logger/src/index.js +5 -5
  89. package/packages/dd-trace/src/opentelemetry/span.js +2 -0
  90. package/packages/dd-trace/src/opentracing/propagation/text_map.js +1 -1
  91. package/packages/dd-trace/src/opentracing/span.js +1 -1
  92. package/packages/dd-trace/src/plugin_manager.js +1 -2
  93. package/packages/dd-trace/src/plugins/apollo.js +52 -0
  94. package/packages/dd-trace/src/plugins/ci_plugin.js +2 -1
  95. package/packages/dd-trace/src/plugins/composite.js +4 -4
  96. package/packages/dd-trace/src/plugins/database.js +1 -0
  97. package/packages/dd-trace/src/plugins/index.js +44 -43
  98. package/packages/dd-trace/src/plugins/plugin.js +1 -1
  99. package/packages/dd-trace/src/plugins/tracing.js +9 -6
  100. package/packages/dd-trace/src/plugins/util/test.js +2 -1
  101. package/packages/dd-trace/src/plugins/util/web.js +4 -4
  102. package/packages/dd-trace/src/profiling/config.js +1 -1
  103. package/packages/dd-trace/src/profiling/loggers/console.js +1 -1
  104. package/packages/dd-trace/src/profiling/profilers/events.js +79 -82
  105. package/packages/dd-trace/src/proxy.js +2 -0
  106. package/packages/dd-trace/src/runtime_metrics.js +8 -5
  107. package/packages/dd-trace/src/serverless.js +3 -2
  108. package/packages/dd-trace/src/service-naming/schemas/v0/web.js +24 -0
  109. package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +0 -1
  110. package/packages/dd-trace/src/service-naming/schemas/v1/web.js +24 -0
  111. package/packages/dd-trace/src/span_processor.js +2 -2
  112. package/packages/dd-trace/src/span_stats.js +1 -1
  113. package/packages/dd-trace/src/telemetry/dependencies.js +4 -5
  114. package/packages/dd-trace/src/telemetry/index.js +12 -13
  115. package/packages/dd-trace/src/telemetry/send-data.js +0 -1
  116. package/packages/dd-trace/src/util.js +7 -7
@@ -23,13 +23,10 @@ const fromEntries = Object.fromEntries || (entries =>
23
23
 
24
24
  // eslint-disable-next-line max-len
25
25
  const qsRegex = '(?:p(?:ass)?w(?:or)?d|pass(?:_?phrase)?|secret|(?:api_?|private_?|public_?|access_?|secret_?)key(?:_?id)?|token|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)(?:(?:\\s|%20)*(?:=|%3D)[^&]+|(?:"|%22)(?:\\s|%20)*(?::|%3A)(?:\\s|%20)*(?:"|%22)(?:%2[^2]|%[^2]|[^"%])+(?:"|%22))|bearer(?:\\s|%20)+[a-z0-9\\._\\-]+|token(?::|%3A)[a-z0-9]{13}|gh[opsu]_[0-9a-zA-Z]{36}|ey[I-L](?:[\\w=-]|%3D)+\\.ey[I-L](?:[\\w=-]|%3D)+(?:\\.(?:[\\w.+\\/=-]|%3D|%2F|%2B)+)?|[\\-]{5}BEGIN(?:[a-z\\s]|%20)+PRIVATE(?:\\s|%20)KEY[\\-]{5}[^\\-]+[\\-]{5}END(?:[a-z\\s]|%20)+PRIVATE(?:\\s|%20)KEY|ssh-rsa(?:\\s|%20)*(?:[a-z0-9\\/\\.+]|%2F|%5C|%2B){100,}'
26
- const defaultWafObfuscatorKeyRegex = `(?i)(?:p(?:ass)?w(?:or)?d|pass(?:_?phrase)?|secret|(?:api_?|private_?\
27
- |public_?)key)|token|consumer_?(?:id|key|secret)|sign(?:ed|ature)|bearer|authorization`
28
- const defaultWafObfuscatorValueRegex =
29
- `(?i)(?:p(?:ass)?w(?:or)?d|pass(?:_?phrase)?|secret|(?:api_?|private_?|public_?|access_?|secret_?)key(?:_?id)?|to\
30
- ken|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)(?:\\s*=[^;]|"\\s*:\\s*"[^"]+")|bearer\
31
- \\s+[a-z0-9\\._\\-]+|token:[a-z0-9]{13}|gh[opsu]_[0-9a-zA-Z]{36}|ey[I-L][\\w=-]+\\.ey[I-L][\\w=-]+(?:\\.[\\w.+\\/=-]+)?\
32
- |[\\-]{5}BEGIN[a-z\\s]+PRIVATE\\sKEY[\\-]{5}[^\\-]+[\\-]{5}END[a-z\\s]+PRIVATE\\sKEY|ssh-rsa\\s*[a-z0-9\\/\\.+]{100,}`
26
+ // eslint-disable-next-line max-len
27
+ const defaultWafObfuscatorKeyRegex = '(?i)(?:p(?:ass)?w(?:or)?d|pass(?:_?phrase)?|secret|(?:api_?|private_?|public_?)key)|token|consumer_?(?:id|key|secret)|sign(?:ed|ature)|bearer|authorization'
28
+ // eslint-disable-next-line max-len
29
+ const defaultWafObfuscatorValueRegex = '(?i)(?:p(?:ass)?w(?:or)?d|pass(?:_?phrase)?|secret|(?:api_?|private_?|public_?|access_?|secret_?)key(?:_?id)?|token|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)(?:\\s*=[^;]|"\\s*:\\s*"[^"]+")|bearer\\s+[a-z0-9\\._\\-]+|token:[a-z0-9]{13}|gh[opsu]_[0-9a-zA-Z]{36}|ey[I-L][\\w=-]+\\.ey[I-L][\\w=-]+(?:\\.[\\w.+\\/=-]+)?|[\\-]{5}BEGIN[a-z\\s]+PRIVATE\\sKEY[\\-]{5}[^\\-]+[\\-]{5}END[a-z\\s]+PRIVATE\\sKEY|ssh-rsa\\s*[a-z0-9\\/\\.+]{100,}'
33
30
 
34
31
  function maybeFile (filepath) {
35
32
  if (!filepath) return
@@ -132,9 +129,11 @@ class Config {
132
129
 
133
130
  const DD_SERVICE_MAPPING = coalesce(
134
131
  options.serviceMapping,
135
- process.env.DD_SERVICE_MAPPING ? fromEntries(
136
- process.env.DD_SERVICE_MAPPING.split(',').map(x => x.trim().split(':'))
137
- ) : {}
132
+ process.env.DD_SERVICE_MAPPING
133
+ ? fromEntries(
134
+ process.env.DD_SERVICE_MAPPING.split(',').map(x => x.trim().split(':'))
135
+ )
136
+ : {}
138
137
  )
139
138
 
140
139
  const DD_API_KEY = coalesce(
@@ -704,7 +703,7 @@ class Config {
704
703
  _isCiVisibility () {
705
704
  return coalesce(
706
705
  this.options.isCiVisibility,
707
- this._defaults['isCiVisibility']
706
+ this._defaults.isCiVisibility
708
707
  )
709
708
  }
710
709
 
@@ -717,7 +716,8 @@ class Config {
717
716
 
718
717
  _getHostname () {
719
718
  const DD_CIVISIBILITY_AGENTLESS_URL = process.env.DD_CIVISIBILITY_AGENTLESS_URL
720
- const url = DD_CIVISIBILITY_AGENTLESS_URL ? new URL(DD_CIVISIBILITY_AGENTLESS_URL)
719
+ const url = DD_CIVISIBILITY_AGENTLESS_URL
720
+ ? new URL(DD_CIVISIBILITY_AGENTLESS_URL)
721
721
  : getAgentUrl(this._getTraceAgentUrl(), this.options)
722
722
  const DD_AGENT_HOST = coalesce(
723
723
  this.options.hostname,
@@ -808,7 +808,7 @@ class Config {
808
808
  }
809
809
  this._setString(calc, 'dogstatsd.hostname', this._getHostname())
810
810
  this._setBoolean(calc, 'isGitUploadEnabled',
811
- calc['isIntelligentTestRunnerEnabled'] && !isFalse(this._isCiVisibilityGitUploadEnabled()))
811
+ calc.isIntelligentTestRunnerEnabled && !isFalse(this._isCiVisibilityGitUploadEnabled()))
812
812
  this._setBoolean(calc, 'spanComputePeerService', this._getSpanComputePeerService())
813
813
  this._setBoolean(calc, 'stats.enabled', this._isTraceStatsComputationEnabled())
814
814
  }
@@ -22,7 +22,7 @@ function computeHash (service, env, edgeTags, parentHash) {
22
22
  return cache.get(key)
23
23
  }
24
24
  const currentHash = shaHash(`${service}${env}` + edgeTags.join(''))
25
- const buf = Buffer.concat([ currentHash, parentHash ], 16)
25
+ const buf = Buffer.concat([currentHash, parentHash], 16)
26
26
  const val = shaHash(buf.toString())
27
27
  cache.set(key, val)
28
28
  return val
@@ -273,12 +273,12 @@ class DataStreamsProcessor {
273
273
  const edgeLatencyNs = nowNs - edgeStartNs
274
274
  const pathwayLatencyNs = nowNs - pathwayStartNs
275
275
  const dataStreamsContext = {
276
- hash: hash,
277
- edgeStartNs: edgeStartNs,
278
- pathwayStartNs: pathwayStartNs,
276
+ hash,
277
+ edgeStartNs,
278
+ pathwayStartNs,
279
279
  previousDirection: direction,
280
- closestOppositeDirectionHash: closestOppositeDirectionHash,
281
- closestOppositeDirectionEdgeStart: closestOppositeDirectionEdgeStart
280
+ closestOppositeDirectionHash,
281
+ closestOppositeDirectionEdgeStart
282
282
  }
283
283
  if (direction === 'direction:out') {
284
284
  // Add the header for this now, as the callee doesn't have access to context when producing
@@ -289,12 +289,12 @@ class DataStreamsProcessor {
289
289
  }
290
290
  const checkpoint = {
291
291
  currentTimestamp: nowNs,
292
- parentHash: parentHash,
293
- hash: hash,
294
- edgeTags: edgeTags,
295
- edgeLatencyNs: edgeLatencyNs,
296
- pathwayLatencyNs: pathwayLatencyNs,
297
- payloadSize: payloadSize
292
+ parentHash,
293
+ hash,
294
+ edgeTags,
295
+ edgeLatencyNs,
296
+ pathwayLatencyNs,
297
+ payloadSize
298
298
  }
299
299
  this.recordCheckpoint(checkpoint, span)
300
300
  return dataStreamsContext
@@ -320,7 +320,7 @@ class DataStreamsProcessor {
320
320
  // TimeBuckets
321
321
  const serializedBuckets = []
322
322
 
323
- for (const [ timeNs, bucket ] of this.buckets.entries()) {
323
+ for (const [timeNs, bucket] of this.buckets.entries()) {
324
324
  const points = []
325
325
 
326
326
  // bucket: StatsBucket
@@ -354,9 +354,9 @@ class DataStreamsProcessor {
354
354
  }
355
355
 
356
356
  module.exports = {
357
- DataStreamsProcessor: DataStreamsProcessor,
358
- StatsPoint: StatsPoint,
359
- StatsBucket: StatsBucket,
357
+ DataStreamsProcessor,
358
+ StatsPoint,
359
+ StatsBucket,
360
360
  Backlog,
361
361
  TimeBuckets,
362
362
  getMessageSize,
@@ -328,8 +328,8 @@ class AgentlessCiVisibilityEncoder extends AgentEncoder {
328
328
  version: ENCODING_VERSION,
329
329
  metadata: {
330
330
  '*': {
331
- 'language': 'javascript',
332
- 'library_version': ddTraceVersion
331
+ language: 'javascript',
332
+ library_version: ddTraceVersion
333
333
  }
334
334
  },
335
335
  events: []
@@ -108,7 +108,7 @@ class CoverageCIVisibilityEncoder extends AgentEncoder {
108
108
  'coverage1',
109
109
  buffer,
110
110
  {
111
- filename: `coverage1.msgpack`,
111
+ filename: 'coverage1.msgpack',
112
112
  contentType: 'application/msgpack'
113
113
  }
114
114
  )
@@ -6,6 +6,7 @@
6
6
  const { Readable } = require('stream')
7
7
  const http = require('http')
8
8
  const https = require('https')
9
+ // eslint-disable-next-line n/no-deprecated-api
9
10
  const { parse: urlParse } = require('url')
10
11
  const zlib = require('zlib')
11
12
 
@@ -1,4 +1,3 @@
1
-
2
1
  const { SpanStatsEncoder } = require('../../encode/span-stats')
3
2
 
4
3
  const pkg = require('../../../../../package.json')
@@ -51,11 +51,11 @@ class ExternalLogger {
51
51
 
52
52
  const payload = {
53
53
  ...log,
54
- 'timestamp': Date.now(),
55
- 'hostname': log.hostname || this.hostname,
56
- 'ddsource': log.ddsource || this.ddsource,
57
- 'service': log.service || this.service,
58
- 'ddtags': logTags || undefined
54
+ timestamp: Date.now(),
55
+ hostname: log.hostname || this.hostname,
56
+ ddsource: log.ddsource || this.ddsource,
57
+ service: log.service || this.service,
58
+ ddtags: logTags || undefined
59
59
  }
60
60
 
61
61
  this.enqueue(payload)
@@ -161,9 +161,11 @@ class Span {
161
161
  get resource () {
162
162
  return this._parentTracer.resource
163
163
  }
164
+
164
165
  get instrumentationLibrary () {
165
166
  return this._parentTracer.instrumentationLibrary
166
167
  }
168
+
167
169
  get _spanProcessor () {
168
170
  return this._parentTracer.getActiveSpanProcessor()
169
171
  }
@@ -321,7 +321,7 @@ class TextMapPropagator {
321
321
  }
322
322
  const matches = headerValue.trim().match(traceparentExpr)
323
323
  if (matches.length) {
324
- const [ version, traceId, spanId, flags, tail ] = matches.slice(1)
324
+ const [version, traceId, spanId, flags, tail] = matches.slice(1)
325
325
  const traceparent = { version }
326
326
  const tracestate = TraceState.fromString(carrier.tracestate)
327
327
  if (invalidSegment.test(traceId)) return null
@@ -210,7 +210,7 @@ class DatadogSpan {
210
210
  // Wrap the value as a string if it's not already a string
211
211
  sanitizedAttributes[key] = typeof maybeScalar === 'string' ? maybeScalar : String(maybeScalar)
212
212
  } else {
213
- log.warn(`Dropping span link attribute. It is not of an allowed type`)
213
+ log.warn('Dropping span link attribute. It is not of an allowed type')
214
214
  }
215
215
  }
216
216
  }
@@ -4,7 +4,6 @@ const { channel } = require('dc-polyfill')
4
4
  const { isFalse } = require('./util')
5
5
  const plugins = require('./plugins')
6
6
  const log = require('./log')
7
- const Nomenclature = require('./service-naming')
8
7
 
9
8
  const loadChannel = channel('dd-trace:instrumentation:load')
10
9
 
@@ -102,7 +101,7 @@ module.exports = class PluginManager {
102
101
  // like instrumenter.enable()
103
102
  configure (config = {}) {
104
103
  this._tracerConfig = config
105
- Nomenclature.configure(config)
104
+ this._tracer._nomenclature.configure(config)
106
105
 
107
106
  for (const name in pluginClasses) {
108
107
  this.loadPlugin(name)
@@ -0,0 +1,52 @@
1
+ const TracingPlugin = require('./tracing')
2
+ const { storage } = require('../../../datadog-core')
3
+
4
+ class ApolloBasePlugin extends TracingPlugin {
5
+ static get id () { return 'apollo.gateway' }
6
+ static get type () { return 'web' }
7
+ static get kind () { return 'server' }
8
+
9
+ bindStart (ctx) {
10
+ const store = storage.getStore()
11
+ const childOf = store ? store.span : null
12
+
13
+ const span = this.startSpan(this.getOperationName(), {
14
+ childOf,
15
+ service: this.getServiceName(),
16
+ type: this.constructor.type,
17
+ kind: this.constructor.kind,
18
+ meta: {}
19
+ }, false)
20
+
21
+ ctx.parentStore = store
22
+ ctx.currentStore = { ...store, span }
23
+
24
+ return ctx.currentStore
25
+ }
26
+
27
+ end (ctx) {
28
+ // Only synchronous operations would have `result` or `error` on `end`.
29
+ if (!ctx.hasOwnProperty('result') && !ctx.hasOwnProperty('error')) return
30
+ ctx?.currentStore?.span?.finish()
31
+ }
32
+
33
+ asyncStart (ctx) {
34
+ ctx?.currentStore?.span.finish()
35
+ return ctx.parentStore
36
+ }
37
+
38
+ getServiceName () {
39
+ return this.serviceName({
40
+ id: `${this.constructor.id}.${this.constructor.operation}`,
41
+ pluginConfig: this.config
42
+ })
43
+ }
44
+
45
+ getOperationName () {
46
+ return this.operationName({
47
+ id: `${this.constructor.id}.${this.constructor.operation}`
48
+ })
49
+ }
50
+ }
51
+
52
+ module.exports = ApolloBasePlugin
@@ -42,7 +42,7 @@ module.exports = class CiPlugin extends Plugin {
42
42
  }
43
43
  this.tracer._exporter.getLibraryConfiguration(this.testConfiguration, (err, libraryConfig) => {
44
44
  if (err) {
45
- log.error(`Intelligent Test Runner configuration could not be fetched. ${err.message}`)
45
+ log.error(`Library configuration could not be fetched. ${err.message}`)
46
46
  } else {
47
47
  this.libraryConfig = libraryConfig
48
48
  }
@@ -123,6 +123,7 @@ module.exports = class CiPlugin extends Plugin {
123
123
  this.tracer._exporter.getKnownTests(this.testConfiguration, (err, knownTests) => {
124
124
  if (err) {
125
125
  log.error(`Known tests could not be fetched. ${err.message}`)
126
+ this.libraryConfig.isEarlyFlakeDetectionEnabled = false
126
127
  }
127
128
  onDone({ err, knownTests })
128
129
  })
@@ -12,11 +12,11 @@ class CompositePlugin extends Plugin {
12
12
  }
13
13
 
14
14
  configure (config) {
15
+ super.configure(config)
15
16
  for (const name in this.constructor.plugins) {
16
- const pluginConfig = config[name] === false ? false : {
17
- ...config,
18
- ...config[name]
19
- }
17
+ const pluginConfig = config[name] === false
18
+ ? false
19
+ : { ...config, ...config[name] }
20
20
 
21
21
  this[name].configure(pluginConfig)
22
22
  }
@@ -20,6 +20,7 @@ class DatabasePlugin extends StoragePlugin {
20
20
  encodedDdpv: ''
21
21
  }
22
22
  }
23
+
23
24
  encodingServiceTags (serviceTag, encodeATag, spanConfig) {
24
25
  if (serviceTag !== spanConfig) {
25
26
  this.serviceTags[serviceTag] = spanConfig
@@ -1,6 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  module.exports = {
4
+ get '@apollo/gateway' () { return require('../../../datadog-plugin-apollo/src') },
4
5
  get '@aws-sdk/smithy-client' () { return require('../../../datadog-plugin-aws-sdk/src') },
5
6
  get '@cucumber/cucumber' () { return require('../../../datadog-plugin-cucumber/src') },
6
7
  get '@playwright/test' () { return require('../../../datadog-plugin-playwright/src') },
@@ -17,66 +18,66 @@ module.exports = {
17
18
  get '@opensearch-project/opensearch' () { return require('../../../datadog-plugin-opensearch/src') },
18
19
  get '@redis/client' () { return require('../../../datadog-plugin-redis/src') },
19
20
  get '@smithy/smithy-client' () { return require('../../../datadog-plugin-aws-sdk/src') },
20
- get 'aerospike' () { return require('../../../datadog-plugin-aerospike/src') },
21
- get 'amqp10' () { return require('../../../datadog-plugin-amqp10/src') },
22
- get 'amqplib' () { return require('../../../datadog-plugin-amqplib/src') },
21
+ get aerospike () { return require('../../../datadog-plugin-aerospike/src') },
22
+ get amqp10 () { return require('../../../datadog-plugin-amqp10/src') },
23
+ get amqplib () { return require('../../../datadog-plugin-amqplib/src') },
23
24
  get 'aws-sdk' () { return require('../../../datadog-plugin-aws-sdk/src') },
24
- get 'bunyan' () { return require('../../../datadog-plugin-bunyan/src') },
25
+ get bunyan () { return require('../../../datadog-plugin-bunyan/src') },
25
26
  get 'cassandra-driver' () { return require('../../../datadog-plugin-cassandra-driver/src') },
26
- get 'child_process' () { return require('../../../datadog-plugin-child_process/src') },
27
- get 'connect' () { return require('../../../datadog-plugin-connect/src') },
28
- get 'couchbase' () { return require('../../../datadog-plugin-couchbase/src') },
29
- get 'cypress' () { return require('../../../datadog-plugin-cypress/src') },
30
- get 'dns' () { return require('../../../datadog-plugin-dns/src') },
31
- get 'elasticsearch' () { return require('../../../datadog-plugin-elasticsearch/src') },
32
- get 'express' () { return require('../../../datadog-plugin-express/src') },
33
- get 'fastify' () { return require('../../../datadog-plugin-fastify/src') },
27
+ get child_process () { return require('../../../datadog-plugin-child_process/src') },
28
+ get connect () { return require('../../../datadog-plugin-connect/src') },
29
+ get couchbase () { return require('../../../datadog-plugin-couchbase/src') },
30
+ get cypress () { return require('../../../datadog-plugin-cypress/src') },
31
+ get dns () { return require('../../../datadog-plugin-dns/src') },
32
+ get elasticsearch () { return require('../../../datadog-plugin-elasticsearch/src') },
33
+ get express () { return require('../../../datadog-plugin-express/src') },
34
+ get fastify () { return require('../../../datadog-plugin-fastify/src') },
34
35
  get 'find-my-way' () { return require('../../../datadog-plugin-find-my-way/src') },
35
- get 'graphql' () { return require('../../../datadog-plugin-graphql/src') },
36
- get 'grpc' () { return require('../../../datadog-plugin-grpc/src') },
37
- get 'hapi' () { return require('../../../datadog-plugin-hapi/src') },
38
- get 'http' () { return require('../../../datadog-plugin-http/src') },
39
- get 'http2' () { return require('../../../datadog-plugin-http2/src') },
40
- get 'https' () { return require('../../../datadog-plugin-http/src') },
41
- get 'ioredis' () { return require('../../../datadog-plugin-ioredis/src') },
36
+ get graphql () { return require('../../../datadog-plugin-graphql/src') },
37
+ get grpc () { return require('../../../datadog-plugin-grpc/src') },
38
+ get hapi () { return require('../../../datadog-plugin-hapi/src') },
39
+ get http () { return require('../../../datadog-plugin-http/src') },
40
+ get http2 () { return require('../../../datadog-plugin-http2/src') },
41
+ get https () { return require('../../../datadog-plugin-http/src') },
42
+ get ioredis () { return require('../../../datadog-plugin-ioredis/src') },
42
43
  get 'jest-circus' () { return require('../../../datadog-plugin-jest/src') },
43
44
  get 'jest-config' () { return require('../../../datadog-plugin-jest/src') },
44
45
  get 'jest-environment-node' () { return require('../../../datadog-plugin-jest/src') },
45
46
  get 'jest-environment-jsdom' () { return require('../../../datadog-plugin-jest/src') },
46
47
  get 'jest-jasmine2' () { return require('../../../datadog-plugin-jest/src') },
47
48
  get 'jest-worker' () { return require('../../../datadog-plugin-jest/src') },
48
- get 'koa' () { return require('../../../datadog-plugin-koa/src') },
49
+ get koa () { return require('../../../datadog-plugin-koa/src') },
49
50
  get 'koa-router' () { return require('../../../datadog-plugin-koa/src') },
50
- get 'kafkajs' () { return require('../../../datadog-plugin-kafkajs/src') },
51
- get 'mariadb' () { return require('../../../datadog-plugin-mariadb/src') },
52
- get 'memcached' () { return require('../../../datadog-plugin-memcached/src') },
51
+ get kafkajs () { return require('../../../datadog-plugin-kafkajs/src') },
52
+ get mariadb () { return require('../../../datadog-plugin-mariadb/src') },
53
+ get memcached () { return require('../../../datadog-plugin-memcached/src') },
53
54
  get 'microgateway-core' () { return require('../../../datadog-plugin-microgateway-core/src') },
54
- get 'mocha' () { return require('../../../datadog-plugin-mocha/src') },
55
+ get mocha () { return require('../../../datadog-plugin-mocha/src') },
55
56
  get 'mocha-each' () { return require('../../../datadog-plugin-mocha/src') },
56
- get 'moleculer' () { return require('../../../datadog-plugin-moleculer/src') },
57
- get 'mongodb' () { return require('../../../datadog-plugin-mongodb-core/src') },
57
+ get moleculer () { return require('../../../datadog-plugin-moleculer/src') },
58
+ get mongodb () { return require('../../../datadog-plugin-mongodb-core/src') },
58
59
  get 'mongodb-core' () { return require('../../../datadog-plugin-mongodb-core/src') },
59
- get 'mysql' () { return require('../../../datadog-plugin-mysql/src') },
60
- get 'mysql2' () { return require('../../../datadog-plugin-mysql2/src') },
61
- get 'net' () { return require('../../../datadog-plugin-net/src') },
62
- get 'next' () { return require('../../../datadog-plugin-next/src') },
60
+ get mysql () { return require('../../../datadog-plugin-mysql/src') },
61
+ get mysql2 () { return require('../../../datadog-plugin-mysql2/src') },
62
+ get net () { return require('../../../datadog-plugin-net/src') },
63
+ get next () { return require('../../../datadog-plugin-next/src') },
63
64
  get 'node:dns' () { return require('../../../datadog-plugin-dns/src') },
64
65
  get 'node:http' () { return require('../../../datadog-plugin-http/src') },
65
66
  get 'node:http2' () { return require('../../../datadog-plugin-http2/src') },
66
67
  get 'node:https' () { return require('../../../datadog-plugin-http/src') },
67
68
  get 'node:net' () { return require('../../../datadog-plugin-net/src') },
68
- get 'oracledb' () { return require('../../../datadog-plugin-oracledb/src') },
69
- get 'openai' () { return require('../../../datadog-plugin-openai/src') },
70
- get 'paperplane' () { return require('../../../datadog-plugin-paperplane/src') },
71
- get 'pg' () { return require('../../../datadog-plugin-pg/src') },
72
- get 'pino' () { return require('../../../datadog-plugin-pino/src') },
69
+ get oracledb () { return require('../../../datadog-plugin-oracledb/src') },
70
+ get openai () { return require('../../../datadog-plugin-openai/src') },
71
+ get paperplane () { return require('../../../datadog-plugin-paperplane/src') },
72
+ get pg () { return require('../../../datadog-plugin-pg/src') },
73
+ get pino () { return require('../../../datadog-plugin-pino/src') },
73
74
  get 'pino-pretty' () { return require('../../../datadog-plugin-pino/src') },
74
- get 'playwright' () { return require('../../../datadog-plugin-playwright/src') },
75
- get 'redis' () { return require('../../../datadog-plugin-redis/src') },
76
- get 'restify' () { return require('../../../datadog-plugin-restify/src') },
77
- get 'rhea' () { return require('../../../datadog-plugin-rhea/src') },
78
- get 'router' () { return require('../../../datadog-plugin-router/src') },
79
- get 'sharedb' () { return require('../../../datadog-plugin-sharedb/src') },
80
- get 'tedious' () { return require('../../../datadog-plugin-tedious/src') },
81
- get 'winston' () { return require('../../../datadog-plugin-winston/src') }
75
+ get playwright () { return require('../../../datadog-plugin-playwright/src') },
76
+ get redis () { return require('../../../datadog-plugin-redis/src') },
77
+ get restify () { return require('../../../datadog-plugin-restify/src') },
78
+ get rhea () { return require('../../../datadog-plugin-rhea/src') },
79
+ get router () { return require('../../../datadog-plugin-router/src') },
80
+ get sharedb () { return require('../../../datadog-plugin-sharedb/src') },
81
+ get tedious () { return require('../../../datadog-plugin-tedious/src') },
82
+ get winston () { return require('../../../datadog-plugin-winston/src') }
82
83
  }
@@ -84,7 +84,7 @@ module.exports = class Plugin {
84
84
 
85
85
  if (!store || !store.span) return
86
86
 
87
- if (!store.span._spanContext._tags['error']) {
87
+ if (!store.span._spanContext._tags.error) {
88
88
  store.span.setTag('error', error || 1)
89
89
  }
90
90
  }
@@ -4,7 +4,6 @@ const Plugin = require('./plugin')
4
4
  const { storage } = require('../../../datadog-core')
5
5
  const analyticsSampler = require('../analytics_sampler')
6
6
  const { COMPONENT } = require('../constants')
7
- const Nomenclature = require('../service-naming')
8
7
 
9
8
  class TracingPlugin extends Plugin {
10
9
  constructor (...args) {
@@ -29,7 +28,7 @@ class TracingPlugin extends Plugin {
29
28
  kind = this.constructor.kind
30
29
  } = opts
31
30
 
32
- return Nomenclature.serviceName(type, kind, id, opts)
31
+ return this._tracer._nomenclature.serviceName(type, kind, id, opts)
33
32
  }
34
33
 
35
34
  operationName (opts = {}) {
@@ -39,7 +38,7 @@ class TracingPlugin extends Plugin {
39
38
  kind = this.constructor.kind
40
39
  } = opts
41
40
 
42
- return Nomenclature.opName(type, kind, id, opts)
41
+ return this._tracer._nomenclature.opName(type, kind, id, opts)
43
42
  }
44
43
 
45
44
  configure (config) {
@@ -58,8 +57,12 @@ class TracingPlugin extends Plugin {
58
57
  this.activeSpan?.finish()
59
58
  }
60
59
 
61
- error (error) {
62
- this.addError(error)
60
+ error (ctxOrError) {
61
+ if (ctxOrError?.currentStore) {
62
+ ctxOrError.currentStore?.span.setTag('error', ctxOrError?.error)
63
+ return
64
+ }
65
+ this.addError(ctxOrError)
63
66
  }
64
67
 
65
68
  addTraceSubs () {
@@ -91,7 +94,7 @@ class TracingPlugin extends Plugin {
91
94
  }
92
95
 
93
96
  addError (error, span = this.activeSpan) {
94
- if (!span._spanContext._tags['error']) {
97
+ if (!span._spanContext._tags.error) {
95
98
  // Errors may be wrapped in a context.
96
99
  error = (error && error.error) || error
97
100
  span.setTag('error', error || 1)
@@ -288,7 +288,8 @@ function getTestSuitePath (testSuiteAbsolutePath, sourceRoot) {
288
288
  return sourceRoot
289
289
  }
290
290
  const testSuitePath = testSuiteAbsolutePath === sourceRoot
291
- ? testSuiteAbsolutePath : path.relative(sourceRoot, testSuiteAbsolutePath)
291
+ ? testSuiteAbsolutePath
292
+ : path.relative(sourceRoot, testSuiteAbsolutePath)
292
293
 
293
294
  return testSuitePath.replace(path.sep, '/')
294
295
  }
@@ -63,7 +63,7 @@ const web = {
63
63
  if (!span) return
64
64
 
65
65
  span.context()._name = `${name}.request`
66
- span.context()._tags['component'] = name
66
+ span.context()._tags.component = name
67
67
 
68
68
  web.setConfig(req, config)
69
69
  },
@@ -263,7 +263,7 @@ const web = {
263
263
  const context = contexts.get(req)
264
264
  const span = context.span
265
265
  const error = context.error
266
- const hasExistingError = span.context()._tags['error'] || span.context()._tags[ERROR_MESSAGE]
266
+ const hasExistingError = span.context()._tags.error || span.context()._tags[ERROR_MESSAGE]
267
267
 
268
268
  if (!hasExistingError && !context.config.validateStatus(statusCode)) {
269
269
  span.setTag(ERROR, error || true)
@@ -405,7 +405,7 @@ function addAllowHeaders (req, res, headers) {
405
405
  }
406
406
 
407
407
  function isOriginAllowed (req, headers) {
408
- const origin = req.headers['origin']
408
+ const origin = req.headers.origin
409
409
  const allowOrigin = headers['access-control-allow-origin']
410
410
 
411
411
  return origin && (allowOrigin === '*' || allowOrigin === origin)
@@ -498,7 +498,7 @@ function extractURL (req) {
498
498
  return `${headers[HTTP2_HEADER_SCHEME]}://${headers[HTTP2_HEADER_AUTHORITY]}${headers[HTTP2_HEADER_PATH]}`
499
499
  } else {
500
500
  const protocol = getProtocol(req)
501
- return `${protocol}://${req.headers['host']}${req.originalUrl || req.url}`
501
+ return `${protocol}://${req.headers.host}${req.originalUrl || req.url}`
502
502
  }
503
503
  }
504
504
 
@@ -237,7 +237,7 @@ function ensureOOMExportStrategies (strategies, options) {
237
237
  }
238
238
  }
239
239
 
240
- return [ ...new Set(strategies) ]
240
+ return [...new Set(strategies)]
241
241
  }
242
242
 
243
243
  function getExporter (name, options) {
@@ -12,7 +12,7 @@ const mapping = {
12
12
 
13
13
  class ConsoleLogger {
14
14
  constructor (options = {}) {
15
- this._level = mapping[options.level] || mapping['error']
15
+ this._level = mapping[options.level] || mapping.error
16
16
  }
17
17
 
18
18
  debug (message) {