dd-trace 3.15.0 → 3.17.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.
- package/LICENSE-3rdparty.csv +2 -2
- package/README.md +53 -0
- package/ci/init.js +9 -1
- package/ext/exporters.d.ts +2 -1
- package/ext/exporters.js +2 -1
- package/index.d.ts +6 -2
- package/package.json +24 -19
- package/packages/datadog-esbuild/index.js +104 -0
- package/packages/datadog-instrumentations/src/cucumber.js +80 -3
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +100 -27
- package/packages/datadog-instrumentations/src/helpers/hook.js +13 -3
- package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
- package/packages/datadog-instrumentations/src/helpers/instrument.js +6 -0
- package/packages/datadog-instrumentations/src/helpers/register.js +2 -2
- package/packages/datadog-instrumentations/src/jest.js +35 -3
- package/packages/datadog-instrumentations/src/mariadb.js +130 -11
- package/packages/datadog-instrumentations/src/mocha.js +30 -6
- package/packages/datadog-instrumentations/src/mongodb-core.js +8 -2
- package/packages/datadog-instrumentations/src/mongoose.js +1 -1
- package/packages/datadog-instrumentations/src/next.js +32 -4
- package/packages/datadog-instrumentations/src/pg.js +16 -11
- package/packages/datadog-instrumentations/src/playwright.js +2 -2
- package/packages/datadog-plugin-amqp10/src/consumer.js +1 -1
- package/packages/datadog-plugin-amqp10/src/index.js +1 -1
- package/packages/datadog-plugin-amqp10/src/producer.js +3 -2
- package/packages/datadog-plugin-amqplib/src/client.js +3 -2
- package/packages/datadog-plugin-amqplib/src/consumer.js +1 -1
- package/packages/datadog-plugin-amqplib/src/index.js +1 -1
- package/packages/datadog-plugin-amqplib/src/producer.js +3 -2
- package/packages/datadog-plugin-aws-sdk/src/base.js +7 -2
- package/packages/datadog-plugin-aws-sdk/src/index.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/s3.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +2 -0
- package/packages/datadog-plugin-bunyan/src/index.js +1 -1
- package/packages/datadog-plugin-cassandra-driver/src/index.js +3 -2
- package/packages/datadog-plugin-connect/src/index.js +1 -1
- package/packages/datadog-plugin-couchbase/src/index.js +1 -1
- package/packages/datadog-plugin-cucumber/src/index.js +33 -6
- package/packages/datadog-plugin-cypress/src/index.js +1 -1
- package/packages/datadog-plugin-cypress/src/plugin.js +40 -33
- package/packages/datadog-plugin-dns/src/index.js +1 -1
- package/packages/datadog-plugin-dns/src/lookup.js +1 -1
- package/packages/datadog-plugin-dns/src/lookup_service.js +1 -1
- package/packages/datadog-plugin-dns/src/resolve.js +1 -1
- package/packages/datadog-plugin-dns/src/reverse.js +1 -1
- package/packages/datadog-plugin-elasticsearch/src/index.js +1 -1
- package/packages/datadog-plugin-express/src/index.js +1 -1
- package/packages/datadog-plugin-fastify/src/index.js +1 -1
- package/packages/datadog-plugin-find-my-way/src/index.js +1 -1
- package/packages/datadog-plugin-fs/src/index.js +1 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +5 -5
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +1 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/index.js +1 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +7 -6
- package/packages/datadog-plugin-graphql/src/execute.js +1 -1
- package/packages/datadog-plugin-graphql/src/index.js +1 -1
- package/packages/datadog-plugin-graphql/src/parse.js +1 -1
- package/packages/datadog-plugin-graphql/src/resolve.js +1 -1
- package/packages/datadog-plugin-graphql/src/validate.js +1 -1
- package/packages/datadog-plugin-grpc/src/client.js +1 -1
- package/packages/datadog-plugin-grpc/src/index.js +1 -1
- package/packages/datadog-plugin-grpc/src/server.js +1 -1
- package/packages/datadog-plugin-hapi/src/index.js +1 -1
- package/packages/datadog-plugin-http/src/client.js +2 -2
- package/packages/datadog-plugin-http/src/index.js +1 -1
- package/packages/datadog-plugin-http/src/server.js +2 -2
- package/packages/datadog-plugin-http2/src/client.js +4 -3
- package/packages/datadog-plugin-http2/src/index.js +1 -1
- package/packages/datadog-plugin-http2/src/server.js +2 -2
- package/packages/datadog-plugin-ioredis/src/index.js +1 -1
- package/packages/datadog-plugin-jest/src/index.js +53 -19
- package/packages/datadog-plugin-kafkajs/src/consumer.js +1 -1
- package/packages/datadog-plugin-kafkajs/src/index.js +1 -1
- package/packages/datadog-plugin-kafkajs/src/producer.js +1 -1
- package/packages/datadog-plugin-koa/src/index.js +1 -1
- package/packages/datadog-plugin-mariadb/src/index.js +18 -1
- package/packages/datadog-plugin-memcached/src/index.js +3 -2
- package/packages/datadog-plugin-microgateway-core/src/index.js +1 -1
- package/packages/datadog-plugin-mocha/src/index.js +13 -9
- package/packages/datadog-plugin-moleculer/src/client.js +1 -1
- package/packages/datadog-plugin-moleculer/src/index.js +1 -1
- package/packages/datadog-plugin-moleculer/src/server.js +1 -1
- package/packages/datadog-plugin-mongodb-core/src/index.js +1 -1
- package/packages/datadog-plugin-mysql/src/index.js +3 -2
- package/packages/datadog-plugin-mysql2/src/index.js +1 -1
- package/packages/datadog-plugin-net/src/index.js +9 -75
- package/packages/datadog-plugin-net/src/ipc.js +1 -1
- package/packages/datadog-plugin-net/src/tcp.js +3 -2
- package/packages/datadog-plugin-next/src/index.js +3 -3
- package/packages/datadog-plugin-opensearch/src/index.js +1 -1
- package/packages/datadog-plugin-oracledb/src/index.js +3 -2
- package/packages/datadog-plugin-paperplane/src/index.js +1 -1
- package/packages/datadog-plugin-paperplane/src/logger.js +1 -1
- package/packages/datadog-plugin-paperplane/src/server.js +1 -1
- package/packages/datadog-plugin-pg/src/index.js +3 -2
- package/packages/datadog-plugin-pino/src/index.js +1 -1
- package/packages/datadog-plugin-playwright/src/index.js +5 -4
- package/packages/datadog-plugin-redis/src/index.js +3 -2
- package/packages/datadog-plugin-restify/src/index.js +1 -1
- package/packages/datadog-plugin-rhea/src/consumer.js +1 -1
- package/packages/datadog-plugin-rhea/src/index.js +1 -1
- package/packages/datadog-plugin-rhea/src/producer.js +3 -2
- package/packages/datadog-plugin-router/src/index.js +8 -8
- package/packages/datadog-plugin-sharedb/src/index.js +1 -1
- package/packages/datadog-plugin-tedious/src/index.js +3 -2
- package/packages/datadog-plugin-web/src/index.js +1 -1
- package/packages/datadog-plugin-winston/src/index.js +1 -1
- package/packages/dd-trace/src/appsec/{templates/blocked.html → blocked_templates.js} +19 -1
- package/packages/dd-trace/src/appsec/blocking.js +9 -24
- package/packages/dd-trace/src/appsec/gateway/engine/runner.js +2 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +2 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/path-traversal-analyzer.js +12 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/sql-injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/vulnerability-analyzer.js +11 -5
- package/packages/dd-trace/src/appsec/iast/iast-log.js +111 -0
- package/packages/dd-trace/src/appsec/iast/index.js +8 -4
- package/packages/dd-trace/src/appsec/iast/path-line.js +3 -6
- package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +11 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +11 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/origin-types.js +2 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +2 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +5 -3
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +5 -3
- package/packages/dd-trace/src/appsec/iast/telemetry/log_collector.js +96 -0
- package/packages/dd-trace/src/appsec/iast/telemetry/logs.js +87 -0
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +27 -2
- package/packages/dd-trace/src/appsec/index.js +4 -18
- package/packages/dd-trace/src/appsec/recommended.json +43 -14
- package/packages/dd-trace/src/appsec/remote_config/index.js +1 -1
- package/packages/dd-trace/src/appsec/sdk/index.js +2 -2
- package/packages/dd-trace/src/ci-visibility/encode/json-encoder.js +27 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +2 -9
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +7 -7
- package/packages/dd-trace/src/ci-visibility/exporters/jest-worker/index.js +33 -0
- package/packages/dd-trace/src/ci-visibility/exporters/jest-worker/writer.js +37 -0
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-itr-configuration.js +8 -2
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +8 -2
- package/packages/dd-trace/src/config.js +44 -22
- package/packages/dd-trace/src/constants.js +2 -1
- package/packages/dd-trace/src/datastreams/encoding.js +80 -0
- package/packages/dd-trace/src/dcitm.js +51 -0
- package/packages/dd-trace/src/exporter.js +7 -9
- package/packages/dd-trace/src/exporters/common/agents.js +42 -0
- package/packages/dd-trace/src/exporters/common/docker.js +4 -1
- package/packages/dd-trace/src/exporters/common/request.js +1 -4
- package/packages/dd-trace/src/lambda/handler.js +14 -6
- package/packages/dd-trace/src/opentracing/propagation/log.js +23 -7
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +28 -2
- package/packages/dd-trace/src/opentracing/span.js +19 -3
- package/packages/dd-trace/src/opentracing/span_context.js +3 -1
- package/packages/dd-trace/src/opentracing/tracer.js +3 -1
- package/packages/dd-trace/src/plugin_manager.js +7 -7
- package/packages/dd-trace/src/plugins/ci_plugin.js +16 -16
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/dd-trace/src/plugins/log_plugin.js +1 -1
- package/packages/dd-trace/src/plugins/outgoing.js +2 -1
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +12 -0
- package/packages/dd-trace/src/plugins/util/ip_extractor.js +23 -27
- package/packages/dd-trace/src/plugins/util/test.js +26 -7
- package/packages/dd-trace/src/profiling/config.js +87 -20
- package/packages/dd-trace/src/profiling/constants.js +16 -0
- package/packages/dd-trace/src/profiling/exporter_cli.js +62 -0
- package/packages/dd-trace/src/profiling/exporters/agent.js +2 -1
- package/packages/dd-trace/src/profiling/profiler.js +21 -8
- package/packages/dd-trace/src/profiling/profilers/space.js +21 -1
- package/packages/dd-trace/src/span_sampler.js +3 -2
- package/packages/dd-trace/src/telemetry/index.js +16 -2
- package/packages/dd-trace/src/util.js +10 -1
- package/scripts/install_plugin_modules.js +5 -1
- package/packages/dd-trace/src/appsec/templates/blocked.json +0 -8
- package/scripts/junit_report.js +0 -25
- package/scripts/tdd.js +0 -34
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { TEXT_MAP } = require('../../../ext/formats')
|
|
4
|
+
const { CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
|
|
4
5
|
const ProducerPlugin = require('../../dd-trace/src/plugins/producer')
|
|
5
6
|
const { getResourceName } = require('./util')
|
|
6
7
|
|
|
7
8
|
class AmqplibProducerPlugin extends ProducerPlugin {
|
|
8
|
-
static get
|
|
9
|
+
static get id () { return 'amqplib' }
|
|
9
10
|
static get operation () { return 'command' }
|
|
10
11
|
|
|
11
12
|
start ({ channel = {}, method, fields }) {
|
|
@@ -18,7 +19,7 @@ class AmqplibProducerPlugin extends ProducerPlugin {
|
|
|
18
19
|
kind: 'producer',
|
|
19
20
|
meta: {
|
|
20
21
|
'out.host': stream._host,
|
|
21
|
-
|
|
22
|
+
[CLIENT_PORT_KEY]: stream.remotePort,
|
|
22
23
|
'amqp.queue': fields.queue,
|
|
23
24
|
'amqp.exchange': fields.exchange,
|
|
24
25
|
'amqp.routingKey': fields.routingKey,
|
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
const analyticsSampler = require('../../dd-trace/src/analytics_sampler')
|
|
4
4
|
const Plugin = require('../../dd-trace/src/plugins/plugin')
|
|
5
5
|
const { storage } = require('../../datadog-core')
|
|
6
|
+
const { isTrue } = require('../../dd-trace/src/util')
|
|
6
7
|
|
|
7
8
|
class BaseAwsSdkPlugin extends Plugin {
|
|
9
|
+
static get id () { return 'aws' }
|
|
10
|
+
|
|
8
11
|
get serviceIdentifier () {
|
|
9
|
-
const id = this.constructor.
|
|
12
|
+
const id = this.constructor.id.toLowerCase()
|
|
10
13
|
Object.defineProperty(this, 'serviceIdentifier', {
|
|
11
14
|
configurable: true,
|
|
12
15
|
writable: true,
|
|
@@ -74,7 +77,9 @@ class BaseAwsSdkPlugin extends Plugin {
|
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
isEnabled (request) {
|
|
77
|
-
|
|
80
|
+
const serviceId = this.serviceIdentifier.toUpperCase()
|
|
81
|
+
const envVarValue = process.env[`DD_TRACE_AWS_SDK_${serviceId}_ENABLED`]
|
|
82
|
+
return envVarValue ? isTrue(envVarValue) : true
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
addResponseTags (span, response) {
|
|
@@ -3,6 +3,8 @@ const log = require('../../../dd-trace/src/log')
|
|
|
3
3
|
const BaseAwsSdkPlugin = require('../base')
|
|
4
4
|
|
|
5
5
|
class EventBridge extends BaseAwsSdkPlugin {
|
|
6
|
+
static get id () { return 'eventbridge' }
|
|
7
|
+
|
|
6
8
|
generateTags (params, operation, response) {
|
|
7
9
|
if (!params || !params.source) return {}
|
|
8
10
|
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
const log = require('../../../dd-trace/src/log')
|
|
3
3
|
const BaseAwsSdkPlugin = require('../base')
|
|
4
4
|
class Kinesis extends BaseAwsSdkPlugin {
|
|
5
|
+
static get id () { return 'kinesis' }
|
|
6
|
+
|
|
5
7
|
generateTags (params, operation, response) {
|
|
6
8
|
if (!params || !params.StreamName) return {}
|
|
7
9
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
|
|
3
4
|
const DatabasePlugin = require('../../dd-trace/src/plugins/database')
|
|
4
5
|
|
|
5
6
|
class CassandraDriverPlugin extends DatabasePlugin {
|
|
6
|
-
static get
|
|
7
|
+
static get id () { return 'cassandra-driver' }
|
|
7
8
|
static get system () { return 'cassandra' }
|
|
8
9
|
|
|
9
10
|
start ({ keyspace, query, connectionOptions = {} }) {
|
|
@@ -21,7 +22,7 @@ class CassandraDriverPlugin extends DatabasePlugin {
|
|
|
21
22
|
'cassandra.query': query,
|
|
22
23
|
'cassandra.keyspace': keyspace,
|
|
23
24
|
'out.host': connectionOptions.host,
|
|
24
|
-
|
|
25
|
+
[CLIENT_PORT_KEY]: connectionOptions.port
|
|
25
26
|
}
|
|
26
27
|
})
|
|
27
28
|
}
|
|
@@ -8,13 +8,14 @@ const {
|
|
|
8
8
|
TEST_STATUS,
|
|
9
9
|
finishAllTraceSpans,
|
|
10
10
|
getTestSuitePath,
|
|
11
|
-
getTestSuiteCommonTags
|
|
11
|
+
getTestSuiteCommonTags,
|
|
12
|
+
addIntelligentTestRunnerSpanTags
|
|
12
13
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
13
14
|
const { RESOURCE_NAME } = require('../../../ext/tags')
|
|
14
15
|
const { COMPONENT, ERROR_MESSAGE } = require('../../dd-trace/src/constants')
|
|
15
16
|
|
|
16
17
|
class CucumberPlugin extends CiPlugin {
|
|
17
|
-
static get
|
|
18
|
+
static get id () {
|
|
18
19
|
return 'cucumber'
|
|
19
20
|
}
|
|
20
21
|
|
|
@@ -23,12 +24,21 @@ class CucumberPlugin extends CiPlugin {
|
|
|
23
24
|
|
|
24
25
|
this.sourceRoot = process.cwd()
|
|
25
26
|
|
|
26
|
-
this.addSub('ci:cucumber:session:finish', (status) => {
|
|
27
|
+
this.addSub('ci:cucumber:session:finish', ({ status, isSuitesSkipped, testCodeCoverageLinesTotal }) => {
|
|
28
|
+
const { isSuitesSkippingEnabled, isCodeCoverageEnabled } = this.itrConfig || {}
|
|
29
|
+
addIntelligentTestRunnerSpanTags(
|
|
30
|
+
this.testSessionSpan,
|
|
31
|
+
this.testModuleSpan,
|
|
32
|
+
{ isSuitesSkipped, isSuitesSkippingEnabled, isCodeCoverageEnabled, testCodeCoverageLinesTotal }
|
|
33
|
+
)
|
|
34
|
+
|
|
27
35
|
this.testSessionSpan.setTag(TEST_STATUS, status)
|
|
28
36
|
this.testModuleSpan.setTag(TEST_STATUS, status)
|
|
29
37
|
this.testModuleSpan.finish()
|
|
30
38
|
this.testSessionSpan.finish()
|
|
31
39
|
finishAllTraceSpans(this.testSessionSpan)
|
|
40
|
+
|
|
41
|
+
this.itrConfig = null
|
|
32
42
|
this.tracer._exporter.flush()
|
|
33
43
|
})
|
|
34
44
|
|
|
@@ -36,12 +46,13 @@ class CucumberPlugin extends CiPlugin {
|
|
|
36
46
|
const testSuiteMetadata = getTestSuiteCommonTags(
|
|
37
47
|
this.command,
|
|
38
48
|
this.frameworkVersion,
|
|
39
|
-
getTestSuitePath(testSuiteFullPath, this.sourceRoot)
|
|
49
|
+
getTestSuitePath(testSuiteFullPath, this.sourceRoot),
|
|
50
|
+
'cucumber'
|
|
40
51
|
)
|
|
41
52
|
this.testSuiteSpan = this.tracer.startSpan('cucumber.test_suite', {
|
|
42
53
|
childOf: this.testModuleSpan,
|
|
43
54
|
tags: {
|
|
44
|
-
[COMPONENT]: this.constructor.
|
|
55
|
+
[COMPONENT]: this.constructor.id,
|
|
45
56
|
...this.testEnvironmentMetadata,
|
|
46
57
|
...testSuiteMetadata
|
|
47
58
|
}
|
|
@@ -53,6 +64,22 @@ class CucumberPlugin extends CiPlugin {
|
|
|
53
64
|
this.testSuiteSpan.finish()
|
|
54
65
|
})
|
|
55
66
|
|
|
67
|
+
this.addSub('ci:cucumber:test-suite:code-coverage', ({ coverageFiles, suiteFile }) => {
|
|
68
|
+
if (!this.itrConfig || !this.itrConfig.isCodeCoverageEnabled) {
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
const relativeCoverageFiles = [...coverageFiles, suiteFile]
|
|
72
|
+
.map(filename => getTestSuitePath(filename, this.sourceRoot))
|
|
73
|
+
|
|
74
|
+
const formattedCoverage = {
|
|
75
|
+
traceId: this.testSuiteSpan.context()._traceId,
|
|
76
|
+
spanId: this.testSuiteSpan.context()._spanId,
|
|
77
|
+
files: relativeCoverageFiles
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
this.tracer._exporter.exportCoverage(formattedCoverage)
|
|
81
|
+
})
|
|
82
|
+
|
|
56
83
|
this.addSub('ci:cucumber:test:start', ({ testName, fullTestSuite }) => {
|
|
57
84
|
const store = storage.getStore()
|
|
58
85
|
const testSuite = getTestSuitePath(fullTestSuite, this.sourceRoot)
|
|
@@ -67,7 +94,7 @@ class CucumberPlugin extends CiPlugin {
|
|
|
67
94
|
const span = this.tracer.startSpan('cucumber.step', {
|
|
68
95
|
childOf,
|
|
69
96
|
tags: {
|
|
70
|
-
[COMPONENT]: this.constructor.
|
|
97
|
+
[COMPONENT]: this.constructor.id,
|
|
71
98
|
'cucumber.step': resource,
|
|
72
99
|
[RESOURCE_NAME]: resource
|
|
73
100
|
}
|
|
@@ -3,7 +3,7 @@ const Plugin = require('../../dd-trace/src/plugins/plugin')
|
|
|
3
3
|
// Cypress plugin does not patch any library. This is just a placeholder to
|
|
4
4
|
// follow the structure of the plugins
|
|
5
5
|
class CypressPlugin extends Plugin {
|
|
6
|
-
static get
|
|
6
|
+
static get id () {
|
|
7
7
|
return 'cypress'
|
|
8
8
|
}
|
|
9
9
|
}
|
|
@@ -15,10 +15,12 @@ const {
|
|
|
15
15
|
TEST_MODULE_ID,
|
|
16
16
|
TEST_SESSION_ID,
|
|
17
17
|
TEST_COMMAND,
|
|
18
|
-
|
|
18
|
+
TEST_MODULE,
|
|
19
19
|
finishAllTraceSpans
|
|
20
20
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
21
21
|
|
|
22
|
+
const TEST_FRAMEWORK_NAME = 'cypress'
|
|
23
|
+
|
|
22
24
|
const { ORIGIN_KEY, COMPONENT } = require('../../dd-trace/src/constants')
|
|
23
25
|
|
|
24
26
|
const CYPRESS_STATUS_TO_TEST_STATUS = {
|
|
@@ -51,9 +53,9 @@ function getCypressVersion (details) {
|
|
|
51
53
|
|
|
52
54
|
function getCypressCommand (details) {
|
|
53
55
|
if (!details) {
|
|
54
|
-
return
|
|
56
|
+
return TEST_FRAMEWORK_NAME
|
|
55
57
|
}
|
|
56
|
-
return
|
|
58
|
+
return `${TEST_FRAMEWORK_NAME} ${details.specPattern || ''}`
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
function getSessionStatus (summary) {
|
|
@@ -78,7 +80,7 @@ function getSuiteStatus (suiteStats) {
|
|
|
78
80
|
|
|
79
81
|
module.exports = (on, config) => {
|
|
80
82
|
const tracer = require('../../dd-trace')
|
|
81
|
-
const testEnvironmentMetadata = getTestEnvironmentMetadata(
|
|
83
|
+
const testEnvironmentMetadata = getTestEnvironmentMetadata(TEST_FRAMEWORK_NAME)
|
|
82
84
|
|
|
83
85
|
const codeOwnersEntries = getCodeOwnersFileEntries()
|
|
84
86
|
|
|
@@ -95,21 +97,21 @@ module.exports = (on, config) => {
|
|
|
95
97
|
command = getCypressCommand(details)
|
|
96
98
|
frameworkVersion = getCypressVersion(details)
|
|
97
99
|
|
|
98
|
-
const testSessionSpanMetadata = getTestSessionCommonTags(command, frameworkVersion)
|
|
99
|
-
const testModuleSpanMetadata = getTestModuleCommonTags(command, frameworkVersion)
|
|
100
|
+
const testSessionSpanMetadata = getTestSessionCommonTags(command, frameworkVersion, TEST_FRAMEWORK_NAME)
|
|
101
|
+
const testModuleSpanMetadata = getTestModuleCommonTags(command, frameworkVersion, TEST_FRAMEWORK_NAME)
|
|
100
102
|
|
|
101
|
-
testSessionSpan = tracer.startSpan(
|
|
103
|
+
testSessionSpan = tracer.startSpan(`${TEST_FRAMEWORK_NAME}.test_session`, {
|
|
102
104
|
childOf,
|
|
103
105
|
tags: {
|
|
104
|
-
[COMPONENT]:
|
|
106
|
+
[COMPONENT]: TEST_FRAMEWORK_NAME,
|
|
105
107
|
...testEnvironmentMetadata,
|
|
106
108
|
...testSessionSpanMetadata
|
|
107
109
|
}
|
|
108
110
|
})
|
|
109
|
-
testModuleSpan = tracer.startSpan(
|
|
111
|
+
testModuleSpan = tracer.startSpan(`${TEST_FRAMEWORK_NAME}.test_module`, {
|
|
110
112
|
childOf: testSessionSpan,
|
|
111
113
|
tags: {
|
|
112
|
-
[COMPONENT]:
|
|
114
|
+
[COMPONENT]: TEST_FRAMEWORK_NAME,
|
|
113
115
|
...testEnvironmentMetadata,
|
|
114
116
|
...testModuleSpanMetadata
|
|
115
117
|
}
|
|
@@ -117,14 +119,16 @@ module.exports = (on, config) => {
|
|
|
117
119
|
})
|
|
118
120
|
|
|
119
121
|
on('after:run', (suiteStats) => {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
if (testSessionSpan && testModuleSpan) {
|
|
123
|
+
const testStatus = getSessionStatus(suiteStats)
|
|
124
|
+
testModuleSpan.setTag(TEST_STATUS, testStatus)
|
|
125
|
+
testSessionSpan.setTag(TEST_STATUS, testStatus)
|
|
123
126
|
|
|
124
|
-
|
|
125
|
-
|
|
127
|
+
testModuleSpan.finish()
|
|
128
|
+
testSessionSpan.finish()
|
|
126
129
|
|
|
127
|
-
|
|
130
|
+
finishAllTraceSpans(testSessionSpan)
|
|
131
|
+
}
|
|
128
132
|
|
|
129
133
|
return new Promise(resolve => {
|
|
130
134
|
tracer._tracer._exporter._writer.flush(() => {
|
|
@@ -137,11 +141,11 @@ module.exports = (on, config) => {
|
|
|
137
141
|
if (testSuiteSpan) {
|
|
138
142
|
return null
|
|
139
143
|
}
|
|
140
|
-
const testSuiteSpanMetadata = getTestSuiteCommonTags(command, frameworkVersion, suite)
|
|
141
|
-
testSuiteSpan = tracer.startSpan(
|
|
144
|
+
const testSuiteSpanMetadata = getTestSuiteCommonTags(command, frameworkVersion, suite, TEST_FRAMEWORK_NAME)
|
|
145
|
+
testSuiteSpan = tracer.startSpan(`${TEST_FRAMEWORK_NAME}.test_suite`, {
|
|
142
146
|
childOf: testModuleSpan,
|
|
143
147
|
tags: {
|
|
144
|
-
[COMPONENT]:
|
|
148
|
+
[COMPONENT]: TEST_FRAMEWORK_NAME,
|
|
145
149
|
...testEnvironmentMetadata,
|
|
146
150
|
...testSuiteSpanMetadata
|
|
147
151
|
}
|
|
@@ -149,25 +153,28 @@ module.exports = (on, config) => {
|
|
|
149
153
|
return null
|
|
150
154
|
},
|
|
151
155
|
'dd:testSuiteFinish': (suiteStats) => {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
if (testSuiteSpan) {
|
|
157
|
+
const status = getSuiteStatus(suiteStats)
|
|
158
|
+
testSuiteSpan.setTag(TEST_STATUS, status)
|
|
159
|
+
testSuiteSpan.finish()
|
|
160
|
+
testSuiteSpan = null
|
|
161
|
+
}
|
|
156
162
|
return null
|
|
157
163
|
},
|
|
158
164
|
'dd:beforeEach': (test) => {
|
|
159
165
|
const { testName, testSuite } = test
|
|
160
|
-
const testSuiteId = testSuiteSpan.context().toSpanId()
|
|
161
|
-
const testSessionId = testSessionSpan.context().toTraceId()
|
|
162
|
-
const testModuleId = testModuleSpan.context().toSpanId()
|
|
163
166
|
|
|
164
167
|
const testSuiteTags = {
|
|
165
|
-
[TEST_SUITE_ID]: testSuiteId,
|
|
166
|
-
[TEST_SESSION_ID]: testSessionId,
|
|
167
168
|
[TEST_COMMAND]: command,
|
|
168
|
-
[TEST_MODULE_ID]: testModuleId,
|
|
169
169
|
[TEST_COMMAND]: command,
|
|
170
|
-
[
|
|
170
|
+
[TEST_MODULE]: TEST_FRAMEWORK_NAME
|
|
171
|
+
}
|
|
172
|
+
if (testSuiteSpan) {
|
|
173
|
+
testSuiteTags[TEST_SUITE_ID] = testSuiteSpan.context().toSpanId()
|
|
174
|
+
}
|
|
175
|
+
if (testSessionSpan && testModuleSpan) {
|
|
176
|
+
testSuiteTags[TEST_SESSION_ID] = testSessionSpan.context().toTraceId()
|
|
177
|
+
testSuiteTags[TEST_MODULE_ID] = testModuleSpan.context().toSpanId()
|
|
171
178
|
}
|
|
172
179
|
|
|
173
180
|
const {
|
|
@@ -183,10 +190,10 @@ module.exports = (on, config) => {
|
|
|
183
190
|
}
|
|
184
191
|
|
|
185
192
|
if (!activeSpan) {
|
|
186
|
-
activeSpan = tracer.startSpan(
|
|
193
|
+
activeSpan = tracer.startSpan(`${TEST_FRAMEWORK_NAME}.test`, {
|
|
187
194
|
childOf,
|
|
188
195
|
tags: {
|
|
189
|
-
[COMPONENT]:
|
|
196
|
+
[COMPONENT]: TEST_FRAMEWORK_NAME,
|
|
190
197
|
[ORIGIN_KEY]: CI_APP_ORIGIN,
|
|
191
198
|
...testSpanMetadata,
|
|
192
199
|
...testEnvironmentMetadata,
|
|
@@ -194,7 +201,7 @@ module.exports = (on, config) => {
|
|
|
194
201
|
}
|
|
195
202
|
})
|
|
196
203
|
}
|
|
197
|
-
return activeSpan ? activeSpan.
|
|
204
|
+
return activeSpan ? activeSpan.context().toTraceId() : null
|
|
198
205
|
},
|
|
199
206
|
'dd:afterEach': (test) => {
|
|
200
207
|
const { state, error, isRUMActive } = test
|
|
@@ -9,7 +9,7 @@ const DNSReversePlugin = require('./reverse')
|
|
|
9
9
|
// TODO: Are DNS spans really client spans?
|
|
10
10
|
|
|
11
11
|
class DNSPlugin extends CompositePlugin {
|
|
12
|
-
static get
|
|
12
|
+
static get id () { return 'dns' }
|
|
13
13
|
static get plugins () {
|
|
14
14
|
return {
|
|
15
15
|
lookup: DNSLookupPlugin,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
4
4
|
|
|
5
5
|
class DNSLookupServicePlugin extends ClientPlugin {
|
|
6
|
-
static get
|
|
6
|
+
static get id () { return 'dns' }
|
|
7
7
|
static get operation () { return 'lookup_service' }
|
|
8
8
|
|
|
9
9
|
start ([address, port]) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
4
4
|
|
|
5
5
|
class DNSResolvePlugin extends ClientPlugin {
|
|
6
|
-
static get
|
|
6
|
+
static get id () { return 'dns' }
|
|
7
7
|
static get operation () { return 'resolve' }
|
|
8
8
|
|
|
9
9
|
start ([hostname, maybeType]) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const DatabasePlugin = require('../../dd-trace/src/plugins/database')
|
|
4
4
|
|
|
5
5
|
class ElasticsearchPlugin extends DatabasePlugin {
|
|
6
|
-
static get
|
|
6
|
+
static get id () { return 'elasticsearch' }
|
|
7
7
|
|
|
8
8
|
start ({ params }) {
|
|
9
9
|
const body = getBody(params.body || params.bulkBody)
|
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
const ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
4
4
|
|
|
5
5
|
class GoogleCloudPubsubClientPlugin extends ClientPlugin {
|
|
6
|
-
static get
|
|
6
|
+
static get id () { return 'google-cloud-pubsub' }
|
|
7
7
|
static get operation () { return 'request' }
|
|
8
8
|
|
|
9
|
-
start ({
|
|
10
|
-
if (
|
|
9
|
+
start ({ request, api, projectId }) {
|
|
10
|
+
if (api === 'publish') return
|
|
11
11
|
|
|
12
12
|
this.startSpan('pubsub.request', {
|
|
13
13
|
service: this.config.service || `${this.tracer._service}-pubsub`,
|
|
14
|
-
resource: [
|
|
14
|
+
resource: [api, request.name].filter(x => x).join(' '),
|
|
15
15
|
kind: 'client',
|
|
16
16
|
meta: {
|
|
17
|
-
'pubsub.method':
|
|
17
|
+
'pubsub.method': api,
|
|
18
18
|
'gcloud.project_id': projectId
|
|
19
19
|
}
|
|
20
20
|
})
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const ConsumerPlugin = require('../../dd-trace/src/plugins/consumer')
|
|
4
4
|
|
|
5
5
|
class GoogleCloudPubsubConsumerPlugin extends ConsumerPlugin {
|
|
6
|
-
static get
|
|
6
|
+
static get id () { return 'google-cloud-pubsub' }
|
|
7
7
|
static get operation () { return 'receive' }
|
|
8
8
|
|
|
9
9
|
start ({ message }) {
|
|
@@ -7,7 +7,7 @@ const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
|
7
7
|
|
|
8
8
|
// TODO: Consider splitting channels for publish/receive in the instrumentation.
|
|
9
9
|
class GoogleCloudPubsubPlugin extends CompositePlugin {
|
|
10
|
-
static get
|
|
10
|
+
static get id () { return 'google-cloud-pubsub' }
|
|
11
11
|
static get plugins () {
|
|
12
12
|
return {
|
|
13
13
|
producer: ProducerPlugin,
|
|
@@ -3,20 +3,21 @@
|
|
|
3
3
|
const ProducerPlugin = require('../../dd-trace/src/plugins/producer')
|
|
4
4
|
|
|
5
5
|
class GoogleCloudPubsubProducerPlugin extends ProducerPlugin {
|
|
6
|
-
static get
|
|
6
|
+
static get id () { return 'google-cloud-pubsub' }
|
|
7
7
|
static get operation () { return 'request' }
|
|
8
8
|
|
|
9
|
-
start ({
|
|
10
|
-
if (
|
|
9
|
+
start ({ request, api, projectId }) {
|
|
10
|
+
if (api !== 'publish') return
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const messages = request.messages || []
|
|
13
|
+
const topic = request.topic
|
|
13
14
|
const span = this.startSpan('pubsub.request', { // TODO: rename
|
|
14
15
|
service: this.config.service || `${this.tracer._service}-pubsub`,
|
|
15
|
-
resource: `${
|
|
16
|
+
resource: `${api} ${topic}`,
|
|
16
17
|
kind: 'producer',
|
|
17
18
|
meta: {
|
|
18
19
|
'gcloud.project_id': projectId,
|
|
19
|
-
'pubsub.method':
|
|
20
|
+
'pubsub.method': api, // TODO: remove
|
|
20
21
|
'pubsub.topic': topic
|
|
21
22
|
}
|
|
22
23
|
})
|
|
@@ -5,7 +5,7 @@ const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
|
|
|
5
5
|
let tools
|
|
6
6
|
|
|
7
7
|
class GraphQLExecutePlugin extends TracingPlugin {
|
|
8
|
-
static get
|
|
8
|
+
static get id () { return 'graphql' }
|
|
9
9
|
static get operation () { return 'execute' }
|
|
10
10
|
|
|
11
11
|
start ({ operation, args, docSource }) {
|