Skip to content

Commit

Permalink
Merge branch 'master' into igor/standalone-apm
Browse files Browse the repository at this point in the history
  • Loading branch information
iunanua authored Feb 19, 2025
2 parents 25c3276 + 172bc66 commit 8779cd6
Show file tree
Hide file tree
Showing 14 changed files with 196 additions and 193 deletions.
2 changes: 1 addition & 1 deletion .gitlab/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ variables:
tags: ["runner:apm-k8s-tweaked-metal"]
image: $MICROBENCHMARKS_CI_IMAGE
interruptible: true
timeout: 15m
timeout: 20m
script:
- git clone --branch dd-trace-js https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/DataDog/benchmarking-platform platform && cd platform
- bp-runner bp-runner.yml --debug
Expand Down
6 changes: 2 additions & 4 deletions benchmark/sirun/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ RUN wget -O sirun.tar.gz https://github.com/DataDog/sirun/releases/download/v0.1
RUN mkdir -p /usr/local/nvm \
&& wget -q -O - https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install --no-progress 14.21.3 \
&& nvm install --no-progress 16.20.1 \
&& nvm install --no-progress 18.16.1 \
&& nvm install --no-progress 20.4.0 \
&& nvm install --no-progress 22.10.0 \
&& nvm alias default 18 \
&& nvm use 18
&& nvm alias default 22 \
&& nvm use 22

