Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ jobs:
with:
version: ${{ matrix.node-version }}
- uses: ./.github/actions/install
# TODO: Remove :flaky once flakiness is better
- run: yarn test:plugins:ci:flaky
- run: yarn test:plugins:ci
- if: always()
uses: ./.github/actions/testagent/logs
with:
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/appsec/iast-esbuild.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('esbuild support for IAST', () => {
const craftedNodeModulesDir = path.join(applicationDir, 'tmp_node_modules')
fs.mkdirSync(craftedNodeModulesDir)
await exec('npm init -y', { cwd: craftedNodeModulesDir })
await exec('npm install @datadog/native-iast-rewriter @datadog/native-iast-taint-tracking', {
await exec('npm install @datadog/wasm-js-rewriter @datadog/native-iast-taint-tracking', {
cwd: craftedNodeModulesDir,
timeout: 3e3
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
target: ['node18'],
external: [
'@datadog/native-iast-taint-tracking',
'@datadog/native-iast-rewriter',
'@datadog/wasm-js-rewriter',

// required if you encounter graphql errors during the build step
// see https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/#bundling
Expand Down
17 changes: 14 additions & 3 deletions integration-tests/cypress/cypress.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2414,19 +2414,26 @@ moduleTypes.forEach(({
...restEnvVars
} = getCiVisEvpProxyConfig(receiver.port)

const specToRun = 'cypress/e2e/spec.cy.js'

childProcess = exec(
testCommand,
version === 'latest' ? testCommand : `${testCommand} --spec ${specToRun}`,
{
cwd,
env: {
...restEnvVars,
CYPRESS_BASE_URL: `http://localhost:${webAppPort}`,
DD_TEST_SESSION_NAME: 'my-test-session-name'
DD_TEST_SESSION_NAME: 'my-test-session-name',
SPEC_PATTERN: specToRun,
},
stdio: 'pipe'
}
)

// TODO: remove this once we have figured out flakiness
childProcess.stdout.pipe(process.stdout)
childProcess.stderr.pipe(process.stderr)

await Promise.all([
once(childProcess, 'exit'),
receiverPromise
Expand Down Expand Up @@ -2532,7 +2539,7 @@ moduleTypes.forEach(({
NUM_RETRIES_EFD
)
}
})
}, 25000)

const runImpactedTest = async (
{ isModified, isEfd = false, isNew = false },
Expand Down Expand Up @@ -2562,6 +2569,10 @@ moduleTypes.forEach(({
}
)

// TODO: remove this once we have figured out flakiness
childProcess.stdout.pipe(process.stdout)
childProcess.stderr.pipe(process.stderr)

await Promise.all([
once(childProcess, 'exit'),
testAssertionsPromise
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/esbuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
"express": "4.21.2",
"knex": "3.1.0",
"koa": "3.0.3",
"openai": "6.5.0"
"openai": "6.6.0"
}
}
2 changes: 1 addition & 1 deletion integration-tests/helpers/fake-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ module.exports = class FakeAgent extends EventEmitter {
// where multiple payloads are generated, and only one is expected to have the proper span (ie next.request),
// but it't not guaranteed to be the last one (so, expectedMessageCount would not be helpful).
// It can still fail if it takes longer than `timeout` duration or if none pass the assertions (timeout still called)
assertMessageReceived (fn, timeout, expectedMessageCount = 1, resolveAtFirstSuccess) {
assertMessageReceived (fn, timeout, expectedMessageCount = 1, resolveAtFirstSuccess = true) {
timeout = timeout || 30000
let resultResolve
let resultReject
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,8 @@ async function spawnPluginIntegrationTestProc (cwd, serverFile, agentPort, stdio
additionalEnvArgs = additionalEnvArgs || {}
let env = /** @type {Record<string, string|undefined>} */ ({
NODE_OPTIONS: `--loader=${hookFile}`,
DD_TRACE_AGENT_PORT: String(agentPort)
DD_TRACE_AGENT_PORT: String(agentPort),
DD_TRACE_FLUSH_INTERVAL: '0'
})
env = { ...process.env, ...env, ...additionalEnvArgs }
return spawnProc(path.join(cwd, serverFile), {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dd-trace",
"version": "5.73.0",
"version": "5.73.1",
"description": "Datadog APM tracing client for JavaScript",
"main": "index.js",
"typings": "index.d.ts",
Expand Down
6 changes: 5 additions & 1 deletion packages/datadog-core/src/utils/src/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ module.exports = function set (object, path, value) {
while (true) {
const nextIndex = path.indexOf('.', index + 1)
if (nextIndex === -1) {
object[path.slice(index + 1)] = value
if (index === -1) {
object[path] = value
} else {
object[path.slice(index + 1)] = value
}
return
}
object = object[path.slice(index + 1, nextIndex)] ??= {}
Expand Down
1 change: 1 addition & 0 deletions packages/datadog-plugin-aws-sdk/test/dynamodb.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ async function resetLocalStackDynamo () {
describe('Plugin', () => {
describe('aws-sdk (dynamodb)', function () {
setup()
this.timeout(10000)

withVersions('aws-sdk', ['aws-sdk', '@aws-sdk/smithy-client'], (version, moduleName) => {
let tracer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ const {
const { withVersions } = require('../../../dd-trace/test/setup/mocha')
const { assert, expect } = require('chai')

const spawnEnv = { DD_TRACE_FLUSH_INTERVAL: '2000' }

describe('esm', () => {
let agent
let proc
let sandbox

withVersions('azure-event-hubs', '@azure/event-hubs', version => {
before(async function () {
this.timeout(20000)
this.timeout(60000)
sandbox = await createSandbox([`'@azure/event-hubs@${version}'`], false, [
'./packages/datadog-plugin-azure-event-hubs/test/integration-test/*'])
})
Expand All @@ -42,7 +44,7 @@ describe('esm', () => {
assert.strictEqual(checkSpansForServiceName(payload, 'azure.eventhubs.send'), true)
})

proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port)
proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, spawnEnv)
await res
}).timeout(20000)

Expand Down Expand Up @@ -86,15 +88,15 @@ describe('esm', () => {
assert.strictEqual(parseLinks(payload[4][0]).length, 2)
})

proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port)
proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, spawnEnv)
await res
}).timeout(60000)

it('does not add span links when they are disabled', async () => {
const res = agent.assertMessageReceived(({ headers, payload }) => {
expect(payload[2][0]).to.not.have.property('_dd.span_links')
})
const envVar = { DD_TRACE_AZURE_EVENTHUBS_BATCH_LINKS_ENABLED: false }
const envVar = { DD_TRACE_AZURE_EVENTHUBS_BATCH_LINKS_ENABLED: false, ...spawnEnv }
proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, undefined, envVar)
await res
}).timeout(60000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const {
const { withVersions } = require('../../../dd-trace/test/setup/mocha')
const { assert } = require('chai')

const spawnEnv = { DD_TRACE_FLUSH_INTERVAL: '2000' }

describe('esm', () => {
let agent
let proc
Expand Down Expand Up @@ -40,7 +42,7 @@ describe('esm', () => {
assert.isArray(payload)
})

proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port)
proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, spawnEnv)

await res
}).timeout(20000)
Expand Down Expand Up @@ -151,7 +153,7 @@ describe('esm', () => {
assert.strictEqual(parseLinks(payload[22][0]).length, 2)
})

proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port)
proc = await spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, spawnEnv)

await res
}).timeout(60000)
Expand Down
14 changes: 11 additions & 3 deletions packages/datadog-plugin-langchain/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const { withVersions } = require('../../dd-trace/test/setup/mocha')

const isDdTrace = iastFilter.isDdTrace

const semifies = require('semifies')

describe('Plugin', () => {
let langchainOpenai
let langchainAnthropic
Expand Down Expand Up @@ -114,9 +116,15 @@ describe('Plugin', () => {
langchainTools = require(`../../../versions/@langchain/core@${version}`)
.get('@langchain/core/tools')

MemoryVectorStore = require(`../../../versions/@langchain/core@${version}`)
.get('langchain/vectorstores/memory')
.MemoryVectorStore
if (semifies(realVersion, '>=1.0')) {
MemoryVectorStore = require('../../../versions/@langchain/classic@>=1.0')
.get('@langchain/classic/vectorstores/memory')
.MemoryVectorStore
} else {
MemoryVectorStore = require(`../../../versions/langchain@${version}`)
.get('langchain/vectorstores/memory')
.MemoryVectorStore
}
})

describe('llm', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ describe('esm', () => {
// TODO: Integrate the assertions into the spawn command by adding a
// callback. It should end the process when the assertions are met. That
// way we can remove the Promise.all and the procPromise.then().
const procPromise = spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port)
const procPromise = spawnPluginIntegrationTestProc(sandbox.folder, 'server.mjs', agent.port, {
DD_TRACE_FLUSH_INTERVAL: '2000'
})

await Promise.all([
procPromise.then((res) => {
Expand Down
4 changes: 3 additions & 1 deletion packages/dd-trace/src/config-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ for (const deprecation of Object.keys(deprecations)) {
module.exports = {
/**
* Returns the environment variables that are supported by the tracer
* (including all non-Datadog/OTEL specific environment variables)
* (including all non-Datadog/OTEL specific environment variables).
*
* This should only be called once in config.js to avoid copying the object frequently.
*
* @returns {TracerEnv} The environment variables
*/
Expand Down
Loading