Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
dd231f2
necessary changes for instrumentation toolkit
wconti27 Nov 19, 2025
ce7cd6f
Warning: Generated analysis does not match schema
wconti27 Nov 20, 2025
ad6333c
add new plugin idea
wconti27 Nov 21, 2025
84b9801
mysql fixes
wconti27 Nov 21, 2025
f6f221f
fix tests
wconti27 Nov 21, 2025
a7d5ed9
switch to js implementation of orchestrion
rochdev Nov 9, 2025
56283a3
add new dependencies to 3rd party licenses
rochdev Nov 9, 2025
944c5cc
fix missing return value
rochdev Nov 9, 2025
e6e6ef6
add compatibility layer with old hooks
rochdev Nov 9, 2025
ba96c0d
add disabling rewriter instrumentations
rochdev Nov 9, 2025
4cf468d
add error handling
rochdev Nov 9, 2025
635a018
lazy load rewriter dependencies
rochdev Nov 9, 2025
16a123e
code cleanup
rochdev Nov 9, 2025
0458255
add initial source map support and remove engines option
rochdev Nov 10, 2025
1326bb6
add missing 3rd party licenses
rochdev Nov 10, 2025
512cedd
add support for replacing subclass instance methods from parent
rochdev Nov 11, 2025
8e4be3f
fix namespace
rochdev Nov 11, 2025
8df7fe5
fix invalid transform
rochdev Nov 11, 2025
1ac72bd
fix incorrect binding and channel name
rochdev Nov 11, 2025
d37a0e2
refactor
rochdev Nov 12, 2025
66adb38
fix last langchain test
rochdev Nov 12, 2025
38ce37c
update config file format and clean up code
rochdev Nov 18, 2025
7a516d9
improve startup time for source maps
rochdev Nov 18, 2025
5fdd995
more necessary changes
wconti27 Nov 24, 2025
8a8f11c
linting changes
wconti27 Nov 24, 2025
5e24538
remove mysql changes (moved to conti/mysql-changes branch)
wconti27 Nov 25, 2025
983d047
clean up PR
wconti27 Nov 26, 2025
e8f2c63
fix lint
wconti27 Dec 1, 2025
e1538c5
remove wrappers
wconti27 Dec 2, 2025
c3a4a63
Merge branch 'master' into conti/pre-tooling-changes
wconti27 Dec 2, 2025
f786fb2
remove gitignore change
wconti27 Dec 2, 2025
9dbaa5c
separate instrumentation files
wconti27 Dec 2, 2025
ae2a11a
Merge branch 'conti/pre-tooling-changes' into conti/all-tooling-changes
wconti27 Dec 2, 2025
f0977cb
switch to js implementation of orchestrion
rochdev Nov 9, 2025
ecec599
fix missing return value
rochdev Nov 9, 2025
8921edb
add compatibility layer with old hooks
rochdev Nov 9, 2025
b8a3ae7
add disabling rewriter instrumentations
rochdev Nov 9, 2025
93c19be
add error handling
rochdev Nov 9, 2025
bed129a
lazy load rewriter dependencies
rochdev Nov 9, 2025
015efe8
code cleanup
rochdev Nov 9, 2025
212b8dd
add initial source map support and remove engines option
rochdev Nov 10, 2025
7747b1c
add support for replacing subclass instance methods from parent
rochdev Nov 11, 2025
52ae29f
fix namespace
rochdev Nov 11, 2025
0e1e477
fix invalid transform
rochdev Nov 11, 2025
c52935a
fix incorrect binding and channel name
rochdev Nov 11, 2025
9be9080
refactor
rochdev Nov 12, 2025
cead8e1
fix last langchain test
rochdev Nov 12, 2025
3864f5d
update config file format and clean up code
rochdev Nov 18, 2025
f18b57d
improve startup time for source maps
rochdev Nov 18, 2025
193092a
add comment explaining the purpose of the js rewriter
rochdev Dec 4, 2025
9cd1513
fix missing 3rd party licenses
rochdev Dec 8, 2025
b8e3bf0
fix missing 3rd party licenses
rochdev Dec 8, 2025
9620be2
refactor transforms as code instead of ast
rochdev Dec 10, 2025
40ba348
code cleanup
rochdev Dec 10, 2025
e3a12ec
split instrumentations in individual files
rochdev Dec 10, 2025
2c7249f
code cleanup
rochdev Dec 10, 2025
7418690
add support for traceCallback
rochdev Dec 11, 2025
a5782af
add basic tests
rochdev Dec 11, 2025
b6c7cf5
code cleanup
rochdev Dec 11, 2025
beb0432
fix test
rochdev Dec 11, 2025
ed547ca
update comment to reflect the new plan
rochdev Dec 11, 2025
47e5adb
fix incorrect dependency and usage from merge
rochdev Dec 11, 2025
a966fc2
merge with orchestrion-js
wconti27 Dec 12, 2025
e503c31
delete langchain
wconti27 Dec 12, 2025
35026f7
Merge branch 'master' into conti/all-tooling-changes
wconti27 Dec 12, 2025
0df1ace
remove files
wconti27 Dec 12, 2025
08c23e1
actually remove file changes
wconti27 Dec 12, 2025
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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,10 @@ packages/datadog-plugin-azure-functions/test/integration-test/fixtures/node_modu
__azurite_db_queue__.json
__azurite_db_queue_extent__.json
__queuestorage__/AzuriteConfig