RUN mkdir /opt/insecure-bank-js
RUN git clone --depth 1 https://github.com/hdiv/insecure-bank-js.git /opt/insecure-bank-js
Expand Down
2 changes: 1 addition & 1 deletion benchmark/sirun/plugin-graphql/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"run": "node index.js",
"run_with_affinity": "bash -c \"taskset -c $CPU_AFFINITY node index.js\"",
"cachegrind": false,
"iterations": 2,
"iterations": 30,
"instructions": true,
"variants": {
"control": {},
Expand Down
4 changes: 2 additions & 2 deletions benchmark/sirun/plugin-graphql/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const Human = new graphql.GraphQLObjectType({
async resolve (obj, args) {
const promises = []

for (let i = 0; i < 100; i++) {
for (let i = 0; i < 20; i++) {
promises.push(await Promise.resolve({}))
}

Expand All @@ -115,7 +115,7 @@ const schema = new graphql.GraphQLSchema({
async resolve (obj, args) {
const promises = []

for (let i = 0; i < 100; i++) {
for (let i = 0; i < 20; i++) {
promises.push(await Promise.resolve({}))
}

Expand Down
22 changes: 8 additions & 14 deletions integration-tests/cucumber/cucumber.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1587,7 +1587,7 @@ versions.forEach(version => {
})
// Dynamic instrumentation only supported from >=8.0.0
context('dynamic instrumentation', () => {
it('does not activate if DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED is not set', (done) => {
it('does not activate if DD_TEST_FAILED_TEST_REPLAY_ENABLED is set to false', (done) => {
receiver.setSettings({
flaky_test_retries_enabled: true,
di_enabled: true
Expand Down Expand Up @@ -1621,7 +1621,10 @@ versions.forEach(version => {
'./node_modules/.bin/cucumber-js ci-visibility/features-di/test-hit-breakpoint.feature --retry 1',
{
cwd,
env: envVars,
env: {
...envVars,
DD_TEST_FAILED_TEST_REPLAY_ENABLED: 'false'
},
stdio: 'pipe'
}
)
Expand Down Expand Up @@ -1666,10 +1669,7 @@ versions.forEach(version => {
'./node_modules/.bin/cucumber-js ci-visibility/features-di/test-hit-breakpoint.feature --retry 1',
{
cwd,
env: {
...envVars,
DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED: 'true'
},
env: envVars,
stdio: 'pipe'
}
)
Expand Down Expand Up @@ -1748,10 +1748,7 @@ versions.forEach(version => {
'./node_modules/.bin/cucumber-js ci-visibility/features-di/test-hit-breakpoint.feature --retry 1',
{
cwd,
env: {
...envVars,
DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED: 'true'
},
env: envVars,
stdio: 'pipe'
}
)
Expand Down Expand Up @@ -1800,10 +1797,7 @@ versions.forEach(version => {
'./node_modules/.bin/cucumber-js ci-visibility/features-di/test-not-hit-breakpoint.feature --retry 1',
{
cwd,
env: {
...envVars,
DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED: 'true'
},
env: envVars,
stdio: 'pipe'
}
)
Expand Down
12 changes: 4 additions & 8 deletions integration-tests/jest/jest.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ describe('jest CommonJS', () => {
}).catch(done)
})

it('can work with Dynamic Instrumentation', (done) => {
it('can work with Failed Test Replay', (done) => {
receiver.setSettings({
flaky_test_retries_enabled: true,
di_enabled: true
Expand Down Expand Up @@ -565,7 +565,6 @@ describe('jest CommonJS', () => {
env: {
...getCiVisAgentlessConfig(receiver.port),
TESTS_TO_RUN: 'dynamic-instrumentation/test-',
DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED: 'true',
DD_CIVISIBILITY_FLAKY_RETRY_COUNT: '1',
RUN_IN_PARALLEL: true
},
Expand Down Expand Up @@ -2537,7 +2536,7 @@ describe('jest CommonJS', () => {
})

context('dynamic instrumentation', () => {
it('does not activate dynamic instrumentation if DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED is not set', (done) => {
it('does not activate dynamic instrumentation if DD_TEST_FAILED_TEST_REPLAY_ENABLED is set to false', (done) => {
receiver.setSettings({
flaky_test_retries_enabled: true,
di_enabled: true
Expand Down Expand Up @@ -2571,7 +2570,8 @@ describe('jest CommonJS', () => {
env: {
...getCiVisAgentlessConfig(receiver.port),
TESTS_TO_RUN: 'dynamic-instrumentation/test-hit-breakpoint',
DD_CIVISIBILITY_FLAKY_RETRY_COUNT: '1'
DD_CIVISIBILITY_FLAKY_RETRY_COUNT: '1',
DD_TEST_FAILED_TEST_REPLAY_ENABLED: 'false'
},
stdio: 'inherit'
}
Expand Down Expand Up @@ -2618,7 +2618,6 @@ describe('jest CommonJS', () => {
env: {
...getCiVisAgentlessConfig(receiver.port),
TESTS_TO_RUN: 'dynamic-instrumentation/test-hit-breakpoint',
DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED: 'true',
DD_CIVISIBILITY_FLAKY_RETRY_COUNT: '1'
},
stdio: 'inherit'
Expand Down Expand Up @@ -2703,7 +2702,6 @@ describe('jest CommonJS', () => {
env: {
...getCiVisAgentlessConfig(receiver.port),
TESTS_TO_RUN: 'dynamic-instrumentation/test-hit-breakpoint',
DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED: 'true',
DD_CIVISIBILITY_FLAKY_RETRY_COUNT: '1'
},
stdio: 'inherit'
Expand Down Expand Up @@ -2753,7 +2751,6 @@ describe('jest CommonJS', () => {
env: {
...getCiVisAgentlessConfig(receiver.port),
TESTS_TO_RUN: 'dynamic-instrumentation/test-not-hit-breakpoint',
DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED: 'true',
DD_CIVISIBILITY_FLAKY_RETRY_COUNT: '1'
},
stdio: 'inherit'
Expand Down Expand Up @@ -2793,7 +2790,6 @@ describe('jest CommonJS', () => {
env: {
...getCiVisAgentlessConfig(receiver.port),
TESTS_TO_RUN: 'dynamic-instrumentation/test-hit-breakpoint',
DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED: 'true',
DD_CIVISIBILITY_FLAKY_RETRY_COUNT: '1',
TEST_SHOULD_PASS_AFTER_RETRY: '1'
},
Expand Down
8 changes: 3 additions & 5 deletions integration-tests/mocha/mocha.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2209,7 +2209,7 @@ describe('mocha CommonJS', function () {
})

context('dynamic instrumentation', () => {
it('does not activate dynamic instrumentation if DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED is not set', (done) => {
it('does not activate dynamic instrumentation if DD_TEST_FAILED_TEST_REPLAY_ENABLED is set to false', (done) => {
receiver.setSettings({
flaky_test_retries_enabled: true,
di_enabled: true
Expand Down Expand Up @@ -2247,7 +2247,8 @@ describe('mocha CommonJS', function () {
TESTS_TO_RUN: JSON.stringify([
'./dynamic-instrumentation/test-hit-breakpoint'
]),
DD_CIVISIBILITY_FLAKY_RETRY_COUNT: '1'
DD_CIVISIBILITY_FLAKY_RETRY_COUNT: '1',
DD_TEST_FAILED_TEST_REPLAY_ENABLED: 'false'
},
stdio: 'inherit'
}
Expand Down Expand Up @@ -2299,7 +2300,6 @@ describe('mocha CommonJS', function () {
TESTS_TO_RUN: JSON.stringify([
'./dynamic-instrumentation/test-hit-breakpoint'
]),
DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED: 'true',
DD_CIVISIBILITY_FLAKY_RETRY_COUNT: '1'
},
stdio: 'inherit'
Expand Down Expand Up @@ -2389,7 +2389,6 @@ describe('mocha CommonJS', function () {
TESTS_TO_RUN: JSON.stringify([
'./dynamic-instrumentation/test-hit-breakpoint'
]),
DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED: 'true',
DD_CIVISIBILITY_FLAKY_RETRY_COUNT: '1'
},
stdio: 'inherit'
Expand Down Expand Up @@ -2443,7 +2442,6 @@ describe('mocha CommonJS', function () {
TESTS_TO_RUN: JSON.stringify([
'./dynamic-instrumentation/test-not-hit-breakpoint'
]),
DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED: 'true',
DD_CIVISIBILITY_FLAKY_RETRY_COUNT: '1'
},
stdio: 'inherit'
Expand Down
14 changes: 6 additions & 8 deletions integration-tests/vitest/vitest.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ versions.forEach((version) => {
// dynamic instrumentation only supported from >=2.0.0
if (version === 'latest') {
context('dynamic instrumentation', () => {
it('does not activate it if DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED is not set', (done) => {
it('does not activate it if DD_TEST_FAILED_TEST_REPLAY_ENABLED is set to false', (done) => {
receiver.setSettings({
flaky_test_retries_enabled: true,
di_enabled: true
Expand Down Expand Up @@ -1025,7 +1025,8 @@ versions.forEach((version) => {
env: {
...getCiVisAgentlessConfig(receiver.port),
TEST_DIR: 'ci-visibility/vitest-tests/dynamic-instrumentation*',
NODE_OPTIONS: '--import dd-trace/register.js -r dd-trace/ci/init'
NODE_OPTIONS: '--import dd-trace/register.js -r dd-trace/ci/init',
DD_TEST_FAILED_TEST_REPLAY_ENABLED: 'false'
},
stdio: 'pipe'
}
Expand Down Expand Up @@ -1075,8 +1076,7 @@ versions.forEach((version) => {
env: {
...getCiVisAgentlessConfig(receiver.port),
TEST_DIR: 'ci-visibility/vitest-tests/dynamic-instrumentation*',
NODE_OPTIONS: '--import dd-trace/register.js -r dd-trace/ci/init',
DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED: '1'
NODE_OPTIONS: '--import dd-trace/register.js -r dd-trace/ci/init'
},
stdio: 'pipe'
}
Expand Down Expand Up @@ -1162,8 +1162,7 @@ versions.forEach((version) => {
env: {
...getCiVisAgentlessConfig(receiver.port),
TEST_DIR: 'ci-visibility/vitest-tests/dynamic-instrumentation*',
NODE_OPTIONS: '--import dd-trace/register.js -r dd-trace/ci/init',
DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED: '1'
NODE_OPTIONS: '--import dd-trace/register.js -r dd-trace/ci/init'
},
stdio: 'pipe'
}
Expand Down Expand Up @@ -1217,8 +1216,7 @@ versions.forEach((version) => {
env: {
...getCiVisAgentlessConfig(receiver.port),
TEST_DIR: 'ci-visibility/vitest-tests/breakpoint-not-hit*',
NODE_OPTIONS: '--import dd-trace/register.js -r dd-trace/ci/init',
DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED: '1'
NODE_OPTIONS: '--import dd-trace/register.js -r dd-trace/ci/init'
},
stdio: 'pipe'
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
"checksum": "^1.0.0",
"cli-table3": "^0.6.3",
"dotenv": "16.3.1",
"esbuild": "0.16.12",
"esbuild": "^0.25.0",
"eslint": "^9.19.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.31.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class TestVisDynamicInstrumentation {
env: {
...process.env,
DD_TRACE_ENABLED: 0,
DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED: 0
DD_TEST_FAILED_TEST_REPLAY_ENABLED: 0
},
workerData: {
config: config.serialize(),
Expand Down
4 changes: 2 additions & 2 deletions packages/dd-trace/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ class Config {
DD_CIVISIBILITY_FLAKY_RETRY_COUNT,
DD_TEST_SESSION_NAME,
DD_AGENTLESS_LOG_SUBMISSION_ENABLED,
DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED,
DD_TEST_FAILED_TEST_REPLAY_ENABLED,
DD_TEST_MANAGEMENT_ENABLED,
DD_TEST_MANAGEMENT_ATTEMPT_TO_FIX_RETRIES
} = process.env
Expand All @@ -1171,7 +1171,7 @@ class Config {
this._setBoolean(calc, 'isManualApiEnabled', !isFalse(this._isCiVisibilityManualApiEnabled()))
this._setString(calc, 'ciVisibilityTestSessionName', DD_TEST_SESSION_NAME)
this._setBoolean(calc, 'ciVisAgentlessLogSubmissionEnabled', isTrue(DD_AGENTLESS_LOG_SUBMISSION_ENABLED))
this._setBoolean(calc, 'isTestDynamicInstrumentationEnabled', isTrue(DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED))
this._setBoolean(calc, 'isTestDynamicInstrumentationEnabled', !isFalse(DD_TEST_FAILED_TEST_REPLAY_ENABLED))
this._setBoolean(calc, 'isServiceUserProvided', !!this._env.service)
this._setBoolean(calc, 'isTestManagementEnabled', !isFalse(DD_TEST_MANAGEMENT_ENABLED))
this._setValue(calc,
Expand Down
8 changes: 4 additions & 4 deletions packages/dd-trace/src/plugins/ci_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,15 @@ module.exports = class CiPlugin extends Plugin {
configure (config, shouldGetEnvironmentData = true) {
super.configure(config)

if (!shouldGetEnvironmentData) {
return
}

if (config.isTestDynamicInstrumentationEnabled && !this.di) {
const testVisibilityDynamicInstrumentation = require('../ci-visibility/dynamic-instrumentation')
this.di = testVisibilityDynamicInstrumentation
}

if (!shouldGetEnvironmentData) {
return
}

this.testEnvironmentMetadata = getTestEnvironmentMetadata(this.constructor.id, this.config)

const {
Expand Down
15 changes: 8 additions & 7 deletions packages/dd-trace/test/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2032,7 +2032,7 @@ describe('Config', () => {
delete process.env.DD_CIVISIBILITY_FLAKY_RETRY_COUNT
delete process.env.DD_TEST_SESSION_NAME
delete process.env.JEST_WORKER_ID
delete process.env.DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED
delete process.env.DD_TEST_FAILED_TEST_REPLAY_ENABLED
delete process.env.DD_AGENTLESS_LOG_SUBMISSION_ENABLED
options = {}
})
Expand Down Expand Up @@ -2131,15 +2131,16 @@ describe('Config', () => {
const config = new Config(options)
expect(config).to.have.property('ciVisAgentlessLogSubmissionEnabled', true)
})
it('should not set isTestDynamicInstrumentationEnabled by default', () => {
const config = new Config(options)
expect(config).to.have.property('isTestDynamicInstrumentationEnabled', false)
})
it('should set isTestDynamicInstrumentationEnabled if DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED is passed', () => {
process.env.DD_TEST_DYNAMIC_INSTRUMENTATION_ENABLED = 'true'
it('should set isTestDynamicInstrumentationEnabled by default', () => {
const config = new Config(options)
expect(config).to.have.property('isTestDynamicInstrumentationEnabled', true)
})
it('should set isTestDynamicInstrumentationEnabled to false if DD_TEST_FAILED_TEST_REPLAY_ENABLED is false',
() => {
process.env.DD_TEST_FAILED_TEST_REPLAY_ENABLED = 'false'
const config = new Config(options)
expect(config).to.have.property('isTestDynamicInstrumentationEnabled', false)
})
})
context('ci visibility mode is not enabled', () => {
it('should not activate intelligent test runner or git metadata upload', () => {
Expand Down
Loading

0 comments on commit 8779cd6

Please sign in to comment.