Skip to content

Commit

Permalink
Merge branch 'master' into conti/kafkajs-batching-support
Browse files Browse the repository at this point in the history
  • Loading branch information
wconti27 authored Aug 27, 2024
2 parents 59026f5 + ba0442f commit 36ae746
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/actions/node/latest/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ runs:
steps:
- uses: actions/setup-node@v3
with:
node-version: 'latest'
node-version: '22.6'
3 changes: 3 additions & 0 deletions .github/workflows/all-green.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: All Green
on:
pull_request:
push:
branches:
- master

jobs:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/appsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ jobs:
matrix:
version:
- 18
- latest
- 22.6
range: ['9.5.0', '11.1.4', '13.2.0', '*']
runs-on: ubuntu-latest
env:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ jobs:
aws-sdk:
strategy:
matrix:
node-version: ['18', 'latest']
node-version: ['18', '22.6']
runs-on: ubuntu-latest
services:
localstack:
Expand Down Expand Up @@ -412,7 +412,7 @@ jobs:
http:
strategy:
matrix:
node-version: ['18', '20', 'latest']
node-version: ['18', '20', '22.6']
runs-on: ubuntu-latest
env:
PLUGINS: http
Expand Down Expand Up @@ -648,7 +648,7 @@ jobs:
matrix:
version:
- 18
- latest
- 22.6
range: ['9.5.0', '11.1.4', '13.2.0', '*']
runs-on: ubuntu-latest
env:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
# setting fail-fast to false in an attempt to prevent this from happening
fail-fast: false
matrix:
version: [18, 20, latest]
version: [18, 20, 22.6]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
integration-ci:
strategy:
matrix:
version: [18, latest]
version: [18, 22.6]
framework: [cucumber, playwright, selenium, jest, mocha]
runs-on: ubuntu-latest
env:
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
# Important: This is outside the minimum supported version of dd-trace-js
# Node > 16 does not work with [email protected] (not even without our plugin)
# TODO: figure out what to do with this: we might have to deprecate support for [email protected]
version: [16, latest]
version: [16, 22.6]
# 6.7.0 is the minimum version we support
cypress-version: [6.7.0, latest]
module-type: ['commonJS', 'esm']
Expand Down
6 changes: 1 addition & 5 deletions integration-tests/profiler/profiler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ function expectProfileMessagePromise (agent, timeout,
event = JSON.parse(files[0].buffer.toString())
assert.propertyVal(event, 'family', 'node')
assert.isString(event.info.profiler.activation)
const ssiEnabled = event.info.profiler.ssi.enabled
assert.isBoolean(ssiEnabled)
if (ssiEnabled) {
assert.isString(event.info.profiler.ssi.mechanism)
}
assert.isString(event.info.profiler.ssi.mechanism)
assert.deepPropertyVal(event, 'attachments', fileNames)
for (const [index, fileName] of fileNames.entries()) {
assert.propertyVal(files[index + 1], 'originalname', fileName)
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/selenium/selenium.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ versionRange.forEach(version => {
const seleniumTest = events.find(event => event.type === 'test').content
assert.include(seleniumTest.meta, {
[TEST_BROWSER_DRIVER]: 'selenium',
[TEST_BROWSER_NAME]: 'chrome-headless-shell',
[TEST_BROWSER_NAME]: 'chrome',
[TEST_TYPE]: 'browser',
[TEST_IS_RUM_ACTIVE]: 'true'
})
Expand Down
11 changes: 4 additions & 7 deletions packages/datadog-instrumentations/src/hapi.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
'use strict'

const tracingChannel = require('dc-polyfill').tracingChannel
const shimmer = require('../../datadog-shimmer')
const { addHook, channel, AsyncResource } = require('./helpers/instrument')
const { addHook, channel } = require('./helpers/instrument')

const handleChannel = channel('apm:hapi:request:handle')
const routeChannel = channel('apm:hapi:request:route')
const errorChannel = channel('apm:hapi:request:error')
const enterChannel = channel('apm:hapi:extension:enter')
const hapiTracingChannel = tracingChannel('apm:hapi:extension')

function wrapServer (server) {
return function (options) {
Expand Down Expand Up @@ -96,11 +97,7 @@ function wrapHandler (handler) {

if (!req) return handler.apply(this, arguments)

const asyncResource = new AsyncResource('bound-anonymous-fn')

return asyncResource.runInAsyncScope(() => {
enterChannel.publish({ req })

return hapiTracingChannel.traceSync(() => {
return handler.apply(this, arguments)
})
}
Expand Down
4 changes: 2 additions & 2 deletions packages/datadog-plugin-hapi/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class HapiPlugin extends RouterPlugin {
}
})

this.addSub('apm:hapi:extension:enter', ({ req }) => {
this.enter(this._requestSpans.get(req))
this.addBind('apm:hapi:extension:start', ({ req }) => {
return this._requestSpans.get(req)
})
}
}
Expand Down
25 changes: 25 additions & 0 deletions packages/datadog-plugin-hapi/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const axios = require('axios')
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 { AsyncLocalStorage } = require('async_hooks')

const versionRange = parseInt(process.versions.node.split('.')[0]) > 14
? '<17 || >18'
Expand Down Expand Up @@ -348,6 +349,30 @@ describe('Plugin', () => {
.get(`http://localhost:${port}/user/123`)
.catch(() => {})
})

it('should persist AsyncLocalStorage context', (done) => {
const als = new AsyncLocalStorage()
const path = '/path'

server.ext('onRequest', (request, h) => {
als.enterWith({ path: request.path })
return reply(request, h)
})

server.route({
method: 'GET',
path,
handler: async (request, h) => {
expect(als.getStore()).to.deep.equal({ path })
done()
return h.response ? h.response() : h()
}
})

axios
.get(`http://localhost:${port}${path}`)
.catch(() => {})
})
})
})
})
7 changes: 1 addition & 6 deletions packages/dd-trace/src/opentracing/propagation/text_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ class TextMapPropagator {
}

