Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3.45.0 proposal #3967

Merged
merged 14 commits into from
Jan 17, 2024
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
14 changes: 3 additions & 11 deletions .github/workflows/appsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,25 +214,17 @@ jobs:
- uses: codecov/codecov-action@v3

next:
strategy:
matrix:
node-version: [16]
range: ['>=9.5 <11.1', '>=11.1 <13.2']
include:
- node-version: 18
range: '>=13.2'
runs-on: ubuntu-latest
env:
PLUGINS: next
RANGE: ${{ matrix.range }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/testagent/start
- uses: ./.github/actions/node/setup
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: yarn install
- uses: ./.github/actions/node/oldest
- run: yarn test:appsec:plugins:ci
- uses: ./.github/actions/node/latest
- run: yarn test:appsec:plugins:ci
- if: always()
uses: ./.github/actions/testagent/logs
Expand Down
14 changes: 3 additions & 11 deletions .github/workflows/plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -906,25 +906,17 @@ jobs:

# TODO: fix performance issues and test more Node versions
next:
strategy:
matrix:
node-version: [14, 16]
range: ['>=9.5 <11.1', '>=11.1 <13.2']
include:
- node-version: 18
range: '>=13.2'
runs-on: ubuntu-latest
env:
PLUGINS: next
RANGE: ${{ matrix.range }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/testagent/start
- uses: ./.github/actions/node/setup
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: yarn install
- uses: ./.github/actions/node/oldest
- run: yarn test:plugins:ci
- uses: ./.github/actions/node/latest
- run: yarn test:plugins:ci
- if: always()
uses: ./.github/actions/testagent/logs
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/release-4.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Release (4.x)

on:
push:
branches:
- v4.x

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
publish:
runs-on: ubuntu-latest
environment: npm
permissions:
id-token: write
contents: write
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org'
- run: npm publish --tag latest-node16 --provenance
- id: pkg
run: |
content=`cat ./package.json | tr '\n' ' '`
echo "json=$content" >> $GITHUB_OUTPUT
- run: |
git tag v${{ fromJson(steps.pkg.outputs.json).version }}
git push origin v${{ fromJson(steps.pkg.outputs.json).version }}

injection-image-publish:
runs-on: ubuntu-latest
needs: ['publish']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- name: Log in to the Container registry
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: pkg
run: |
content=`cat ./package.json | tr '\n' ' '`
echo "json=$content" >> $GITHUB_OUTPUT
- name: npm pack for injection image
run: |
npm pack dd-trace@${{ fromJson(steps.pkg.outputs.json).version }}
- uses: ./.github/actions/injection
with:
init-image-version: v${{ fromJson(steps.pkg.outputs.json).version }}
2 changes: 1 addition & 1 deletion .github/workflows/release-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Release (latest)
on:
push:
branches:
- v4.x
- v5.x

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
Expand Down
21 changes: 19 additions & 2 deletions integration-tests/ci-visibility.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ testFrameworks.forEach(({
const events = payloads.flatMap(({ payload }) => payload.events)
const suites = events.filter(event => event.type === 'test_suite_end')

assert.equal(suites.length, 2)
assert.equal(suites.length, 3)

const testSession = events.find(event => event.type === 'test_session_end').content
const testModule = events.find(event => event.type === 'test_module_end').content
Expand All @@ -993,12 +993,19 @@ testFrameworks.forEach(({
assert.propertyVal(testModule.meta, TEST_ITR_FORCED_RUN, 'true')
assert.propertyVal(testModule.meta, TEST_ITR_UNSKIPPABLE, 'true')

const passedSuite = suites.find(
event => event.content.resource === 'test_suite.ci-visibility/unskippable-test/test-to-run.js'
)
const skippedSuite = suites.find(
event => event.content.resource === 'test_suite.ci-visibility/unskippable-test/test-to-skip.js'
)
const forcedToRunSuite = suites.find(
event => event.content.resource === 'test_suite.ci-visibility/unskippable-test/test-unskippable.js'
)
// It does not mark as unskippable if there is no docblock
assert.propertyVal(passedSuite.content.meta, TEST_STATUS, 'pass')
assert.notProperty(passedSuite.content.meta, TEST_ITR_UNSKIPPABLE)
assert.notProperty(passedSuite.content.meta, TEST_ITR_FORCED_RUN)

assert.propertyVal(skippedSuite.content.meta, TEST_STATUS, 'skip')
assert.notProperty(skippedSuite.content.meta, TEST_ITR_UNSKIPPABLE)
Expand All @@ -1012,6 +1019,7 @@ testFrameworks.forEach(({
let TESTS_TO_RUN = 'unskippable-test/test-'
if (name === 'mocha') {
TESTS_TO_RUN = JSON.stringify([
'./unskippable-test/test-to-run.js',
'./unskippable-test/test-to-skip.js',
'./unskippable-test/test-unskippable.js'
])
Expand Down Expand Up @@ -1050,7 +1058,7 @@ testFrameworks.forEach(({
const events = payloads.flatMap(({ payload }) => payload.events)
const suites = events.filter(event => event.type === 'test_suite_end')

assert.equal(suites.length, 2)
assert.equal(suites.length, 3)

const testSession = events.find(event => event.type === 'test_session_end').content
const testModule = events.find(event => event.type === 'test_module_end').content
Expand All @@ -1059,13 +1067,21 @@ testFrameworks.forEach(({
assert.notProperty(testModule.meta, TEST_ITR_FORCED_RUN)
assert.propertyVal(testModule.meta, TEST_ITR_UNSKIPPABLE, 'true')

const passedSuite = suites.find(
event => event.content.resource === 'test_suite.ci-visibility/unskippable-test/test-to-run.js'
)
const skippedSuite = suites.find(
event => event.content.resource === 'test_suite.ci-visibility/unskippable-test/test-to-skip.js'
).content
const nonSkippedSuite = suites.find(
event => event.content.resource === 'test_suite.ci-visibility/unskippable-test/test-unskippable.js'
).content

// It does not mark as unskippable if there is no docblock
assert.propertyVal(passedSuite.content.meta, TEST_STATUS, 'pass')
assert.notProperty(passedSuite.content.meta, TEST_ITR_UNSKIPPABLE)
assert.notProperty(passedSuite.content.meta, TEST_ITR_FORCED_RUN)

assert.propertyVal(skippedSuite.meta, TEST_STATUS, 'skip')

assert.propertyVal(nonSkippedSuite.meta, TEST_STATUS, 'pass')
Expand All @@ -1077,6 +1093,7 @@ testFrameworks.forEach(({
let TESTS_TO_RUN = 'unskippable-test/test-'
if (name === 'mocha') {
TESTS_TO_RUN = JSON.stringify([
'./unskippable-test/test-to-run.js',
'./unskippable-test/test-to-skip.js',
'./unskippable-test/test-unskippable.js'
])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { expect } = require('chai')

describe('test-to-run', () => {
it('can report tests', () => {
expect(1 + 2).to.equal(3)
})
})
22 changes: 14 additions & 8 deletions integration-tests/profiler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ describe('profiler', () => {
const threadIdKey = strings.dedup('thread id')
const osThreadIdKey = strings.dedup('os thread id')
const threadNameValue = strings.dedup('Main Event Loop')
const nonJSThreadNameValue = strings.dedup('Non-JS threads')

for (const sample of profile.sample) {
let ts, spanId, rootSpanId, endpoint, threadName, threadId, osThreadId
for (const label of sample.label) {
Expand All @@ -205,14 +207,18 @@ describe('profiler', () => {
default: assert.fail(`Unexpected label key ${strings.dedup(label.key)} ${encoded}`)
}
}
// Timestamp must be defined and be between process start and end time
assert.isDefined(ts, encoded)
assert.isNumber(osThreadId, encoded)
assert.equal(threadId, strings.dedup('0'), encoded)
assert.isTrue(ts <= procEnd, encoded)
assert.isTrue(ts >= procStart, encoded)
// Thread name must be defined and exactly equal "Main Event Loop"
assert.equal(threadName, threadNameValue, encoded)
if (threadName !== nonJSThreadNameValue) {
// Timestamp must be defined and be between process start and end time
assert.isDefined(ts, encoded)
assert.isNumber(osThreadId, encoded)
assert.equal(threadId, strings.dedup('0'), encoded)
assert.isTrue(ts <= procEnd, encoded)
assert.isTrue(ts >= procStart, encoded)
// Thread name must be defined and exactly equal "Main Event Loop"
assert.equal(threadName, threadNameValue, encoded)
} else {
assert.equal(threadId, strings.dedup('NA'), encoded)
}
// Either all or none of span-related labels are defined
if (endpoint === undefined) {
// It is possible to catch a sample executing in tracer's startSpan so
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dd-trace",
"version": "3.44.0",
"version": "3.45.0",
"description": "Datadog APM tracing client for JavaScript",
"main": "index.js",
"typings": "index.d.ts",
Expand Down Expand Up @@ -72,7 +72,7 @@
"@datadog/native-iast-rewriter": "2.2.2",
"@datadog/native-iast-taint-tracking": "1.6.4",
"@datadog/native-metrics": "^2.0.0",
"@datadog/pprof": "4.1.0",
"@datadog/pprof": "5.0.0",
"@datadog/sketches-js": "^2.1.0",
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/core": "^1.14.0",
Expand All @@ -85,7 +85,7 @@
"istanbul-lib-coverage": "3.2.0",
"jest-docblock": "^29.7.0",
"koalas": "^1.0.2",
"limiter": "^1.1.4",
"limiter": "1.1.5",
"lodash.kebabcase": "^4.1.1",
"lodash.pick": "^4.4.0",
"lodash.sortby": "^4.7.0",
Expand All @@ -99,9 +99,9 @@
"path-to-regexp": "^0.1.2",
"pprof-format": "^2.0.7",
"protobufjs": "^7.2.5",
"tlhunter-sorted-set": "^0.1.0",
"retry": "^0.13.1",
"semver": "^7.5.4"
"semver": "^7.5.4",
"tlhunter-sorted-set": "^0.1.0"
},
"devDependencies": {
"@types/node": ">=14",
Expand Down
2 changes: 2 additions & 0 deletions packages/datadog-instrumentations/src/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,8 @@ addHook({
_ddTestModuleId,
_ddTestSessionId,
_ddTestCommand,
_ddForcedToRun,
_ddUnskippable,
...restOfTestEnvironmentOptions
} = testEnvironmentOptions

Expand Down
2 changes: 2 additions & 0 deletions packages/datadog-plugin-google-cloud-pubsub/src/consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class GoogleCloudPubsubConsumerPlugin extends ConsumerPlugin {
finish (message) {
const span = this.activeSpan

if (!span) return

if (message.message._handled) {
span.setTag('pubsub.ack', 1)
}
Expand Down
18 changes: 18 additions & 0 deletions packages/datadog-plugin-google-cloud-pubsub/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,24 @@ describe('Plugin', () => {
await pubsub.createTopic(topicName)
})
})

it('should handle manual subscription close', async () => {
const [topic] = await pubsub.createTopic(topicName)
const [sub] = await topic.createSubscription('foo')

// message handler takes a while, subscription is closed while it's still running
sub.on('message', msg => {
setTimeout(() => { msg.ack() }, 2000)
})

await publish(topic, { data: Buffer.from('hello') })

setTimeout(() => { sub.close() }, 500)

return new Promise((resolve) => {
sub.on('close', resolve)
})
})
})

describe('with configuration', () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/datadog-plugin-hapi/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('Plugin', () => {
.then(_port => {
port = _port
server = Hapi.server({
address: '127.0.0.1',
address: 'localhost',
port
})
return server.start()
Expand All @@ -69,9 +69,9 @@ describe('Plugin', () => {

if (Hapi.Server.prototype.connection) {
server = new Hapi.Server()
server.connection({ address: '127.0.0.1', port })
server.connection({ address: 'localhost', port })
} else {
server = new Hapi.Server('127.0.0.1', port)
server = new Hapi.Server('localhost', port)
}

server.start(done)
Expand Down
28 changes: 24 additions & 4 deletions packages/datadog-plugin-jest/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ class JestPlugin extends CiPlugin {
return 'jest'
}

// The lists are the same for every test suite, so we can cache them
getUnskippableSuites (unskippableSuitesList) {
if (!this.unskippableSuites) {
this.unskippableSuites = JSON.parse(unskippableSuitesList)
}
return this.unskippableSuites
}
getForcedToRunSuites (forcedToRunSuitesList) {
if (!this.forcedToRunSuites) {
this.forcedToRunSuites = JSON.parse(forcedToRunSuitesList)
}
return this.forcedToRunSuites
}

constructor (...args) {
super(...args)

Expand Down Expand Up @@ -128,11 +142,17 @@ class JestPlugin extends CiPlugin {
const testSuiteMetadata = getTestSuiteCommonTags(testCommand, frameworkVersion, testSuite, 'jest')

if (_ddUnskippable) {
this.telemetry.count(TELEMETRY_ITR_UNSKIPPABLE, { testLevel: 'suite' })
testSuiteMetadata[TEST_ITR_UNSKIPPABLE] = 'true'
const unskippableSuites = this.getUnskippableSuites(_ddUnskippable)
if (unskippableSuites[testSuite]) {
this.telemetry.count(TELEMETRY_ITR_UNSKIPPABLE, { testLevel: 'suite' })
testSuiteMetadata[TEST_ITR_UNSKIPPABLE] = 'true'
}
if (_ddForcedToRun) {
this.telemetry.count(TELEMETRY_ITR_FORCED_TO_RUN, { testLevel: 'suite' })
testSuiteMetadata[TEST_ITR_FORCED_RUN] = 'true'
const forcedToRunSuites = this.getForcedToRunSuites(_ddForcedToRun)
if (forcedToRunSuites[testSuite]) {
this.telemetry.count(TELEMETRY_ITR_FORCED_TO_RUN, { testLevel: 'suite' })
testSuiteMetadata[TEST_ITR_FORCED_RUN] = 'true'
}
}
}

Expand Down
Loading