dd-trace 4.8.1 → 4.10.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 (49) hide show
  1. package/CONTRIBUTING.md +66 -0
  2. package/MIGRATING.md +0 -14
  3. package/package.json +18 -18
  4. package/packages/datadog-esbuild/index.js +109 -31
  5. package/packages/datadog-instrumentations/index.js +1 -0
  6. package/packages/datadog-instrumentations/src/couchbase.js +41 -5
  7. package/packages/datadog-instrumentations/src/helpers/bundler-register.js +54 -0
  8. package/packages/datadog-instrumentations/src/helpers/hook.js +1 -4
  9. package/packages/datadog-instrumentations/src/helpers/hooks.js +4 -1
  10. package/packages/datadog-instrumentations/src/helpers/register.js +7 -2
  11. package/packages/datadog-instrumentations/src/jest.js +37 -1
  12. package/packages/datadog-plugin-aws-sdk/src/base.js +22 -10
  13. package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +16 -0
  14. package/packages/datadog-plugin-aws-sdk/src/services/sns.js +18 -0
  15. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +23 -0
  16. package/packages/datadog-plugin-cassandra-driver/src/index.js +1 -1
  17. package/packages/datadog-plugin-couchbase/src/index.js +32 -30
  18. package/packages/datadog-plugin-elasticsearch/src/index.js +1 -1
  19. package/packages/datadog-plugin-fetch/src/index.js +1 -0
  20. package/packages/datadog-plugin-http/src/client.js +7 -17
  21. package/packages/datadog-plugin-http/src/server.js +10 -2
  22. package/packages/datadog-plugin-http2/src/client.js +2 -16
  23. package/packages/datadog-plugin-http2/src/server.js +10 -1
  24. package/packages/datadog-plugin-memcached/src/index.js +1 -1
  25. package/packages/datadog-plugin-mongodb-core/src/index.js +2 -2
  26. package/packages/datadog-plugin-mysql/src/index.js +1 -1
  27. package/packages/datadog-plugin-next/src/index.js +2 -2
  28. package/packages/datadog-plugin-oracledb/src/index.js +1 -1
  29. package/packages/datadog-plugin-pg/src/index.js +1 -1
  30. package/packages/datadog-plugin-redis/src/index.js +1 -1
  31. package/packages/datadog-plugin-tedious/src/index.js +1 -1
  32. package/packages/dd-trace/src/appsec/iast/analyzers/weak-hash-analyzer.js +11 -7
  33. package/packages/dd-trace/src/appsec/passport.js +1 -1
  34. package/packages/dd-trace/src/config.js +7 -5
  35. package/packages/dd-trace/src/plugin_manager.js +6 -1
  36. package/packages/dd-trace/src/plugins/index.js +1 -0
  37. package/packages/dd-trace/src/plugins/tracing.js +16 -9
  38. package/packages/dd-trace/src/proxy.js +2 -2
  39. package/packages/dd-trace/src/serverless.js +51 -7
  40. package/packages/dd-trace/src/service-naming/index.js +7 -11
  41. package/packages/dd-trace/src/service-naming/schemas/definition.js +4 -4
  42. package/packages/dd-trace/src/service-naming/schemas/util.js +21 -3
  43. package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +20 -8
  44. package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +33 -23
  45. package/packages/dd-trace/src/service-naming/schemas/v0/web.js +33 -1
  46. package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +14 -2
  47. package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +12 -9
  48. package/packages/dd-trace/src/service-naming/schemas/v1/web.js +33 -1
  49. package/packages/dd-trace/src/dcitm.js +0 -53
