Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
df18d9a
[profiling] Associate tracing span IDs with samples in the wall profi…
nsavoire Jul 14, 2023
917f0e5
Taint request URI (#3302)
CarlesDD Jul 17, 2023
bdcb70e
Fix erroneous resetting of profiler state to undefined (#3394)
szegedi Jul 17, 2023
749392f
Detect missing header vulnerabilities (#3269)
uurien Jul 17, 2023
5f3e851
Update yarn.lock with current pprof-nodejs version (#3398)
nsavoire Jul 17, 2023
b2831f0
openai: be defensive about response object shape (#3408)
tlhunter Jul 18, 2023
f084c98
delete old build scripts (#3396)
tlhunter Jul 18, 2023
99c6df0
Add eslint rule for object-curly-newline (#3406)
nsavoire Jul 18, 2023
dfcf8b0
Fix a phrase in README (#3405)
szegedi Jul 18, 2023
a91b65f
Fix same dependency detection (#3386)
uurien Jul 18, 2023
2e10f31
fix: Handle case where Lambda handler is using callbacks instead of p…
astuyve Jul 17, 2023
07f6cda
Ignore esbuild output from integration tests in esbuild (#3410)
Jul 18, 2023
b58689b
[ci-visibility] Do not modify how jest reports timeouts (#3399)
juan-fernandez Jul 19, 2023
a4c3106
Allow https datadog agent url in continuous profiling (#3190) (#3194)
grainrigi Jul 19, 2023
c7e4716
Fix distributed tracing issue caused by single span ingestion changes…
Jul 19, 2023
2d91953
Ensure OTel span name is copied to resource.name (#3412)
Jul 19, 2023
bb66f96
Make datadog distributed tracing header take priority over traceconte…
Jul 19, 2023
11990d9
Exclude empty telemetry metrics (#3421)
Jul 19, 2023
578d776
openai: make services entirely optional when initializing (#3420)
tlhunter Jul 20, 2023
74f5c4b
Fix service representation config (#3419)
jbertran Jul 20, 2023
670471b
implement naming schema for graphql plugin (#3279)
rarguelloF Jul 20, 2023
5f0218a
Fix flaky serverless integration test (#3418)
thedavl Jul 20, 2023
773bcdc
Fix native-iast-taint-tracking version number (#3433)
uurien Jul 20, 2023
61c6f31
openai: remove String#replaceAll for Node.js <=14 (#3432)
tlhunter Jul 20, 2023
2818d67
Add BITBUCKET_GIT_HTTP_ORIGIN env variable (#3401)
ericlaz Jul 21, 2023
0808128
[ci-visibility] Make integration test for jest compatible with node 1…
juan-fernandez Jul 21, 2023
372b481
v2.42.0
szegedi Jul 20, 2023
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules
versions
acmeair-nodejs
vendor
integration-tests/esbuild/out.js
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"import/no-extraneous-dependencies": 2,
"standard/no-callback-literal": 0,
"no-prototype-builtins": 0,
"n/no-restricted-require": [2, ["diagnostics_channel"]]
"n/no-restricted-require": [2, ["diagnostics_channel"]],
"object-curly-newline": ["error", {"multiline": true, "consistent": true }]
}
}
17 changes: 17 additions & 0 deletions .github/workflows/plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,23 @@ jobs:
uses: ./.github/actions/testagent/logs
- uses: codecov/codecov-action@v2

openai:
runs-on: ubuntu-latest
env:
PLUGINS: openai
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/testagent/start
- uses: ./.github/actions/node/setup
- 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
- uses: codecov/codecov-action@v2

opensearch:
runs-on: ubuntu-latest
services:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ $ yarn leak:plugins

### Linting

We use [ESLint](https://eslint.org) to make sure that new code is
conform to our coding standards.
We use [ESLint](https://eslint.org) to make sure that new code
conforms to our coding standards.

To run the linter, use:

Expand Down
10 changes: 6 additions & 4 deletions benchmark/sirun/get-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ const artifactsUrl = num =>

function get (url, headers) {
return new Promise((resolve, reject) => {
https.get(url, { headers: Object.assign({
'user-agent': 'dd-results-retriever',
accept: 'application/json'
}, headers) }, async res => {
https.get(url, {
headers: Object.assign({
'user-agent': 'dd-results-retriever',
accept: 'application/json'
}, headers)
}, async res => {
if (res.statusCode >= 300 && res.statusCode < 400) {
resolve(get(res.headers.location))
return
Expand Down
22 changes: 22 additions & 0 deletions integration-tests/ci-visibility.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,28 @@ testFrameworks.forEach(({
}).catch(done)
})
})
it('reports timeout error message', (done) => {
childProcess = fork('ci-visibility/run-jest.js', {
cwd,
env: {
...getCiVisAgentlessConfig(receiver.port),
NODE_OPTIONS: '-r dd-trace/ci/init',
RUN_IN_PARALLEL: true,
TEST_REGEX: 'timeout-test/timeout-test.js'
},
stdio: 'pipe'
})
childProcess.stdout.on('data', (chunk) => {
testOutput += chunk.toString()
})
childProcess.stderr.on('data', (chunk) => {
testOutput += chunk.toString()
})
childProcess.on('message', () => {
assert.include(testOutput, 'Exceeded timeout of 100 ms for a test')
done()
})
})
}

it('can run tests and report spans', (done) => {
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/ci-visibility/run-jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const options = {
projects: [__dirname],
testPathIgnorePatterns: ['/node_modules/'],
cache: false,
testRegex: /test\/ci-visibility-test/,
testRegex: process.env.TEST_REGEX ? new RegExp(process.env.TEST_REGEX) : /test\/ci-visibility-test/,
coverage: true,
runInBand: true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable */
jest.setTimeout(100)
describe('ci visibility', () => {
it('will timeout', (done) => {
setTimeout(() => {
done()
}, 200)
})
})
15 changes: 9 additions & 6 deletions integration-tests/serverless/test-gcloud-function.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,33 @@ ls "${SERVERLESS_INTEGRATION_DIR_PATH}/test-project/"
STAGE=$(xxd -l 4 -c 4 -p </dev/random)

function cleanup {
gcloud functions delete dd-trace-js-sls-mini-agent-integration-test-${STAGE} --region us-east1 --gen2 --quiet
gcloud functions delete dd-trace-js-sls-mini-agent-integration-test-${STAGE} --region us-east1 --gen2 --quiet --project datadog-sandbox
}
trap cleanup EXIT

echo "Deploying integration test cloud function"

gcloud functions deploy dd-trace-js-sls-mini-agent-integration-test-${STAGE} \
DEPLOY_OUTPUT=$(gcloud functions deploy dd-trace-js-sls-mini-agent-integration-test-${STAGE} \
--gen2 \
--runtime=nodejs18 \
--region=us-east1 \
--project=datadog-sandbox \
--source "${SERVERLESS_INTEGRATION_DIR_PATH}/test-project/" \
--entry-point=helloGET \
--trigger-http \
--allow-unauthenticated \
--env-vars-file "${SERVERLESS_INTEGRATION_DIR_PATH}/test-project/.env.yaml"
--env-vars-file "${SERVERLESS_INTEGRATION_DIR_PATH}/test-project/.env.yaml")

INVOKE_URL=$(echo "$DEPLOY_OUTPUT" | awk 'END {print $NF}')

echo "Calling deployed cloud function"

curl -s "https://us-east1-datadog-sandbox.cloudfunctions.net/dd-trace-js-sls-mini-agent-integration-test-${STAGE}"
curl -s "${INVOKE_URL}"

echo "Waiting 1 minute before tailing logs"
echo "Waiting 60 seconds before tailing logs"
sleep 60

LOGS=$(gcloud functions logs read dd-trace-js-sls-mini-agent-integration-test-${STAGE} --region us-east1 --gen2 --limit 1000)
LOGS=$(gcloud functions logs read dd-trace-js-sls-mini-agent-integration-test-${STAGE} --region us-east1 --gen2 --limit 1000 --project datadog-sandbox)

echo "$LOGS"

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dd-trace",
"version": "2.41.0",
"version": "2.42.0",
"description": "Datadog APM tracing client for JavaScript",
"main": "index.js",
"typings": "index.d.ts",
Expand Down Expand Up @@ -68,9 +68,9 @@
"dependencies": {
"@datadog/native-appsec": "^3.2.0",
"@datadog/native-iast-rewriter": "2.0.1",
"@datadog/native-iast-taint-tracking": "^1.5.0",
"@datadog/native-iast-taint-tracking": "1.5.0",
"@datadog/native-metrics": "^1.6.0",
"@datadog/pprof": "3.0.0",
"@datadog/pprof": "3.1.0",
"@datadog/sketches-js": "^2.1.0",
"@types/node": "<18.13",
"@opentelemetry/api": "^1.0.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/datadog-core/src/storage/async_resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { channel } = require('../../../diagnostics_channel')

const beforeCh = channel('dd-trace:storage:before')
const afterCh = channel('dd-trace:storage:after')
const enterCh = channel('dd-trace:storage:enter')

let PrivateSymbol = Symbol
function makePrivateSymbol () {
Expand Down Expand Up @@ -52,6 +53,7 @@ class AsyncResourceStorage {
const resource = this._executionAsyncResource()

resource[this._ddResourceStore] = store
enterCh.publish()
}

run (store, callback, ...args) {
Expand All @@ -61,11 +63,13 @@ class AsyncResourceStorage {
const oldStore = resource[this._ddResourceStore]

resource[this._ddResourceStore] = store
enterCh.publish()

try {
return callback(...args)
} finally {
resource[this._ddResourceStore] = oldStore
enterCh.publish()
}
}

Expand Down
10 changes: 6 additions & 4 deletions packages/datadog-instrumentations/src/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
suite: this.testSuite,
runner: 'jest-circus',
testParameters,
frameworkVersion: jestVersion,
testStartLine: getTestLineStart(event.test.asyncError, this.testSuite)
frameworkVersion: jestVersion
})
originalTestFns.set(event.test, event.test.fn)
event.test.fn = asyncResource.bind(event.test.fn)
Expand All @@ -145,7 +144,10 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
const formattedError = formatJestError(event.test.errors[0])
testErrCh.publish(formattedError)
}
testRunFinishCh.publish(status)
testRunFinishCh.publish({
status,
testStartLine: getTestLineStart(event.test.asyncError, this.testSuite)
})
// restore in case it is retried
event.test.fn = originalTestFns.get(event.test)
})
Expand Down Expand Up @@ -471,7 +473,7 @@ function jasmineAsyncInstallWraper (jasmineAsyncInstallExport, jestVersion) {
const formattedError = formatJestError(spec.result.failedExpectations[0].error)
testErrCh.publish(formattedError)
}
testRunFinishCh.publish(specStatusToTestStatus[spec.result.status])
testRunFinishCh.publish({ status: specStatusToTestStatus[spec.result.status] })
onComplete.apply(this, arguments)
})
arguments[0] = callback
Expand Down
8 changes: 5 additions & 3 deletions packages/datadog-plugin-elasticsearch/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,11 @@ describe('Plugin', () => {
before(() => {
return agent.load('elasticsearch', {
service: 'custom',
hooks: { query: (span, params) => {
span.addTags({ 'elasticsearch.params': 'foo', 'elasticsearch.method': params.method })
} }
hooks: {
query: (span, params) => {
span.addTags({ 'elasticsearch.params': 'foo', 'elasticsearch.method': params.method })
}
}
})
})

Expand Down
10 changes: 6 additions & 4 deletions packages/datadog-plugin-graphql/src/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ let tools
class GraphQLExecutePlugin extends TracingPlugin {
static get id () { return 'graphql' }
static get operation () { return 'execute' }
static get type () { return 'graphql' }
static get kind () { return 'server' }

start ({ operation, args, docSource }) {
const type = operation && operation.operation
const name = operation && operation.name && operation.name.value
const document = args.document
const source = this.config.source && document && docSource

const span = this.startSpan('graphql.execute', {
service: this.config.service,
const span = this.startSpan(this.operationName(), {
service: this.config.service || this.serviceName(),
resource: getSignature(document, name, type, this.config.signature),
kind: 'server',
type: 'graphql',
kind: this.constructor.kind,
type: this.constructor.type,
meta: {
'graphql.operation.type': type,
'graphql.operation.name': name,
Expand Down
16 changes: 16 additions & 0 deletions packages/datadog-plugin-graphql/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { expect } = require('chai')
const semver = require('semver')
const agent = require('../../dd-trace/test/plugins/agent')
const { ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/constants')
const namingSchema = require('./naming')

describe('Plugin', () => {
let tracer
Expand Down Expand Up @@ -175,6 +176,21 @@ describe('Plugin', () => {
return agent.close({ ritmReset: false })
})

withNamingSchema(
() => {
const source = `query MyQuery { hello(name: "world") }`
const variableValues = { who: 'world' }
graphql.graphql({ schema, source, variableValues })
},
() => namingSchema.server.opName,
() => namingSchema.server.serviceName,
'test',
(traces) => {
const spans = sort(traces[0])
return spans[0]
}
)

it('should instrument parsing', done => {
const source = `query MyQuery { hello(name: "world") }`
const variableValues = { who: 'world' }
Expand Down
14 changes: 14 additions & 0 deletions packages/datadog-plugin-graphql/test/naming.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { resolveNaming } = require('../../dd-trace/test/plugins/helpers')

module.exports = resolveNaming({
server: {
v0: {
opName: 'graphql.execute',
serviceName: 'test'
},
v1: {
opName: 'graphql.server.request',
serviceName: 'test'
}
}
})
11 changes: 8 additions & 3 deletions packages/datadog-plugin-jest/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,12 @@ class JestPlugin extends CiPlugin {
this.enter(span, store)
})

this.addSub('ci:jest:test:finish', (status) => {
this.addSub('ci:jest:test:finish', ({ status, testStartLine }) => {
const span = storage.getStore().span
span.setTag(TEST_STATUS, status)
if (testStartLine) {
span.setTag(TEST_SOURCE_START, testStartLine)
}
span.finish()
finishAllTraceSpans(span)
})
Expand Down Expand Up @@ -197,8 +200,10 @@ class JestPlugin extends CiPlugin {
const extraTags = {
[JEST_TEST_RUNNER]: runner,
[TEST_PARAMETERS]: testParameters,
[TEST_FRAMEWORK_VERSION]: frameworkVersion,
[TEST_SOURCE_START]: testStartLine
[TEST_FRAMEWORK_VERSION]: frameworkVersion
}
if (testStartLine) {
extraTags[TEST_SOURCE_START] = testStartLine
}

return super.startTestSpan(name, suite, this.testSuiteSpan, extraTags)
Expand Down
3 changes: 2 additions & 1 deletion packages/datadog-plugin-kafkajs/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ describe('Plugin', () => {
await consumer.run({
eachMessage: async ({ topic, partition, message, heartbeat, pause }) => {
expect(setDataStreamsContextSpy.args[0][0].hash).to.equal(expectedConsumerHash)
} })
}
})
setDataStreamsContextSpy.restore()
})
})
Expand Down
Loading