_hasParentIdInTags (spanContext) {
return tags.DD_PARENT_ID in spanContext._trace.tags &&
spanContext._trace.tags[tags.DD_PARENT_ID] !== zeroTraceId
return tags.DD_PARENT_ID in spanContext._trace.tags
}

_updateParentIdFromDdHeaders (carrier, firstSpanContext) {
Expand Down Expand Up @@ -445,10 +444,6 @@ class TextMapPropagator {
}
})

if (!spanContext._trace.tags[tags.DD_PARENT_ID]) {
spanContext._trace.tags[tags.DD_PARENT_ID] = zeroTraceId
}

this._extractBaggageItems(carrier, spanContext)
return spanContext
}
Expand Down
3 changes: 1 addition & 2 deletions packages/dd-trace/src/profiling/exporters/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ class AgentExporter {
profiler: {
activation: this._activation,
ssi: {
enabled: this._libraryInjected,
mechanism: this._libraryInjected ? 'injected_agent' : undefined
mechanism: this._libraryInjected ? 'injected_agent' : 'none'
},
version
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ describe('TextMapPropagator', () => {

const carrier = textMap
const spanContext = propagator.extract(carrier)
expect(spanContext._trace.tags).to.have.property('_dd.parent_id', '0000000000000000')
expect(spanContext._trace.tags).to.not.have.property('_dd.parent_id')
})

it('should not extract tracestate from tracecontext when trace IDs don\'t match', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/test/profiling/exporters/agent.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe('exporters/agent', function () {
expect(Object.keys(event.info.profiler)).to.have.length(3)
expect(event.info.profiler).to.have.property('activation', 'unknown')
expect(event.info.profiler).to.have.property('ssi')
expect(event.info.profiler.ssi).to.have.property('enabled', false)
expect(event.info.profiler.ssi).to.have.property('mechanism', 'none')
expect(event.info.profiler).to.have.property('version', version)
expect(event.info).to.have.property('runtime')
expect(Object.keys(event.info.runtime)).to.have.length(2)
Expand Down

0 comments on commit 36ae746

Please sign in to comment.