dd-trace 5.96.0 → 5.98.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 (173) hide show
  1. package/index.d.ts +60 -2
  2. package/package.json +9 -7
  3. package/packages/datadog-esbuild/index.js +20 -9
  4. package/packages/datadog-instrumentations/src/child_process.js +7 -17
  5. package/packages/datadog-instrumentations/src/crypto.js +1 -2
  6. package/packages/datadog-instrumentations/src/cucumber.js +69 -4
  7. package/packages/datadog-instrumentations/src/cypress-config.js +318 -0
  8. package/packages/datadog-instrumentations/src/cypress.js +86 -4
  9. package/packages/datadog-instrumentations/src/dns.js +1 -2
  10. package/packages/datadog-instrumentations/src/express.js +4 -4
  11. package/packages/datadog-instrumentations/src/fs.js +27 -29
  12. package/packages/datadog-instrumentations/src/graphql.js +1 -1
  13. package/packages/datadog-instrumentations/src/helpers/bundler-register.js +41 -13
  14. package/packages/datadog-instrumentations/src/helpers/hook.js +31 -6
  15. package/packages/datadog-instrumentations/src/helpers/hooks.js +12 -19
  16. package/packages/datadog-instrumentations/src/helpers/instrument.js +27 -13
  17. package/packages/datadog-instrumentations/src/helpers/register.js +103 -142
  18. package/packages/datadog-instrumentations/src/http/client.js +2 -3
  19. package/packages/datadog-instrumentations/src/http/server.js +2 -5
  20. package/packages/datadog-instrumentations/src/http2/client.js +1 -3
  21. package/packages/datadog-instrumentations/src/http2/server.js +1 -3
  22. package/packages/datadog-instrumentations/src/jest.js +117 -16
  23. package/packages/datadog-instrumentations/src/limitd-client.js +1 -1
  24. package/packages/datadog-instrumentations/src/mocha/utils.js +12 -1
  25. package/packages/datadog-instrumentations/src/net.js +2 -8
  26. package/packages/datadog-instrumentations/src/pino.js +1 -1
  27. package/packages/datadog-instrumentations/src/playwright.js +4 -1
  28. package/packages/datadog-instrumentations/src/prisma.js +1 -2
  29. package/packages/datadog-instrumentations/src/redis.js +12 -6
  30. package/packages/datadog-instrumentations/src/selenium.js +4 -1
  31. package/packages/datadog-instrumentations/src/sequelize.js +1 -1
  32. package/packages/datadog-instrumentations/src/url.js +1 -3
  33. package/packages/datadog-instrumentations/src/vitest.js +5 -1
  34. package/packages/datadog-instrumentations/src/vm.js +1 -3
  35. package/packages/datadog-plugin-aws-sdk/src/base.js +5 -4
  36. package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +1 -0
  37. package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +1 -0
  38. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +1 -0
  39. package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +1 -0
  40. package/packages/datadog-plugin-aws-sdk/src/services/sns.js +1 -0
  41. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +1 -0
  42. package/packages/datadog-plugin-cucumber/src/index.js +13 -3
  43. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +166 -6
  44. package/packages/datadog-plugin-cypress/src/index.js +59 -2
  45. package/packages/datadog-plugin-fs/src/index.js +1 -1
  46. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +2 -1
  47. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +2 -7
  48. package/packages/datadog-plugin-graphql/src/resolve.js +1 -1
  49. package/packages/datadog-plugin-http/src/client.js +1 -1
  50. package/packages/datadog-plugin-http/src/server.js +10 -2
  51. package/packages/datadog-plugin-http2/src/client.js +1 -1
  52. package/packages/datadog-plugin-http2/src/server.js +10 -2
  53. package/packages/datadog-plugin-jest/src/index.js +4 -2
  54. package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +31 -4
  55. package/packages/datadog-plugin-mocha/src/index.js +5 -2
  56. package/packages/datadog-plugin-mongodb-core/src/index.js +3 -3
  57. package/packages/datadog-plugin-mysql/src/index.js +1 -1
  58. package/packages/datadog-plugin-next/src/index.js +10 -16
  59. package/packages/datadog-plugin-openai/src/services.js +1 -0
  60. package/packages/datadog-plugin-pg/src/index.js +1 -1
  61. package/packages/datadog-plugin-tedious/src/index.js +1 -1
  62. package/packages/datadog-plugin-ws/src/close.js +1 -1
  63. package/packages/datadog-plugin-ws/src/receiver.js +1 -1
  64. package/packages/datadog-webpack/index.js +3 -3
  65. package/packages/dd-trace/index.js +12 -10
  66. package/packages/dd-trace/src/agent/url.js +2 -2
  67. package/packages/dd-trace/src/aiguard/sdk.js +26 -22
  68. package/packages/dd-trace/src/appsec/blocked_templates.js +4 -3
  69. package/packages/dd-trace/src/appsec/blocking.js +64 -33
  70. package/packages/dd-trace/src/appsec/iast/iast-plugin.js +1 -1
  71. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +1 -1
  72. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +1 -1
  73. package/packages/dd-trace/src/appsec/remote_config.js +1 -0
  74. package/packages/dd-trace/src/appsec/sdk/index.js +4 -0
  75. package/packages/dd-trace/src/appsec/sdk/set_user.js +1 -1
  76. package/packages/dd-trace/src/appsec/sdk/track_event.js +5 -5
  77. package/packages/dd-trace/src/appsec/sdk/user_blocking.js +2 -2
  78. package/packages/dd-trace/src/appsec/sdk/utils.js +4 -2
  79. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +6 -1
  80. package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +4 -0
  81. package/packages/dd-trace/src/config/defaults.js +315 -146
  82. package/packages/dd-trace/src/config/generated-config-types.d.ts +9 -1
  83. package/packages/dd-trace/src/config/helper.js +59 -10
  84. package/packages/dd-trace/src/config/index.js +587 -1496
  85. package/packages/dd-trace/src/config/parsers.js +256 -0
  86. package/packages/dd-trace/src/config/remote_config.js +59 -2
  87. package/packages/dd-trace/src/config/supported-configurations.json +406 -432
  88. package/packages/dd-trace/src/constants.js +1 -0
  89. package/packages/dd-trace/src/crashtracking/crashtracker.js +7 -1
  90. package/packages/dd-trace/src/crashtracking/index.js +1 -7
  91. package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +5 -2
  92. package/packages/dd-trace/src/debugger/index.js +1 -1
  93. package/packages/dd-trace/src/dogstatsd.js +12 -9
  94. package/packages/dd-trace/src/encode/0.4.js +8 -7
  95. package/packages/dd-trace/src/encode/span-stats.js +4 -1
  96. package/packages/dd-trace/src/exporters/agent/writer.js +7 -1
  97. package/packages/dd-trace/src/exporters/common/request.js +9 -0
  98. package/packages/dd-trace/src/exporters/common/writer.js +12 -2
  99. package/packages/dd-trace/src/heap_snapshots.js +3 -0
  100. package/packages/dd-trace/src/index.js +5 -2
  101. package/packages/dd-trace/src/lambda/runtime/ritm.js +6 -6
  102. package/packages/dd-trace/src/llmobs/index.js +4 -1
  103. package/packages/dd-trace/src/llmobs/plugins/ai/index.js +5 -1
  104. package/packages/dd-trace/src/llmobs/plugins/ai/util.js +60 -12
  105. package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +4 -2
  106. package/packages/dd-trace/src/llmobs/sdk.js +12 -8
  107. package/packages/dd-trace/src/llmobs/span_processor.js +1 -1
  108. package/packages/dd-trace/src/llmobs/tagger.js +9 -6
  109. package/packages/dd-trace/src/llmobs/writers/base.js +2 -0
  110. package/packages/dd-trace/src/llmobs/writers/util.js +3 -0
  111. package/packages/dd-trace/src/log/index.js +20 -59
  112. package/packages/dd-trace/src/log/writer.js +7 -19
  113. package/packages/dd-trace/src/noop/proxy.js +8 -0
  114. package/packages/dd-trace/src/openfeature/remote_config.js +6 -1
  115. package/packages/dd-trace/src/opentelemetry/context_manager.js +6 -4
  116. package/packages/dd-trace/src/opentelemetry/logs/index.js +1 -1
  117. package/packages/dd-trace/src/opentelemetry/metrics/index.js +1 -1
  118. package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +17 -2
  119. package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +14 -2
  120. package/packages/dd-trace/src/opentelemetry/otlp/trace.proto +358 -0
  121. package/packages/dd-trace/src/opentelemetry/otlp/trace_service.proto +78 -0
  122. package/packages/dd-trace/src/opentelemetry/trace/index.js +75 -0
  123. package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +66 -0
  124. package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +332 -0
  125. package/packages/dd-trace/src/opentracing/propagation/text_map.js +9 -4
  126. package/packages/dd-trace/src/opentracing/tracer.js +9 -4
  127. package/packages/dd-trace/src/payload-tagging/config/index.js +6 -5
  128. package/packages/dd-trace/src/plugin_manager.js +8 -6
  129. package/packages/dd-trace/src/plugins/ci_plugin.js +4 -0
  130. package/packages/dd-trace/src/plugins/log_plugin.js +3 -0
  131. package/packages/dd-trace/src/plugins/plugin.js +11 -13
  132. package/packages/dd-trace/src/plugins/storage.js +2 -2
  133. package/packages/dd-trace/src/plugins/tracing.js +22 -5
  134. package/packages/dd-trace/src/plugins/util/test.js +2 -0
  135. package/packages/dd-trace/src/plugins/util/web.js +6 -88
  136. package/packages/dd-trace/src/process-tags/index.js +3 -0
  137. package/packages/dd-trace/src/profiler.js +27 -2
  138. package/packages/dd-trace/src/profiling/config.js +73 -241
  139. package/packages/dd-trace/src/profiling/exporter_cli.js +1 -4
  140. package/packages/dd-trace/src/profiling/exporters/event_serializer.js +6 -2
  141. package/packages/dd-trace/src/profiling/profiler.js +78 -109
  142. package/packages/dd-trace/src/profiling/profilers/events.js +2 -3
  143. package/packages/dd-trace/src/profiling/profilers/wall.js +89 -6
  144. package/packages/dd-trace/src/profiling/ssi-heuristics.js +4 -1
  145. package/packages/dd-trace/src/propagation-hash/index.js +2 -1
  146. package/packages/dd-trace/src/proxy.js +40 -6
  147. package/packages/dd-trace/src/remote_config/index.js +3 -0
  148. package/packages/dd-trace/src/require-package-json.js +8 -4
  149. package/packages/dd-trace/src/ritm.js +58 -26
  150. package/packages/dd-trace/src/runtime_metrics/index.js +3 -0
  151. package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +18 -11
  152. package/packages/dd-trace/src/sampler.js +1 -1
  153. package/packages/dd-trace/src/service-naming/index.js +1 -1
  154. package/packages/dd-trace/src/service-naming/schemas/definition.js +4 -1
  155. package/packages/dd-trace/src/service-naming/schemas/util.js +15 -1
  156. package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +24 -1
  157. package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +60 -0
  158. package/packages/dd-trace/src/service-naming/schemas/v0/web.js +17 -1
  159. package/packages/dd-trace/src/service-naming/schemas/v0/websocket.js +5 -0
  160. package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +17 -0
  161. package/packages/dd-trace/src/service-naming/schemas/v1/web.js +11 -1
  162. package/packages/dd-trace/src/service-naming/schemas/v1/websocket.js +6 -0
  163. package/packages/dd-trace/src/span_stats.js +5 -1
  164. package/packages/dd-trace/src/standalone/index.js +3 -0
  165. package/packages/dd-trace/src/telemetry/index.js +2 -3
  166. package/packages/dd-trace/src/telemetry/send-data.js +5 -19
  167. package/packages/dd-trace/src/telemetry/session-propagation.js +19 -44
  168. package/packages/dd-trace/src/telemetry/telemetry.js +28 -171
  169. package/packages/dd-trace/src/tracer.js +2 -2
  170. package/packages/dd-trace/src/util.js +0 -9
  171. package/vendor/dist/@apm-js-collab/code-transformer/index.js +28 -6
  172. package/vendor/dist/protobufjs/index.js +1 -1
  173. package/packages/dd-trace/src/log/utils.js +0 -16
