Skip to content
Merged
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
140 changes: 140 additions & 0 deletions .github/workflows/apm-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@ jobs:
api_key: ${{ secrets.DD_API_KEY }}
service: dd-trace-js-tests

crypto:
runs-on: ubuntu-latest
env:
PLUGINS: crypto
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
- uses: ./.github/actions/plugins/test
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

confluentinc-kafka-javascript:
strategy:
matrix:
Expand Down Expand Up @@ -267,6 +277,16 @@ jobs:
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

cookie:
runs-on: ubuntu-latest
env:
PLUGINS: cookie
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
- uses: ./.github/actions/plugins/test
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

couchbase:
strategy:
matrix:
Expand Down Expand Up @@ -434,6 +454,16 @@ jobs:
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

generic-pool:
runs-on: ubuntu-latest
env:
PLUGINS: generic-pool
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: ./.github/actions/plugins/test
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

graphql:
runs-on: ubuntu-latest
env:
Expand All @@ -454,6 +484,16 @@ jobs:
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

handlebars:
runs-on: ubuntu-latest
env:
PLUGINS: handlebars
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
- uses: ./.github/actions/plugins/test
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

hapi:
runs-on: ubuntu-latest
env:
Expand Down Expand Up @@ -577,6 +617,16 @@ jobs:
api_key: ${{ secrets.DD_API_KEY }}
service: dd-trace-js-tests

knex:
runs-on: ubuntu-latest
env:
PLUGINS: knex
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: ./.github/actions/plugins/test
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

koa:
runs-on: ubuntu-latest
env:
Expand All @@ -587,6 +637,16 @@ jobs:
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

ldapjs:
runs-on: 'ubuntu-latest'
env:
PLUGINS: ldapjs
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: ./.github/actions/plugins/test
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

limitd-client:
runs-on: ubuntu-latest
services:
Expand All @@ -607,6 +667,16 @@ jobs:
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

lodash:
runs-on: 'ubuntu-latest'
env:
PLUGINS: lodash
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: ./.github/actions/plugins/test
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

mariadb:
runs-on: ubuntu-latest
services:
Expand Down Expand Up @@ -712,6 +782,16 @@ jobs:
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

multer:
runs-on: ubuntu-latest
env:
PLUGINS: multer
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
- uses: ./.github/actions/plugins/test
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

mysql:
runs-on: ubuntu-latest
services:
Expand Down Expand Up @@ -833,6 +913,16 @@ jobs:
api_key: ${{ secrets.DD_API_KEY }}
service: dd-trace-js-tests

node-serialize:
runs-on: ubuntu-latest
env:
PLUGINS: node-serialize
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: ./.github/actions/plugins/test
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

opensearch:
runs-on: ubuntu-latest
services:
Expand Down Expand Up @@ -963,6 +1053,16 @@ jobs:
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

process:
runs-on: ubuntu-latest
env:
PLUGINS: process
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
- uses: ./.github/actions/plugins/test
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

protobufjs:
runs-on: ubuntu-latest
env:
Expand All @@ -974,6 +1074,16 @@ jobs:
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

pug:
runs-on: ubuntu-latest
env:
PLUGINS: pug
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
- uses: ./.github/actions/plugins/test
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

redis:
runs-on: ubuntu-latest
services:
Expand Down Expand Up @@ -1067,6 +1177,16 @@ jobs:
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

sequelize:
runs-on: ubuntu-latest
env:
PLUGINS: sequelize
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
- uses: ./.github/actions/plugins/test
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

sharedb:
runs-on: ubuntu-latest
env:
Expand Down Expand Up @@ -1130,6 +1250,26 @@ jobs:
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

url:
runs-on: ubuntu-latest
env:
PLUGINS: url
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
- uses: ./.github/actions/plugins/test
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

vm:
runs-on: ubuntu-latest
env:
PLUGINS: vm
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
- uses: ./.github/actions/plugins/test
with:
dd_api_key: ${{ secrets.DD_API_KEY }}