@@ -10,6 +10,7 @@ module.exports = {
10
10
  get '@grpc/grpc-js' () { return require('../../../datadog-plugin-grpc/src') },
11
11
  get '@hapi/hapi' () { return require('../../../datadog-plugin-hapi/src') },
12
12
  get '@jest/core' () { return require('../../../datadog-plugin-jest/src') },
13
+ get '@jest/test-sequencer' () { return require('../../../datadog-plugin-jest/src') },
13
14
  get '@jest/transform' () { return require('../../../datadog-plugin-jest/src') },
14
15
  get '@koa/router' () { return require('../../../datadog-plugin-koa/src') },
15
16
  get '@node-redis/client' () { return require('../../../datadog-plugin-redis/src') },
@@ -22,17 +22,24 @@ class TracingPlugin extends Plugin {
22
22
  return store && store.span
23
23
  }
24
24
 
25
- serviceName (...serviceArgs) {
26
- if (Nomenclature.shouldUseConsistentServiceNaming) {
27
- return Nomenclature.shortCircuitServiceName(this.config, ...serviceArgs)
28
- }
29
- const { type, id, kind } = this.constructor
30
- return Nomenclature.serviceName(type, kind, id, ...serviceArgs)
25
+ serviceName (opts = {}) {
26
+ const {
27
+ type = this.constructor.type,
28
+ id = this.constructor.id,
29
+ kind = this.constructor.kind
30
+ } = opts
31
+
32
+ return Nomenclature.serviceName(type, kind, id, opts)
31
33
  }
32
34
 
33
- operationName (...opNameArgs) {
34
- const { type, id, kind } = this.constructor
35
- return Nomenclature.opName(type, kind, id, ...opNameArgs)
35
+ operationName (opts = {}) {
36
+ const {
37
+ type = this.constructor.type,
38
+ id = this.constructor.id,
39
+ kind = this.constructor.kind
40
+ } = opts
41
+
42
+ return Nomenclature.opName(type, kind, id, opts)
36
43
  }
37
44
 
38
45
  configure (config) {
@@ -30,8 +30,8 @@ class Tracer extends NoopProxy {
30
30
  remoteConfig.enable(config)
31
31
  }
32
32
 
33
- if (config.isGCPFunction) {
34
- require('./serverless').maybeStartServerlessMiniAgent()
33
+ if (config.isGCPFunction || config.isAzureFunctionConsumptionPlan) {
34
+ require('./serverless').maybeStartServerlessMiniAgent(config)
35
35
  }
36
36
 
37
37
  if (config.profiling.enabled) {
@@ -1,14 +1,19 @@
1
1
  'use strict'
2
2
 
3
- function maybeStartServerlessMiniAgent () {
4
- let rustBinaryPath =
5
- '/workspace/node_modules/@datadog/sma/datadog-serverless-agent-linux-amd64/datadog-serverless-trace-mini-agent'
6
- if (process.env.DD_MINI_AGENT_PATH !== undefined) {
7
- rustBinaryPath = process.env.DD_MINI_AGENT_PATH
3
+ const log = require('./log')
4
+
5
+ function maybeStartServerlessMiniAgent (config) {
6
+ if (process.platform !== 'win32' && process.platform !== 'linux') {
7
+ log.error(`Serverless Mini Agent is only supported on Windows and Linux.`)
8
+ return
8
9
  }
9
- const log = require('./log')
10
+
11
+ const rustBinaryPath = getRustBinaryPath(config)
12
+
10
13
  const fs = require('fs')
11
14
 
15
+ log.debug(`Trying to spawn the Serverless Mini Agent at path: ${rustBinaryPath}`)
16
+
12
17
  // trying to spawn with an invalid path will return a non-descriptive error, so we want to catch
13
18
  // invalid paths and log our own error.
14
19
  if (!fs.existsSync(rustBinaryPath)) {
@@ -22,4 +27,43 @@ function maybeStartServerlessMiniAgent () {
22
27
  }
23
28
  }
24
29
 
25
- module.exports = { maybeStartServerlessMiniAgent }
30
+ function getRustBinaryPath (config) {
31
+ if (process.env.DD_MINI_AGENT_PATH !== undefined) {
32
+ return process.env.DD_MINI_AGENT_PATH
33
+ }
34
+
35
+ const rustBinaryPathRoot = config.isGCPFunction ? '/workspace' : '/home/site/wwwroot'
36
+ const rustBinaryPathOsFolder = process.platform === 'win32'
37
+ ? 'datadog-serverless-agent-windows-amd64' : 'datadog-serverless-agent-linux-amd64'
38
+
39
+ const rustBinaryExtension = process.platform === 'win32' ? '.exe' : ''
40
+
41
+ const rustBinaryPath =
42
+ `${rustBinaryPathRoot}/node_modules/@datadog/sma/${rustBinaryPathOsFolder}/\
43
+ datadog-serverless-trace-mini-agent${rustBinaryExtension}`
44
+
45
+ return rustBinaryPath
46
+ }
47
+
48
+ function getIsGCPFunction () {
49
+ const isDeprecatedGCPFunction = process.env.FUNCTION_NAME !== undefined && process.env.GCP_PROJECT !== undefined
50
+ const isNewerGCPFunction = process.env.K_SERVICE !== undefined && process.env.FUNCTION_TARGET !== undefined
51
+
52
+ return isDeprecatedGCPFunction || isNewerGCPFunction
53
+ }
54
+
55
+ function getIsAzureFunctionConsumptionPlan () {
56
+ const isAzureFunction =
57
+ process.env.FUNCTIONS_EXTENSION_VERSION !== undefined && process.env.FUNCTIONS_WORKER_RUNTIME !== undefined
58
+ const azureWebsiteSKU = process.env.WEBSITE_SKU
59
+ const isConsumptionPlan = azureWebsiteSKU === undefined || azureWebsiteSKU === 'Dynamic'
60
+
61
+ return isAzureFunction && isConsumptionPlan
62
+ }
63
+
64
+ module.exports = {
65
+ maybeStartServerlessMiniAgent,
66
+ getIsGCPFunction,
67
+ getIsAzureFunctionConsumptionPlan,
68
+ getRustBinaryPath
69
+ }
@@ -18,20 +18,16 @@ class SchemaManager {
18
18
  return this.config.spanRemoveIntegrationFromService && this.version === 'v0'
19
19
  }
20
20
 
21
- opName (type, kind, plugin, ...opNameArgs) {
22
- return this.schema.getOpName(type, kind, plugin, ...opNameArgs)
21
+ opName (type, kind, plugin, opts) {
22
+ return this.schema.getOpName(type, kind, plugin, opts)
23
23
  }
24
24
 
25
- serviceName (type, kind, plugin, ...serviceNameArgs) {
26
- return this.schema.getServiceName(type, kind, plugin, this.config.service, ...serviceNameArgs)
27
- }
25
+ serviceName (type, kind, plugin, opts) {
26
+ const schema = this.shouldUseConsistentServiceNaming
27
+ ? this.schemas.v1
28
+ : this.schema
28
29
 
29
- shortCircuitServiceName (pluginConfig, ...args) {
30
- // We're short-circuiting, so we do not obey custom service functions
31
- if (typeof pluginConfig.service === 'function') {
32
- return this.config.service
33
- }
34
- return pluginConfig.service || this.config.service
30
+ return schema.getServiceName(type, kind, plugin, { ...opts, tracerService: this.config.service })
35
31
  }
36
32
 
37
33
  configure (config = {}) {
@@ -10,14 +10,14 @@ class SchemaDefinition {
10
10
  }
11
11
  }
12
12
 
13
- getOpName (type, kind, plugin, ...opNameArgs) {
13
+ getOpName (type, kind, plugin, opts) {
14
14
  const item = this.getSchemaItem(type, kind, plugin)
15
- return item.opName(...opNameArgs)
15
+ return item.opName(opts)
16
16
  }
17
17
 
18
- getServiceName (type, kind, plugin, service, ...serviceNameArgs) {
18
+ getServiceName (type, kind, plugin, opts) {
19
19
  const item = this.getSchemaItem(type, kind, plugin)
20
- return item.serviceName(service, ...serviceNameArgs)
20
+ return item.serviceName(opts)
21
21
  }
22
22
  }
23
23
 
@@ -1,5 +1,23 @@
1
- function identityService (service) {
2
- return service
1
+ function identityService ({ tracerService }) {
2
+ return tracerService
3
3
  }
4
4
 
5
- module.exports = { identityService }
5
+ function getFormattedHostString ({ host, port }) {
6
+ return [host, port].filter(val => val).join(':')
7
+ }
8
+
9
+ function httpPluginClientService ({ tracerService, pluginConfig, sessionDetails }) {
10
+ if (pluginConfig.splitByDomain) {
11
+ return getFormattedHostString(sessionDetails)
12
+ } else if (pluginConfig.service) {
13
+ return pluginConfig.service
14
+ }
15
+
16
+ return tracerService
17
+ }
18
+
19
+ function awsServiceV0 ({ tracerService, awsService }) {
20
+ return `${tracerService}-aws-${awsService}`
21
+ }
22
+
23
+ module.exports = { identityService, httpPluginClientService, awsServiceV0 }
@@ -1,7 +1,7 @@
1
- const { identityService } = require('../util')
1
+ const { identityService, awsServiceV0 } = require('../util')
2
2
 
3
- function amqpServiceName (service) {
4
- return `${service}-amqp`
3
+ function amqpServiceName ({ tracerService }) {
4
+ return `${tracerService}-amqp`
5
5
  }
6
6
 
7
7
  const messaging = {
@@ -16,15 +16,23 @@ const messaging = {
16
16
  },
17
17
  'google-cloud-pubsub': {
18
18
  opName: () => 'pubsub.request',
19
- serviceName: service => `${service}-pubsub`
19
+ serviceName: ({ tracerService }) => `${tracerService}-pubsub`
20
20
  },
21
21
  kafkajs: {
22
22
  opName: () => 'kafka.produce',
23
- serviceName: service => `${service}-kafka`
23
+ serviceName: ({ tracerService }) => `${tracerService}-kafka`
24
24
  },
25
25
  rhea: {
26
26
  opName: () => 'amqp.send',
27
- serviceName: service => `${service}-amqp-producer`
27
+ serviceName: ({ tracerService }) => `${tracerService}-amqp-producer`
28
+ },
29
+ sqs: {
30
+ opName: () => 'aws.request',
31
+ serviceName: awsServiceV0
32
+ },
33
+ sns: {
34
+ opName: () => 'aws.request',
35
+ serviceName: awsServiceV0
28
36
  }
29
37
  },
30
38
  consumer: {
@@ -42,11 +50,15 @@ const messaging = {
42
50
  },
43
51
  kafkajs: {
44
52
  opName: () => 'kafka.consume',
45
- serviceName: service => `${service}-kafka`
53
+ serviceName: ({ tracerService }) => `${tracerService}-kafka`
46
54
  },
47
55
  rhea: {
48
56
  opName: () => 'amqp.receive',
49
57
  serviceName: identityService
58
+ },
59
+ sqs: {
60
+ opName: () => 'aws.request',
61
+ serviceName: awsServiceV0
50
62
  }
51
63
  },
52
64
  client: {
@@ -56,7 +68,7 @@ const messaging = {
56
68
  },
57
69
  'google-cloud-pubsub': {
58
70
  opName: () => 'pubsub.request',
59
- serviceName: service => `${service}-pubsub`
71
+ serviceName: ({ tracerService }) => `${tracerService}-pubsub`
60
72
  }
61
73
  }
62
74
  }
@@ -1,37 +1,37 @@
1
- function getRedisService (config, connectionName) {
2
- if (config.splitByInstance && connectionName) {
3
- return config.service
4
- ? `${config.service}-${connectionName}`
1
+ function getRedisService (pluginConfig, connectionName) {
2
+ if (pluginConfig.splitByInstance && connectionName) {
3
+ return pluginConfig.service
4
+ ? `${pluginConfig.service}-${connectionName}`
5
5
  : connectionName
6
6
  }
7
7
 
8
- return config.service
8
+ return pluginConfig.service
9
9
  }
10
10
 
11
- function fromSystem (service, system) {
12
- return system ? `${service}-${system}` : undefined
11
+ function fromSystem (tracerService, system) {
12
+ return system ? `${tracerService}-${system}` : undefined
13
13
  }
14
14
 
15
- function mysqlServiceName (service, config, dbConfig, system) {
16
- if (typeof config.service === 'function') {
17
- return config.service(dbConfig)
15
+ function mysqlServiceName ({ tracerService, pluginConfig, dbConfig, system }) {
16
+ if (typeof pluginConfig.service === 'function') {
17
+ return pluginConfig.service(dbConfig)
18
18
  }
19
- return config.service || fromSystem(service, system)
19
+ return pluginConfig.service || fromSystem(tracerService, system)
20
20
  }
21
21
 
22
22
  function withSuffixFunction (suffix) {
23
- return (service, config, params) => {
24
- if (typeof config.service === 'function') {
25
- return config.service(params)
23
+ return ({ tracerService, pluginConfig, params }) => {
24
+ if (typeof pluginConfig.service === 'function') {
25
+ return pluginConfig.service(params)
26
26
  }
27
- return config.service || `${service}-${suffix}`
27
+ return pluginConfig.service || `${tracerService}-${suffix}`
28
28
  }
29
29
  }
30
30
 
31
31
  const redisConfig = {
32
32
  opName: () => 'redis.command',
33
- serviceName: (service, config, system, connectionName) => {
34
- return getRedisService(config, connectionName) || fromSystem(service, system)
33
+ serviceName: ({ tracerService, pluginConfig, system, connectionName }) => {
34
+ return getRedisService(pluginConfig, connectionName) || fromSystem(tracerService, system)
35
35
  }
36
36
  }
37
37
 
@@ -39,11 +39,17 @@ const storage = {
39
39
  client: {
40
40
  'cassandra-driver': {
41
41
  opName: () => 'cassandra.query',
42
- serviceName: (service, config, system) => config.service || fromSystem(service, system)
42
+ serviceName: ({ tracerService, pluginConfig, system }) =>
43
+ pluginConfig.service || fromSystem(tracerService, system)
44
+ },
45
+ couchbase: {
46
+ opName: ({ operation }) => `couchbase.${operation}`,
47
+ serviceName: ({ tracerService, pluginConfig }) => pluginConfig.service || `${tracerService}-couchbase`
43
48
  },
44
49
  elasticsearch: {
45
50
  opName: () => 'elasticsearch.query',
46
- serviceName: (service, config) => config.service || `${service}-elasticsearch`
51
+ serviceName: ({ tracerService, pluginConfig }) =>
52
+ pluginConfig.service || `${tracerService}-elasticsearch`
47
53
  },
48
54
  ioredis: redisConfig,
49
55
  mariadb: {
@@ -52,11 +58,13 @@ const storage = {
52
58
  },
53
59
  memcached: {
54
60
  opName: () => 'memcached.command',
55
- serviceName: (service, config, system) => config.service || fromSystem(service, system)
61
+ serviceName: ({ tracerService, pluginConfig, system }) =>
62
+ pluginConfig.service || fromSystem(tracerService, system)
56
63
  },
57
64
  'mongodb-core': {
58
65
  opName: () => 'mongodb.query',
59
- serviceName: (service, config) => config.service || `${service}-mongodb`
66
+ serviceName: ({ tracerService, pluginConfig }) =>
67
+ pluginConfig.service || `${tracerService}-mongodb`
60
68
  },
61
69
  mysql: {
62
70
  opName: () => 'mysql.query',
@@ -68,7 +76,8 @@ const storage = {
68
76
  },
69
77
  opensearch: {
70
78
  opName: () => 'opensearch.query',
71
- serviceName: (service, config) => config.service || `${service}-opensearch`
79
+ serviceName: ({ tracerService, pluginConfig }) =>
80
+ pluginConfig.service || `${tracerService}-opensearch`
72
81
  },
73
82
  oracledb: {
74
83
  opName: () => 'oracle.query',
@@ -81,7 +90,8 @@ const storage = {
81
90
  redis: redisConfig,
82
91
  tedious: {
83
92
  opName: () => 'tedious.request',
84
- serviceName: (service, config, system) => config.service || fromSystem(service, system)
93
+ serviceName: ({ tracerService, pluginConfig, system }) =>
94
+ pluginConfig.service || fromSystem(tracerService, system)
85
95
  }
86
96
  }
87
97
  }
@@ -1,4 +1,4 @@
1
- const { identityService } = require('../util')
1
+ const { identityService, httpPluginClientService, awsServiceV0 } = require('../util')
2
2
  const { DD_MAJOR } = require('../../../../../../version')
3
3
 
4
4
  const web = {
@@ -10,6 +10,26 @@ const web = {
10
10
  moleculer: {
11
11
  opName: () => 'moleculer.call',
12
12
  serviceName: identityService
13
+ },
14
+ http: {
15
+ opName: () => 'http.request',
16
+ serviceName: httpPluginClientService
17
+ },
18
+ fetch: {
19
+ opName: () => 'http.request',
20
+ serviceName: httpPluginClientService
21
+ },
22
+ http2: {
23
+ opName: () => 'http.request',
24
+ serviceName: httpPluginClientService
25
+ },
26
+ aws: {
27
+ opName: () => 'aws.request',
28
+ serviceName: awsServiceV0
29
+ },
30
+ lambda: {
31
+ opName: () => 'aws.request',
32
+ serviceName: awsServiceV0
13
33
  }
14
34
  },
15
35
  server: {
@@ -20,6 +40,18 @@ const web = {
20
40
  moleculer: {
21
41
  opName: () => 'moleculer.action',
22
42
  serviceName: identityService
43
+ },
44
+ http: {
45
+ opName: () => 'web.request',
46
+ serviceName: identityService
47
+ },
48
+ http2: {
49
+ opName: () => 'web.request',
50
+ serviceName: identityService
51
+ },
52
+ next: {
53
+ opName: () => 'next.request',
54
+ serviceName: identityService
23
55
  }
24
56
  }
25
57
  }
@@ -22,7 +22,15 @@ const messaging = {
22
22
  opName: () => 'kafka.send',
23
23
  serviceName: identityService
24
24
  },
25
- rhea: amqpOutbound
25
+ rhea: amqpOutbound,
26
+ sqs: {
27
+ opName: () => 'aws.sqs.send',
28
+ serviceName: identityService
29
+ },
30
+ sns: {
31
+ opName: () => 'aws.sns.send',
32
+ serviceName: identityService
33
+ }
26
34
  },
27
35
  consumer: {
28
36
  amqplib: amqpInbound,
@@ -35,7 +43,11 @@ const messaging = {
35
43
  opName: () => 'kafka.process',
36
44
  serviceName: identityService
37
45
  },
38
- rhea: amqpInbound
46
+ rhea: amqpInbound,
47
+ sqs: {
48
+ opName: () => 'aws.sqs.process',
49
+ serviceName: identityService
50
+ }
39
51
  },
40
52
  client: {
41
53
  amqplib: {
@@ -1,7 +1,6 @@
1
- const { identityService } = require('../util')
2
1
 
3
- function configWithFallback (service, config) {
4
- return config.service || service
2
+ function configWithFallback ({ tracerService, pluginConfig }) {
3
+ return pluginConfig.service || tracerService
5
4
  }
6
5
 
7
6
  const redisNaming = {
@@ -11,14 +10,14 @@ const redisNaming = {
11
10
 
12
11
  const mySQLNaming = {
13
12
  opName: () => 'mysql.query',
14
- serviceName: identityService
13
+ serviceName: withFunction
15
14
  }
16
15
 
17
- function withFunction (service, config, params) {
18
- if (typeof config.service === 'function') {
19
- return config.service(params)
16
+ function withFunction ({ tracerService, pluginConfig, params }) {
17
+ if (typeof pluginConfig.service === 'function') {
18
+ return pluginConfig.service(params)
20
19
  }
21
- return configWithFallback(service, config)
20
+ return configWithFallback({ tracerService, pluginConfig })
22
21
  }
23
22
 
24
23
  const storage = {
@@ -27,6 +26,10 @@ const storage = {
27
26
  opName: () => 'cassandra.query',
28
27
  serviceName: configWithFallback
29
28
  },
29
+ couchbase: {
30
+ opName: () => 'couchbase.query',
31
+ serviceName: configWithFallback
32
+ },
30
33
  elasticsearch: {
31
34
  opName: () => 'elasticsearch.query',
32
35
  serviceName: configWithFallback
@@ -34,7 +37,7 @@ const storage = {
34
37
  ioredis: redisNaming,
35
38
  mariadb: {
36
39
  opName: () => 'mariadb.query',
37
- serviceName: identityService
40
+ serviceName: withFunction
38
41
  },
39
42
  memcached: {
40
43
  opName: () => 'memcached.command',
@@ -1,4 +1,4 @@
1
- const { identityService } = require('../util')
1
+ const { identityService, httpPluginClientService } = require('../util')
2
2
 
3
3
  const web = {
4
4
  client: {
@@ -9,6 +9,26 @@ const web = {
9
9
  moleculer: {
10
10
  opName: () => 'moleculer.client.request',
11
11
  serviceName: identityService
12
+ },
13
+ http: {
14
+ opName: () => 'http.client.request',
15
+ serviceName: httpPluginClientService
16
+ },
17
+ fetch: {
18
+ opName: () => 'http.client.request',
19
+ serviceName: httpPluginClientService
20
+ },
21
+ http2: {
22
+ opName: () => 'http.client.request',
23
+ serviceName: httpPluginClientService
24
+ },
25
+ aws: {
26
+ opName: ({ awsService }) => `aws.${awsService}.request`,
27
+ serviceName: identityService
28
+ },
29
+ lambda: {
30
+ opName: () => 'aws.lambda.invoke',
31
+ serviceName: identityService
12
32
  }
13
33
  },
14
34
  server: {
@@ -19,6 +39,18 @@ const web = {
19
39
  moleculer: {
20
40
  opName: () => 'moleculer.server.request',
21
41
  serviceName: identityService
42
+ },
43
+ http: {
44
+ opName: () => 'http.server.request',
45
+ serviceName: identityService
46
+ },
47
+ http2: {
48
+ opName: () => 'http.server.request',
49
+ serviceName: identityService
50
+ },
51
+ next: {
52
+ opName: () => 'http.server.request',
53
+ serviceName: identityService
22
54
  }
23
55
  }
24
56
  }
@@ -1,53 +0,0 @@
1
- 'use strict'
2
-
3
- // TODO: Figure out why we can't use the internal version.
4
- // eslint-disable-next-line n/no-restricted-require
5
- const dc = require('diagnostics_channel')
6
-
7
- const CHANNEL_PREFIX = 'dd-trace:bundledModuleLoadStart'
8
-
9
- if (!dc.subscribe) {
10
- dc.subscribe = (channel, cb) => {
11
- dc.channel(channel).subscribe(cb)
12
- }
13
- }
14
- if (!dc.unsubscribe) {
15
- dc.unsubscribe = (channel, cb) => {
16
- if (dc.channel(channel).hasSubscribers) {
17
- dc.channel(channel).unsubscribe(cb)
18
- }
19
- }
20
- }
21
-
22
- module.exports = DcitmHook
23
-
24
- /**
25
- * This allows for listening to diagnostic channel events when a module is loaded.
26
- * Currently it's intended use is for situations like when code runs through a bundler.
27
- *
28
- * Unlike RITM and IITM, which have files available on a filesystem at runtime, DCITM
29
- * requires access to a package's version ahead of time as the package.json file likely
30
- * won't be available.
31
- *
32
- * This function runs many times at startup, once for every module that dd-trace may trace.
33
- * As it runs on a per-module basis we're creating per-module channels.
34
- */
35
- function DcitmHook (moduleNames, options, onrequire) {
36
- if (!(this instanceof DcitmHook)) return new DcitmHook(moduleNames, options, onrequire)
37
-
38
- function onModuleLoad (payload) {
39
- payload.module = onrequire(payload.module, payload.path, undefined, payload.version)
40
- }
41
-
42
- for (const moduleName of moduleNames) {
43
- // dc.channel(`${CHANNEL_PREFIX}:${moduleName}`).subscribe(onModuleLoad)
44
- dc.subscribe(`${CHANNEL_PREFIX}:${moduleName}`, onModuleLoad)
45
- }
46
-
47
- this.unhook = function dcitmUnload () {
48
- for (const moduleName of moduleNames) {
49
- // dc.channel(`${CHANNEL_PREFIX}:${moduleName}`).unsubscribe(onModuleLoad)
50
- dc.unsubscribe(`${CHANNEL_PREFIX}:${moduleName}`, onModuleLoad)
51
- }
52
- }
53
- }