@@ -22,19 +22,44 @@ let patchedRequire = null
22
22
  const moduleLoadStartChannel = dc.channel('dd-trace:moduleLoadStart')
23
23
  const moduleLoadEndChannel = dc.channel('dd-trace:moduleLoadEnd')
24
24
 
25
+ function stripNodePrefix (name) {
26
+ if (typeof name !== 'string') return name
27
+ return name.startsWith('node:') ? name.slice(5) : name
28
+ }
29
+
30
+ const builtinModules = new Set(Module.builtinModules.map(stripNodePrefix))
31
+
32
+ function isBuiltinModuleName (name) {
33
+ if (typeof name !== 'string') return false
34
+ return builtinModules.has(stripNodePrefix(name))
35
+ }
36
+
37
+ function normalizeModuleName (name) {
38
+ if (typeof name !== 'string') return name
39
+ const stripped = stripNodePrefix(name)
40
+ return builtinModules.has(stripped) ? stripped : name
41
+ }
42
+
43
+ /**
44
+ * @overload
45
+ * @param {string[]} modules list of modules to hook into
46
+ * @param {object} options hook options
47
+ * @param {Function} onrequire callback to be executed upon encountering module
48
+ */
49
+ /**
50
+ * @overload
51
+ * @param {string[]} modules list of modules to hook into
52
+ * @param {Function} onrequire callback to be executed upon encountering module
53
+ */
25
54
  function Hook (modules, options, onrequire) {
26
55
  if (!(this instanceof Hook)) return new Hook(modules, options, onrequire)
27
- if (typeof modules === 'function') {
28
- onrequire = modules
29
- modules = null
30
- options = {}
31
- } else if (typeof options === 'function') {
56
+ if (typeof options === 'function') {
32
57
  onrequire = options
33
58
  options = {}
34
59
  }
35
60
 
36
- modules = modules || []
37
- options = options || {}
61
+ modules ??= []
62
+ options ??= {}
38
63
 
39
64
  this.modules = modules
40
65
  this.options = options
@@ -63,32 +88,34 @@ function Hook (modules, options, onrequire) {
63
88
  */
64
89
  let filename
65
90
  try {
66
- // @ts-expect-error Module._resolveFilename is not typed
91
+ // @ts-expect-error - Module._resolveFilename is not typed
67
92
  filename = Module._resolveFilename(request, this)
68
93
  } catch {
69
94
  return _origRequire.apply(this, arguments)
70
95
  }
71
- const core = !filename.includes(path.sep)
96
+
97
+ const builtin = isBuiltinModuleName(filename)
98
+ const moduleId = builtin ? normalizeModuleName(filename) : filename
72
99
  let name, basedir, hooks
73
100
  // return known patched modules immediately
74
- if (cache[filename]) {
75
- const externalCacheEntry = require.cache[filename]
101
+ if (cache[moduleId]) {
76
102
  // require.cache was potentially altered externally
77
- if (externalCacheEntry && externalCacheEntry.exports !== cache[filename].original) {
78
- return externalCacheEntry.exports
103
+ const cacheEntry = require.cache[filename]
104
+ if (cacheEntry && cacheEntry.exports !== cache[filename].original) {
105
+ return cacheEntry.exports
79
106
  }
80
107
 
81
- return cache[filename].exports
108
+ return cache[moduleId].exports
82
109
  }
83
110
 
84
111
  // Check if this module has a patcher in-progress already.
85
112
  // Otherwise, mark this module as patching in-progress.
86
- const patched = patching[filename]
113
+ const patched = patching[moduleId]
87
114
  if (patched) {
88
115
  // If it's already patched, just return it as-is.
89
116
  return origRequire.apply(this, arguments)
90
117
  }
91
- patching[filename] = true
118
+ patching[moduleId] = true
92
119
 
93
120
  const payload = {
94
121
  filename,
@@ -107,12 +134,12 @@ function Hook (modules, options, onrequire) {
107
134
 
108
135
  // The module has already been loaded,
109
136
  // so the patching mark can be cleaned up.
110
- delete patching[filename]
137
+ delete patching[moduleId]
111
138
 
112
- if (core) {
113
- hooks = moduleHooks[filename]
139
+ if (builtin) {
140
+ hooks = moduleHooks[moduleId]
114
141
  if (!hooks) return exports // abort if module name isn't on whitelist
115
- name = filename
142
+ name = moduleId
116
143
  } else {
117
144
  const inAWSLambda = getEnvironmentVariable('AWS_LAMBDA_FUNCTION_NAME') !== undefined
118
145
  const hasLambdaHandler = getValueFromEnvSources('DD_LAMBDA_HANDLER') !== undefined
@@ -129,7 +156,8 @@ function Hook (modules, options, onrequire) {
129
156
  hooks = moduleHooks[name]
130
157
  if (!hooks) return exports // abort if module name isn't on whitelist
131
158
 
132
- // @ts-expect-error Module._resolveLookupPaths is not typed
159
+ // figure out if this is the main module file, or a file inside the module
160
+ // @ts-expect-error - Module._resolveLookupPaths is meant to be internal and is not typed
133
161
  const paths = Module._resolveLookupPaths(name, this, true)
134
162
  if (!paths) {
135
163
  // abort if _resolveLookupPaths return null
@@ -138,7 +166,7 @@ function Hook (modules, options, onrequire) {
138
166
 
139
167
  let res
140
168
  try {
141
- // @ts-expect-error Module._findPath is not typed
169
+ // @ts-expect-error - Module._findPath is meant to be internal and is not typed
142
170
  res = Module._findPath(name, [basedir, ...paths])
143
171
  } catch {
144
172
  // case where the file specified in package.json "main" doesn't exist
@@ -163,17 +191,21 @@ function Hook (modules, options, onrequire) {
163
191
 
164
192
  // ensure that the cache entry is assigned a value before calling
165
193
  // onrequire, in case calling onrequire requires the same module.
166
- cache[filename] = { exports }
167
- cache[filename].original = exports
194
+ cache[moduleId] = { exports }
195
+ cache[moduleId].original = exports
168
196
 
169
197
  for (const hook of hooks) {
170
- cache[filename].exports = hook(cache[filename].exports, name, basedir)
198
+ cache[moduleId].exports = hook(cache[moduleId].exports, name, basedir)
171
199
  }
172
200
 
173
- return cache[filename].exports
201
+ return cache[moduleId].exports
174
202
  }
175
203
  }
176
204
 
205
+ /**
206
+ * Reset the Ritm hook. This is used to reset the hook after a test.
207
+ * TODO: Remove this and instead use proxyquire to reset the hook.
208
+ */
177
209
  Hook.reset = function () {
178
210
  Module.prototype.require = origRequire
179
211
  patchedRequire = null
@@ -14,6 +14,9 @@ const noop = runtimeMetrics = {
14
14
  }
15
15
 
16
16
  module.exports = {
17
+ /**
18
+ * @param {import('../config/config-base')} config - Tracer configuration
19
+ */
17
20
  start (config) {
18
21
  if (!config?.runtimeMetrics.enabled) return
19
22
 
@@ -35,6 +35,9 @@ let eventLoopDelayObserver = null
35
35
  // https://github.com/DataDog/dogweb/blob/prod/integration/node/node_metadata.csv
36
36
 
37
37
  module.exports = {
38
+ /**
39
+ * @param {import('../config/config-base')} config - Tracer configuration
40
+ */
38
41
  start (config) {
39
42
  this.stop()
40
43
  const clientConfig = DogStatsDClient.generateClientConfig(config)
@@ -52,17 +55,21 @@ module.exports = {
52
55
  startGCObserver()
53
56
  }
54
57
 
55
- // Using no-gc prevents the native gc metrics from being tracked. Not
56
- // passing any options means all metrics are tracked.
57
- // TODO: This is a workaround. We should find a better solution.
58
- const watchers = trackEventLoop ? ['loop'] : ['no-gc']
59
-
60
- try {
61
- nativeMetrics = require('@datadog/native-metrics')
62
- nativeMetrics.start(...watchers)
63
- } catch (error) {
64
- log.error('Error starting native metrics', error)
65
- nativeMetrics = null
58
+ const useNative = config.runtimeMetrics.native !== false
59
+
60
+ if (useNative) {
61
+ // Using no-gc prevents the native gc metrics from being tracked. Not
62
+ // passing any options means all metrics are tracked.
63
+ // TODO: This is a workaround. We should find a better solution.
64
+ const watchers = trackEventLoop ? ['loop'] : ['no-gc']
65
+
66
+ try {
67
+ nativeMetrics = require('@datadog/native-metrics')
68
+ nativeMetrics.start(...watchers)
69
+ } catch (error) {
70
+ log.error('Error starting native metrics', error)
71
+ nativeMetrics = null
72
+ }
66
73
  }
67
74
 
68
75
  client = new MetricsAggregationClient(new DogStatsDClient(clientConfig))
@@ -42,7 +42,7 @@ class Sampler {
42
42
  /**
43
43
  * Determines whether a trace/span should be sampled based on the configured sampling rate.
44
44
  *
45
- * @param {Span|SpanContext} span - The span or span context to evaluate.
45
+ * @param {import("../../..").Span|import("../../..").SpanContext} span - The span or span context to evaluate.
46
46
  * @returns {boolean} `true` if the trace/span should be sampled, otherwise `false`.
47
47
  */
48
48
  isSampled (span) {
@@ -41,7 +41,7 @@ class SchemaManager {
41
41
  * @param {string} kind
42
42
  * @param {string} plugin
43
43
  * @param {object} opts
44
- * @returns {string}
44
+ * @returns {object} {name, source}
45
45
  */
46
46
  serviceName (type, kind, plugin, opts) {
47
47
  const schema = this.shouldUseConsistentServiceNaming
@@ -12,7 +12,10 @@ class SchemaDefinition {
12
12
 
13
13
  getServiceName (type, kind, plugin, opts) {
14
14
  const item = this.schema[type][kind][plugin]
15
- return item.serviceName(opts)
15
+ return {
16
+ name: item.serviceName(opts),
17
+ source: item.serviceSource?.(opts),
18
+ }
16
19
  }
17
20
  }
18
21
 
@@ -18,8 +18,22 @@ function httpPluginClientService ({ tracerService, pluginConfig, sessionDetails
18
18
  return tracerService
19
19
  }
20
20
 
21
+ function optionServiceSource ({ pluginConfig }) {
22
+ if (pluginConfig.splitByDomain) {
23
+ return 'opt.split_by_domain'
24
+ }
25
+
26
+ if (pluginConfig.service) {
27
+ return 'opt.plugin'
28
+ }
29
+ }
30
+
21
31
  function awsServiceV0 ({ tracerService, awsService }) {
22
32
  return `${tracerService}-aws-${awsService}`
23
33
  }
24
34
 
25
- module.exports = { identityService, httpPluginClientService, awsServiceV0 }
35
+ function awsServiceSource ({ awsService }) {
36
+ return awsService
37
+ }
38
+
39
+ module.exports = { identityService, httpPluginClientService, awsServiceV0, optionServiceSource, awsServiceSource }
@@ -1,66 +1,83 @@
1
1
  'use strict'
2
2
 
3
- const { identityService, awsServiceV0 } = require('../util')
3
+ const { identityService, awsServiceV0, awsServiceSource } = require('../util')
4
4
 
5
5
  function amqpServiceName ({ tracerService }) {
6
6
  return `${tracerService}-amqp`
7
7
  }
8
8
 
9
+ function integrationSource (source) {
10
+ return () => source
11
+ }
12
+
9
13
  const messaging = {
10
14
  producer: {
11
15
  amqplib: {
12
16
  opName: () => 'amqp.command',
13
17
  serviceName: amqpServiceName,
18
+ serviceSource: integrationSource('amqp'),
14
19
  },
15
20
  amqp10: {
16
21
  opName: () => 'amqp.send',
17
22
  serviceName: amqpServiceName,
23
+ serviceSource: integrationSource('amqp'),
18
24
  },
19
25
  'azure-event-hubs': {
20
26
  opName: () => 'azure.eventhubs.send',
21
27
  serviceName: ({ tracerService }) => `${tracerService}-azure-event-hubs`,
28
+ serviceSource: integrationSource('azure-event-hubs'),
22
29
  },
23
30
  'azure-service-bus': {
24
31
  opName: () => 'azure.servicebus.send',
25
32
  serviceName: ({ tracerService }) => `${tracerService}-azure-service-bus`,
33
+ serviceSource: integrationSource('azure-service-bus'),
26
34
  },
27
35
  'google-cloud-pubsub': {
28
36
  opName: () => 'pubsub.request',
29
37
  serviceName: ({ tracerService }) => `${tracerService}-pubsub`,
38
+ serviceSource: integrationSource('google-cloud-pubsub'),
30
39
  },
31
40
  kafkajs: {
32
41
  opName: () => 'kafka.produce',
33
42
  serviceName: ({ tracerService }) => `${tracerService}-kafka`,
43
+ serviceSource: integrationSource('kafka'),
34
44
  },
35
45
  'confluentinc-kafka-javascript': {
36
46
  opName: () => 'kafka.produce',
37
47
  serviceName: ({ tracerService }) => `${tracerService}-kafka`,
48
+ serviceSource: integrationSource('kafka'),
38
49
  },
39
50
  rhea: {
40
51
  opName: () => 'amqp.send',
41
52
  serviceName: ({ tracerService }) => `${tracerService}-amqp-producer`,
53
+ serviceSource: integrationSource('amqp'),
42
54
  },
43
55
  sqs: {
44
56
  opName: () => 'aws.request',
45
57
  serviceName: awsServiceV0,
58
+ serviceSource: awsServiceSource,
46
59
  },
47
60
  sns: {
48
61
  opName: () => 'aws.request',
49
62
  serviceName: awsServiceV0,
63
+ serviceSource: awsServiceSource,
50
64
  },
51
65
  bullmq: {
52
66
  opName: () => 'bullmq.add',
53
67
  serviceName: ({ tracerService }) => `${tracerService}-bullmq`,
68
+ serviceSource: integrationSource('bullmq'),
54
69
  },
55
70
  },
56
71
  consumer: {
57
72
  amqplib: {
58
73
  opName: () => 'amqp.command',
59
74
  serviceName: amqpServiceName,
75
+ serviceSource: integrationSource('amqp'),
60
76
  },
61
77
  amqp10: {
62
78
  opName: () => 'amqp.receive',
63
79
  serviceName: amqpServiceName,
80
+ serviceSource: integrationSource('amqp'),
64
81
  },
65
82
  'google-cloud-pubsub': {
66
83
  opName: () => 'pubsub.receive',
@@ -69,10 +86,12 @@ const messaging = {
69
86
  kafkajs: {
70
87
  opName: () => 'kafka.consume',
71
88
  serviceName: ({ tracerService }) => `${tracerService}-kafka`,
89
+ serviceSource: integrationSource('kafka'),
72
90
  },
73
91
  'confluentinc-kafka-javascript': {
74
92
  opName: () => 'kafka.consume',
75
93
  serviceName: ({ tracerService }) => `${tracerService}-kafka`,
94
+ serviceSource: integrationSource('kafka'),
76
95
  },
77
96
  rhea: {
78
97
  opName: () => 'amqp.receive',
@@ -81,20 +100,24 @@ const messaging = {
81
100
  sqs: {
82
101
  opName: () => 'aws.request',
83
102
  serviceName: awsServiceV0,
103
+ serviceSource: awsServiceSource,
84
104
  },
85
105
  bullmq: {
86
106
  opName: () => 'bullmq.processJob',
87
107
  serviceName: ({ tracerService }) => `${tracerService}-bullmq`,
108
+ serviceSource: integrationSource('bullmq'),
88
109
  },
89
110
  },
90
111
  client: {
91
112
  amqplib: {
92
113
  opName: () => 'amqp.command',
93
114
  serviceName: amqpServiceName,
115
+ serviceSource: integrationSource('amqp'),
94
116
  },
95
117
  'google-cloud-pubsub': {
96
118
  opName: () => 'pubsub.request',
97
119
  serviceName: ({ tracerService }) => `${tracerService}-pubsub`,
120
+ serviceSource: integrationSource('google-cloud-pubsub'),
98
121
  },
99
122
  },
100
123
  }
@@ -30,11 +30,26 @@ function withSuffixFunction (suffix) {
30
30
  }
31
31
  }
32
32
 
33
+ function optionServiceSource ({ pluginConfig, integration, connectionName }) {
34
+ if (pluginConfig.splitByInstance && connectionName) {
35
+ return 'opt.split_by_instance'
36
+ }
37
+
38
+ if (pluginConfig.service) {
39
+ return 'opt.plugin'
40
+ }
41
+
42
+ return integration
43
+ }
44
+
33
45
  const redisConfig = {
34
46
  opName: () => 'redis.command',
35
47
  serviceName: ({ tracerService, pluginConfig, system, connectionName }) => {
36
48
  return getRedisService(pluginConfig, connectionName) || fromSystem(tracerService, system)
37
49
  },
50
+ serviceSource: ({ tracerService, pluginConfig, connectionName }) => {
51
+ return optionServiceSource({ tracerService, pluginConfig, connectionName, integration: 'redis' })
52
+ },
38
53
  }
39
54
 
40
55
  const valkeyConfig = {
@@ -42,6 +57,9 @@ const valkeyConfig = {
42
57
  serviceName: ({ tracerService, pluginConfig, system, connectionName }) => {
43
58
  return getRedisService(pluginConfig, connectionName) || fromSystem(tracerService, system)
44
59
  },
60
+ serviceSource: ({ tracerService, pluginConfig, connectionName }) => {
61
+ return optionServiceSource({ tracerService, pluginConfig, connectionName, integration: 'valkey' })
62
+ },
45
63
  }
46
64
 
47
65
  const storage = {
@@ -50,67 +68,109 @@ const storage = {
50
68
  opName: () => 'aerospike.command',
51
69
  serviceName: ({ tracerService, pluginConfig }) =>
52
70
  pluginConfig.service || `${tracerService}-aerospike`,
71
+ serviceSource: ({ tracerService, pluginConfig, connectionName }) => {
72
+ return optionServiceSource({ tracerService, pluginConfig, connectionName, integration: 'aerospike' })
73
+ },
53
74
  },
54
75
  'cassandra-driver': {
55
76
  opName: () => 'cassandra.query',
56
77
  serviceName: ({ tracerService, pluginConfig, system }) =>
57
78
  pluginConfig.service || fromSystem(tracerService, system),
79
+ serviceSource: ({ tracerService, pluginConfig, connectionName }) => {
80
+ return optionServiceSource({ tracerService, pluginConfig, connectionName, integration: 'cassandra-driver' })
81
+ },
58
82
  },
59
83
  couchbase: {
60
84
  opName: ({ operation }) => `couchbase.${operation}`,
61
85
  serviceName: ({ tracerService, pluginConfig }) => pluginConfig.service || `${tracerService}-couchbase`,
86
+ serviceSource: ({ tracerService, pluginConfig, connectionName }) => {
87
+ return optionServiceSource({ tracerService, pluginConfig, connectionName, integration: 'couchbase' })
88
+ },
62
89
  },
63
90
  elasticsearch: {
64
91
  opName: () => 'elasticsearch.query',
65
92
  serviceName: ({ tracerService, pluginConfig }) =>
66
93
  pluginConfig.service || `${tracerService}-elasticsearch`,
94
+ serviceSource: ({ tracerService, pluginConfig, connectionName }) => {
95
+ return optionServiceSource({ tracerService, pluginConfig, connectionName, integration: 'elasticsearch' })
96
+ },
67
97
  },
68
98
  ioredis: redisConfig,
69
99
  iovalkey: valkeyConfig,
70
100
  mariadb: {
71
101
  opName: () => 'mariadb.query',
72
102
  serviceName: mysqlServiceName,
103
+ serviceSource: ({ tracerService, pluginConfig, connectionName }) => {
104
+ return optionServiceSource({ tracerService, pluginConfig, connectionName, integration: 'mysql' })
105
+ },
73
106
  },
74
107
  memcached: {
75
108
  opName: () => 'memcached.command',
76
109
  serviceName: ({ tracerService, pluginConfig, system }) =>
77
110
  pluginConfig.service || fromSystem(tracerService, system),
111
+ serviceSource: ({ tracerService, pluginConfig, connectionName }) => {
112
+ return optionServiceSource({ tracerService, pluginConfig, connectionName, integration: 'memcached' })
113
+ },
78
114
  },
79
115
  'mongodb-core': {
80
116
  opName: () => 'mongodb.query',
81
117
  serviceName: ({ tracerService, pluginConfig }) =>
82
118
  pluginConfig.service || `${tracerService}-mongodb`,
119
+ serviceSource: ({ tracerService, pluginConfig, connectionName }) => {
120
+ return optionServiceSource({ tracerService, pluginConfig, connectionName, integration: 'mongodb' })
121
+ },
83
122
  },
84
123
  mysql: {
85
124
  opName: () => 'mysql.query',
86
125
  serviceName: mysqlServiceName,
126
+ serviceSource: ({ tracerService, pluginConfig, connectionName }) => {
127
+ return optionServiceSource({ tracerService, pluginConfig, connectionName, integration: 'mysql' })
128
+ },
87
129
  },
88
130
  mysql2: {
89
131
  opName: () => 'mysql.query',
90
132
  serviceName: mysqlServiceName,
133
+ serviceSource: ({ tracerService, pluginConfig, connectionName }) => {
134
+ return optionServiceSource({ tracerService, pluginConfig, connectionName, integration: 'mysql' })
135
+ },
91
136
  },
92
137
  opensearch: {
93
138
  opName: () => 'opensearch.query',
94
139
  serviceName: ({ tracerService, pluginConfig }) =>
95
140
  pluginConfig.service || `${tracerService}-opensearch`,
141
+ serviceSource: ({ tracerService, pluginConfig, connectionName }) => {
142
+ return optionServiceSource({ tracerService, pluginConfig, connectionName, integration: 'opensearch' })
143
+ },
96
144
  },
97
145
  oracledb: {
98
146
  opName: () => 'oracle.query',
99
147
  serviceName: withSuffixFunction('oracle'),
148
+ serviceSource: ({ tracerService, pluginConfig, connectionName }) => {
149
+ return optionServiceSource({ tracerService, pluginConfig, connectionName, integration: 'oracledb' })
150
+ },
100
151
  },
101
152
  pg: {
102
153
  opName: () => 'pg.query',
103
154
  serviceName: withSuffixFunction('postgres'),
155
+ serviceSource: ({ tracerService, pluginConfig, connectionName }) => {
156
+ return optionServiceSource({ tracerService, pluginConfig, connectionName, integration: 'pg' })
157
+ },
104
158
  },
105
159
  prisma: {
106
160
  opName: ({ operation }) => `prisma.${operation}`,
107
161
  serviceName: withSuffixFunction('prisma'),
162
+ serviceSource: ({ tracerService, pluginConfig, connectionName }) => {
163
+ return optionServiceSource({ tracerService, pluginConfig, connectionName, integration: 'prisma' })
164
+ },
108
165
  },
109
166
  redis: redisConfig,
110
167
  tedious: {
111
168
  opName: () => 'tedious.request',
112
169
  serviceName: ({ tracerService, pluginConfig, system }) =>
113
170
  pluginConfig.service || fromSystem(tracerService, system),
171
+ serviceSource: ({ tracerService, pluginConfig, connectionName }) => {
172
+ return optionServiceSource({ tracerService, pluginConfig, connectionName, integration: 'tedious' })
173
+ },
114
174
  },
115
175
  },
116
176
  }
@@ -1,6 +1,9 @@
1
1
  'use strict'
2
2
 
3
- const { identityService, httpPluginClientService, awsServiceV0 } = require('../util')
3
+ const {
4
+ identityService, httpPluginClientService, awsServiceV0,
5
+ optionServiceSource, awsServiceSource,
6
+ } = require('../util')
4
7
 
5
8
  const web = {
6
9
  client: {
@@ -15,56 +18,69 @@ const web = {
15
18
  http: {
16
19
  opName: () => 'http.request',
17
20
  serviceName: httpPluginClientService,
21
+ serviceSource: optionServiceSource,
18
22
  },
19
23
  fetch: {
20
24
  opName: () => 'http.request',
21
25
  serviceName: httpPluginClientService,
26
+ serviceSource: optionServiceSource,
22
27
  },
23
28
  http2: {
24
29
  opName: () => 'http.request',
25
30
  serviceName: httpPluginClientService,
31
+ serviceSource: optionServiceSource,
26
32
  },
27
33
  genai: {
28
34
  opName: () => 'google_genai.request',
29
35
  serviceName: ({ pluginConfig, tracerService }) => pluginConfig.service || tracerService,
36
+ serviceSource: optionServiceSource,
30
37
  },
31
38
  aws: {
32
39
  opName: () => 'aws.request',
33
40
  serviceName: awsServiceV0,
41
+ serviceSource: awsServiceSource,
34
42
  },
35
43
  lambda: {
36
44
  opName: () => 'aws.request',
37
45
  serviceName: awsServiceV0,
46
+ serviceSource: awsServiceSource,
38
47
  },
39
48
  undici: {
40
49
  opName: () => 'undici.request',
41
50
  serviceName: httpPluginClientService,
51
+ serviceSource: optionServiceSource,
42
52
  },
43
53
  },
44
54
  server: {
45
55
  'apollo.gateway.request': {
46
56
  opName: () => 'apollo.gateway.request',
47
57
  serviceName: ({ pluginConfig, tracerService }) => pluginConfig.service || tracerService,
58
+ serviceSource: optionServiceSource,
48
59
  },
49
60
  'apollo.gateway.plan': {
50
61
  opName: () => 'apollo.gateway.plan',
51
62
  serviceName: ({ pluginConfig, tracerService }) => pluginConfig.service || tracerService,
63
+ serviceSource: optionServiceSource,
52
64
  },
53
65
  'apollo.gateway.validate': {
54
66
  opName: () => 'apollo.gateway.validate',
55
67
  serviceName: ({ pluginConfig, tracerService }) => pluginConfig.service || tracerService,
68
+ serviceSource: optionServiceSource,
56
69
  },
57
70
  'apollo.gateway.execute': {
58
71
  opName: () => 'apollo.gateway.execute',
59
72
  serviceName: ({ pluginConfig, tracerService }) => pluginConfig.service || tracerService,
73
+ serviceSource: optionServiceSource,
60
74
  },
61
75
  'apollo.gateway.fetch': {
62
76
  opName: () => 'apollo.gateway.fetch',
63
77
  serviceName: ({ pluginConfig, tracerService }) => pluginConfig.service || tracerService,
78
+ serviceSource: optionServiceSource,
64
79
  },
65
80
  'apollo.gateway.postprocessing': {
66
81
  opName: () => 'apollo.gateway.postprocessing',
67
82
  serviceName: ({ pluginConfig, tracerService }) => pluginConfig.service || tracerService,
83
+ serviceSource: optionServiceSource,
68
84
  },
69
85
  grpc: {
70
86
  opName: () => 'grpc.server',
@@ -1,28 +1,33 @@
1
1
  'use strict'
2
+ const { optionServiceSource } = require('../util')
2
3
 
3
4
  const websocket = {
4
5
  request: {
5
6
  ws: {
6
7
  opName: () => 'web.request',
7
8
  serviceName: ({ pluginConfig, tracerService }) => pluginConfig.service || tracerService,
9
+ serviceSource: optionServiceSource,
8
10
  },
9
11
  },
10
12
  producer: {
11
13
  ws: {
12
14
  opName: () => 'websocket.send',
13
15
  serviceName: ({ pluginConfig, tracerService }) => pluginConfig.service || tracerService,
16
+ serviceSource: optionServiceSource,
14
17
  },
15
18
  },
16
19
  consumer: {
17
20
  ws: {
18
21
  opName: () => 'websocket.receive',
19
22
  serviceName: ({ pluginConfig, tracerService }) => pluginConfig.service || tracerService,
23
+ serviceSource: optionServiceSource,
20
24
  },
21
25
  },
22
26
  close: {
23
27
  ws: {
24
28
  opName: () => 'websocket.close',
25
29
  serviceName: ({ pluginConfig, tracerService }) => pluginConfig.service || tracerService,
30
+ serviceSource: optionServiceSource,
26
31
  },
27
32
  },
28
33
  }