winston:
runs-on: ubuntu-latest
env:
Expand Down
35 changes: 24 additions & 11 deletions packages/datadog-instrumentations/test/knex.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
const { expect } = require('chai')
const { describe, it, beforeEach, afterEach } = require('mocha')

const agent = require('../../dd-trace/test/plugins/agent')
const { storage } = require('../../datadog-core')
const { withVersions } = require('../../dd-trace/test/setup/mocha')

require('../src/knex')

describe('Instrumentation', () => {
let knex
let client
Expand All @@ -16,27 +15,41 @@ describe('Instrumentation', () => {
describe('knex', () => {
withVersions('knex', 'knex', version => {
describe('without configuration', () => {
/**
* TODO (Pablo Erhard): Implement a single mechanism to automatically trigger hook loading
* across all tests. This should allow test hooks to initialize programmatically
* without requiring explicit `agent.load()` calls in every individual test file.
*/
before(async () => {
await agent.load()
})

beforeEach(() => {
knex = require(`../../../versions/knex@${version}`).get()
client = knex({
client: 'pg',
client: 'sqlite3',
connection: {
filename: ':memory:'
}
})
})

afterEach(() => client.destroy())
after(async () => {
await agent.close()
})

it('should propagate context', () =>
storage('legacy').run(store, () =>
client.raw('PRAGMA user_version')
.finally(() => {
expect(storage('legacy').getStore()).to.equal(store)
})
.catch(() => {})
it('should propagate context', async () => {
let isInstrumented = false

await storage('legacy').run(store, () =>
client.raw('PRAGMA user_version').then(() => {
isInstrumented = storage('legacy').getStore() === store
}).catch(() => {})
)
)

expect(isInstrumented).to.equal(true)
})
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const {
sandboxCwd, useSandbox, varySandbox, curl,
FakeAgent, spawnPluginIntegrationTestProc
} = require('../../../../integration-tests/helpers')
const { assert } = require('chai')
const assert = require('node:assert/strict')
const { withVersions } = require('../../../dd-trace/test/setup/mocha')

withVersions('cookie-parser', 'cookie-parser', version => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict'

const {
sandboxCwd, useSandbox, varySandbox, curl,
FakeAgent, spawnPluginIntegrationTestProc
} = require('../../../../integration-tests/helpers')
const assert = require('node:assert/strict')
const { withVersions } = require('../../../dd-trace/test/setup/mocha')

withVersions('cookie', 'cookie', version => {
describe('ESM', () => {
let variants, proc, agent

useSandbox([`'cookie@${version}'`, 'express'], false,
['./packages/datadog-plugin-cookie/test/integration-test/*'])

before(function () {
variants = varySandbox('server.mjs', 'cookie')
})

beforeEach(async () => {
agent = await new FakeAgent().start()
})

afterEach(async () => {
proc?.kill()
await agent.stop()
})

for (const variant of varySandbox.VARIANTS) {
it(`is instrumented loaded with ${variant}`, async () => {
proc = await spawnPluginIntegrationTestProc(sandboxCwd(), variants[variant], agent.port)
const response = await curl(proc)
assert.equal(response.headers['x-counter'], '1')
})
}
})
})
23 changes: 23 additions & 0 deletions packages/datadog-plugin-cookie/test/integration-test/server.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'dd-trace/init.js'
import express from 'express'
import cookie from 'cookie'
import dc from 'dc-polyfill'

const cookieParseCh = dc.channel('datadog:cookie:parse:finish')
let counter = 0
cookieParseCh.subscribe(() => {
counter += 1
})

const app = express()

app.get('/', (req, res) => {
cookie.parse('hello=world')
res.setHeader('X-Counter', counter)
res.end('ok')
})

const server = app.listen(0, () => {
const port = server.address().port
process.send({ port })
})
Loading