Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4d189ea
[profiling] Associate tracing span IDs with samples in the wall profi…
nsavoire Jul 14, 2023
9ab9872
Taint request URI (#3302)
CarlesDD Jul 17, 2023
cb46c63
Fix erroneous resetting of profiler state to undefined (#3394)
szegedi Jul 17, 2023
023cec3
Detect missing header vulnerabilities (#3269)
uurien Jul 17, 2023
3f87b7a
Update yarn.lock with current pprof-nodejs version (#3398)
nsavoire Jul 17, 2023
396e133
openai: be defensive about response object shape (#3408)
tlhunter Jul 18, 2023
4f0493d
delete old build scripts (#3396)
tlhunter Jul 18, 2023
6772252
Add eslint rule for object-curly-newline (#3406)
nsavoire Jul 18, 2023
48a7219
Fix a phrase in README (#3405)
szegedi Jul 18, 2023
c21d806
Fix same dependency detection (#3386)
uurien Jul 18, 2023
15e35ac
fix: Handle case where Lambda handler is using callbacks instead of p…
astuyve Jul 17, 2023
fc7d1e3
Ignore esbuild output from integration tests in esbuild (#3410)
Jul 18, 2023
8502b99
[ci-visibility] Do not modify how jest reports timeouts (#3399)
juan-fernandez Jul 19, 2023
900b7b2
Allow https datadog agent url in continuous profiling (#3190) (#3194)
grainrigi Jul 19, 2023
a226615
Fix distributed tracing issue caused by single span ingestion changes…
Jul 19, 2023
5c75d72
Ensure OTel span name is copied to resource.name (#3412)
Jul 19, 2023
4b310d2
Make datadog distributed tracing header take priority over traceconte…
Jul 19, 2023
7c143db
Exclude empty telemetry metrics (#3421)
Jul 19, 2023
20f079c
openai: make services entirely optional when initializing (#3420)
tlhunter Jul 20, 2023
ef3783b
Fix service representation config (#3419)
jbertran Jul 20, 2023
55016b9
implement naming schema for graphql plugin (#3279)
rarguelloF Jul 20, 2023
98b7ce0
Re-enable Couchbase testing (#3265)
tabgok Jul 20, 2023
0aaef22
Fix flaky serverless integration test (#3418)
thedavl Jul 20, 2023
1326161
Fix native-iast-taint-tracking version number (#3433)
uurien Jul 20, 2023
3fd7ee5
openai: remove String#replaceAll for Node.js <=14 (#3432)
tlhunter Jul 20, 2023
2c77690
Add BITBUCKET_GIT_HTTP_ORIGIN env variable (#3401)
ericlaz Jul 21, 2023
1715691
[ci-visibility] Make integration test for jest compatible with node 1…
juan-fernandez Jul 21, 2023
f1743f6
v4.8.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 @@ -33,6 +33,7 @@
"mocha/no-global-tests": 0,
"mocha/no-exports": 0,
"mocha/no-skipped-tests": 0,
"n/no-restricted-require": [2, ["diagnostics_channel"]]
"n/no-restricted-require": [2, ["diagnostics_channel"]],
"object-curly-newline": ["error", {"multiline": true, "consistent": true }]
}
}
54 changes: 36 additions & 18 deletions .github/workflows/plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,24 +182,25 @@ jobs:
uses: ./.github/actions/testagent/logs
- uses: codecov/codecov-action@v2

# couchbase:
# runs-on: ubuntu-latest
# services:
# couchbase:
# image: sabrenner/couchbase-server-sandbox:latest
# ports:
# - 8091-8095:8091-8095
# - 11210:11210
# env:
# PLUGINS: couchbase
# SERVICES: couchbase
# steps:
# - uses: actions/checkout@v2
# - uses: ./.github/actions/node/setup
# - run: yarn install
# - uses: ./.github/actions/node/oldest
# - run: yarn test:plugins:ci
# - uses: codecov/codecov-action@v2
couchbase:
runs-on: ubuntu-latest
services:
couchbase:
image: ghcr.io/datadog/couchbase-server-sandbox:latest
ports:
- 8091-8095:8091-8095
- 11210:11210
env:
PLUGINS: couchbase
SERVICES: couchbase
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: codecov/codecov-action@v2

connect:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -778,6 +779,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
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "2"
services:
couchbase:
image: sabrenner/couchbase-server-sandbox:latest
image: ghcr.io/datadog/couchbase-server-sandbox:latest
ports:
- "127.0.0.1:8091-8095:8091-8095"
- "127.0.0.1:11210:11210"
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": "4.7.0",
"version": "4.8.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": "^2.0.0",
"@datadog/pprof": "3.0.0",
"@datadog/pprof": "3.1.0",
"@datadog/sketches-js": "^2.1.0",
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/core": "^1.14.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
8 changes: 4 additions & 4 deletions packages/datadog-instrumentations/src/couchbase.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function wrapV3Query (query) {
}

// semver >=2 <3
addHook({ name: 'couchbase', file: 'lib/bucket.js', versions: ['^2.6.5'] }, Bucket => {
addHook({ name: 'couchbase', file: 'lib/bucket.js', versions: ['^2.6.12'] }, Bucket => {
const startCh = channel('apm:couchbase:query:start')
const finishCh = channel('apm:couchbase:query:finish')
const errorCh = channel('apm:couchbase:query:error')
Expand Down Expand Up @@ -208,7 +208,7 @@ addHook({ name: 'couchbase', file: 'lib/bucket.js', versions: ['^2.6.5'] }, Buck
return Bucket
})

addHook({ name: 'couchbase', file: 'lib/cluster.js', versions: ['^2.6.5'] }, Cluster => {
addHook({ name: 'couchbase', file: 'lib/cluster.js', versions: ['^2.6.12'] }, Cluster => {
Cluster.prototype._maybeInvoke = wrapMaybeInvoke(Cluster.prototype._maybeInvoke)
Cluster.prototype.query = wrapQuery(Cluster.prototype.query)

Expand All @@ -217,15 +217,15 @@ addHook({ name: 'couchbase', file: 'lib/cluster.js', versions: ['^2.6.5'] }, Clu

// semver >=3 <3.2.0

addHook({ name: 'couchbase', file: 'lib/collection.js', versions: ['>=3.0.0 <3.2.0'] }, Collection => {
addHook({ name: 'couchbase', file: 'lib/collection.js', versions: ['^3.0.7', '^3.1.3'] }, Collection => {
wrapAllNames(['upsert', 'insert', 'replace'], name => {
shimmer.wrap(Collection.prototype, name, wrapWithName(name))
})

return Collection
})

addHook({ name: 'couchbase', file: 'lib/cluster.js', versions: ['>=3.0.0 <3.2.0'] }, Cluster => {
addHook({ name: 'couchbase', file: 'lib/cluster.js', versions: ['^3.0.7', '^3.1.3'] }, Cluster => {
shimmer.wrap(Cluster.prototype, 'query', wrapV3Query)
return Cluster
})
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
Loading