# ignore apm-instrumentation-toolkit analysis results dirs
.analysis/

# ignore claude settings
.claude/
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default [
'**/versions', // This is effectively a node_modules tree.
'**/acmeair-nodejs', // We don't own this.
'**/vendor', // Generally, we didn't author this code.
'**/.analysis', // Ignore apm-instrumentation-toolkit analysis results
'integration-tests/code-origin/typescript.js', // Generated
'integration-tests/debugger/target-app/source-map-support/bundle.js', // Generated
'integration-tests/debugger/target-app/source-map-support/hello/world.js', // Generated
Expand Down
26 changes: 18 additions & 8 deletions integration-tests/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ const { DEBUG } = process.env
// This is set by the setShouldKill function
let shouldKill

// Symbol constants for dynamic value matching in assertObjectContains
const ANY_STRING = Symbol.for('test.ANY_STRING')
const ANY_NUMBER = Symbol.for('test.ANY_NUMBER')
const ANY_VALUE = Symbol.for('test.ANY_VALUE')

/**
* @param {string} filename
* @param {string} cwd
Expand Down Expand Up @@ -57,7 +62,7 @@ async function runAndCheckOutput (filename, cwd, expectedOut, expectedSource) {

if (expectedSource) {
assert.match(out, new RegExp(`instrumentation source: ${expectedSource}`),
`Expected the process to output "${expectedSource}", but logs only contain: "${out}"`)
`Expected the process to output "${expectedSource}", but logs only contain: "${out}"`)
}
return pid
}
Expand All @@ -80,9 +85,9 @@ async function runAndCheckWithTelemetry (filename, expectedOut, expectedTelemetr
const msgs = await cleanup()
if (expectedTelemetryPoints.length === 0) {
// assert no telemetry sent
assert.strictEqual(msgs.length, 0, `Expected no telemetry, but got:\n${
msgs.map(msg => JSON.stringify(msg[1].points)).join('\n')
}`)
assert.strictEqual(
msgs.length, 0, `Expected no telemetry, but got:\n${msgs.map(msg => JSON.stringify(msg[1].points)).join('\n')
}`)
} else {
assertTelemetryPoints(pid, msgs, expectedTelemetryPoints)
}
Expand Down Expand Up @@ -633,9 +638,8 @@ function setShouldKill (value) {
})
}

// @ts-expect-error assert.partialDeepStrictEqual does not exist on older Node.js versions
// eslint-disable-next-line n/no-unsupported-features/node-builtins
const assertObjectContains = assert.partialDeepStrictEqual || function assertObjectContains (actual, expected) {
// we use our own assertObjectContains, to account for any types
const assertObjectContains = function assertObjectContains (actual, expected) {
if (Array.isArray(expected)) {
assert.ok(Array.isArray(actual), `Expected array but got ${typeof actual}`)
let startIndex = 0
Expand All @@ -662,7 +666,13 @@ const assertObjectContains = assert.partialDeepStrictEqual || function assertObj
}

for (const [key, val] of Object.entries(expected)) {
if (val !== null && typeof val === 'object') {
if (val === ANY_STRING) {
assert.strictEqual(typeof actual[key], 'string', `Expected ${key} to be a string but got ${typeof actual[key]}`)
} else if (val === ANY_NUMBER) {
assert.strictEqual(typeof actual[key], 'number', `Expected ${key} to be a number but got ${typeof actual[key]}`)
} else if (val === ANY_VALUE) {
assert.ok(actual[key] !== undefined, `Expected ${key} to be present but it was undefined`)
} else if (val !== null && typeof val === 'object') {
assert.ok(Object.hasOwn(actual, key))
assert.notStrictEqual(actual[key], null)
assert.strictEqual(typeof actual[key], 'object')
Expand Down
10 changes: 8 additions & 2 deletions packages/dd-trace/src/plugins/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ const StoragePlugin = require('./storage')
class CachePlugin extends StoragePlugin {
static operation = 'command'

startSpan (options, ctx) {
startSpan (name, options, ctx) {
if (typeof name === 'object' && name !== null && ctx === undefined) {
ctx = options
options = name
name = this.operationName()
}

if (!options.kind) {
options.kind = this.constructor.kind
}
return super.startSpan(this.operationName(), options, ctx)
return super.startSpan(name, options, ctx)
}
}

Expand Down
10 changes: 8 additions & 2 deletions packages/dd-trace/src/plugins/consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ class ConsumerPlugin extends InboundPlugin {
static kind = 'consumer'
static type = 'messaging'

startSpan (options, enterOrCtx) {
startSpan (name, options, enterOrCtx) {
if (typeof name === 'object' && name !== null && enterOrCtx === undefined) {
enterOrCtx = options
options = name
name = this.operationName()
}

if (!options.service) {
options.service = this.config.service || this.serviceName()
}
if (!options.kind) {
options.kind = this.constructor.kind
}
return super.startSpan(this.operationName(), options, enterOrCtx)
return super.startSpan(name, options, enterOrCtx)
}
}

Expand Down
10 changes: 8 additions & 2 deletions packages/dd-trace/src/plugins/producer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ class ProducerPlugin extends OutboundPlugin {
static kind = 'producer'
static type = 'messaging'

startSpan (options, enterOrCtx) {
startSpan (name, options, enterOrCtx) {
if (typeof name === 'object' && name !== null && enterOrCtx === undefined) {
enterOrCtx = options
options = name
name = this.operationName()
}

const spanDefaults = {
kind: this.constructor.kind
}
Expand All @@ -19,7 +25,7 @@ class ProducerPlugin extends OutboundPlugin {
if (!options[key]) options[key] = spanDefaults[key]
}
)
return super.startSpan(this.operationName(), options, enterOrCtx)
return super.startSpan(name, options, enterOrCtx)
}
}

Expand Down
20 changes: 12 additions & 8 deletions packages/dd-trace/src/plugins/tracing.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,35 @@ class TracingPlugin extends Plugin {
this.addError(ctxOrError)
}

addTraceSubs () {
registerOperation (channelName) {
this.addTraceSubs(channelName)
}

addTraceSubs (channelName) {
const events = ['start', 'end', 'asyncStart', 'asyncEnd', 'error', 'finish']

for (const event of events) {
const bindName = `bind${event.charAt(0).toUpperCase()}${event.slice(1)}`

if (this[event]) {
this.addTraceSub(event, message => {
this[event](message)
})
this[event](message, channelName)
}, channelName)
}

if (this[bindName]) {
this.addTraceBind(event, message => this[bindName](message))
this.addTraceBind(event, message => this[bindName](message, channelName), channelName)
}
}
}

addTraceSub (eventName, handler) {
const prefix = this.constructor.prefix || `apm:${this.component}:${this.operation}`
addTraceSub (eventName, handler, channelName) {
const prefix = channelName || this.constructor.prefix || `apm:${this.component}:${this.operation}`
this.addSub(`${prefix}:${eventName}`, handler)
}

addTraceBind (eventName, transform) {
const prefix = this.constructor.prefix || `apm:${this.component}:${this.operation}`
addTraceBind (eventName, transform, channelName) {
const prefix = channelName || this.constructor.prefix || `apm:${this.component}:${this.operation}`
this.addBind(`${prefix}:${eventName}`, transform)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
'use strict'

const { describe, it, beforeEach, afterEach, before, after } = require('mocha')
const { expect } = require('chai')
const agent = require('../../../plugins/agent')
const { withVersions } = require('../../mocha')

function createIntegrationTestSuite (pluginName, packageName, testSetup, options, testCallback) {
describe('Plugin', () => {
describe(pluginName, () => {
withVersions(pluginName, packageName, version => {
createVersionedTests(pluginName, packageName, testSetup, options, version, testCallback)
})
})
})
}

function createVersionedTests (pluginName, packageName, testSetup, options = {}, version, testCallback) {
let tracer = null
let mod = null

describe('without configuration', () => {
before(async () => {
const plugins = [pluginName, ...(options.additionalPlugins || [])]
const pluginConfigs = [options.pluginConfig || {}, ...(options.additionalPlugins || []).map(() => ({}))]
await agent.load(plugins, pluginConfigs)
})

after(async () => {
await agent.close({ ritmReset: false })
})

before(async () => {
tracer = require('../../../../../dd-trace').init()
mod = require(`../../../../../../versions/${packageName}@${version}`)
mod = options.subModule ? mod.get(options.subModule) : mod.get()
await testSetup.setup(mod)
})

after(async () => {
if (testSetup?.teardown) {
await testSetup.teardown()
}
})

if (testCallback) {
testCallback({
testSetup,
agent,
tracer,
expect,
describe,
it,
beforeEach,
afterEach,
mod
})
}
})
}

module.exports = { createIntegrationTestSuite }
Loading