Skip to content

Commit

Permalink
Merge branch 'master' into nicholas.hulston/span-pointer-env-vars
Browse files Browse the repository at this point in the history
  • Loading branch information
nhulston authored Feb 20, 2025
2 parents 27c78b7 + 96bb84a commit b22bbac
Show file tree
Hide file tree
Showing 40 changed files with 518 additions and 166 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'Stale PR Bot'
on:
schedule:
- cron: '0 4 * * *'

permissions:
pull-requests: write

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0
with:
days-before-issue-stale: -1 # disabled for issues

days-before-pr-stale: 90 # 3 months
days-before-pr-close: 14 # 2 weeks
stale-pr-label: "stale"
exempt-pr-labels: "keep-open"
exempt-draft-pr: true
stale-pr-message: |
This pull request has been marked as stale due to 90 days of inactivity.
If this is still relevant, please update or comment to keep it open.
If this should be kept open indefinitely, please apply the label `keep-open`.
Otherwise, it will be automatically closed after 14 days.
2 changes: 1 addition & 1 deletion .github/workflows/system-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: DataDog/system-tests/.github/workflows/compute-workflow-parameters.yml@main
with:
library: nodejs
scenarios_groups: essentials,appsec_rasp
scenarios_groups: essentials,appsec_rasp,debugger

system-tests:
runs-on: ${{ contains(fromJSON('["CROSSED_TRACING_LIBRARIES", "INTEGRATIONS"]'), matrix.scenario) && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
Expand Down
6 changes: 2 additions & 4 deletions benchmark/sirun/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ RUN wget -O sirun.tar.gz https://github.com/DataDog/sirun/releases/download/v0.1
RUN mkdir -p /usr/local/nvm \
&& wget -q -O - https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install --no-progress 14.21.3 \
&& nvm install --no-progress 16.20.1 \
&& nvm install --no-progress 18.16.1 \
&& nvm install --no-progress 20.4.0 \
&& nvm install --no-progress 22.10.0 \
&& nvm alias default 18 \
&& nvm use 18
&& nvm alias default 22 \
&& nvm use 22

RUN mkdir /opt/insecure-bank-js
RUN git clone --depth 1 https://github.com/hdiv/insecure-bank-js.git /opt/insecure-bank-js
Expand Down
4 changes: 2 additions & 2 deletions ci/init.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
const tracer = require('../packages/dd-trace')
const { isTrue } = require('../packages/dd-trace/src/util')
const { isTrue, isFalse } = require('../packages/dd-trace/src/util')
const log = require('../packages/dd-trace/src/log')

const isJestWorker = !!process.env.JEST_WORKER_ID
Expand All @@ -23,7 +23,7 @@ const options = {
flushInterval: isJestWorker ? 0 : 5000
}

let shouldInit = true
let shouldInit = !isFalse(process.env.DD_CIVISIBILITY_ENABLED)

if (isPackageManager()) {
log.debug('dd-trace is not initialized in a package manager.')
Expand Down
12 changes: 8 additions & 4 deletions initialize.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ ${result.source}`
const [NODE_MAJOR, NODE_MINOR] = process.versions.node.split('.').map(x => +x)

const brokenLoaders = NODE_MAJOR === 18 && NODE_MINOR === 0
const iitmExclusions = [/langsmith/, /openai\/_shims/, /openai\/resources\/chat\/completions\/messages/]

export async function load (...args) {
const loadHook = brokenLoaders ? args[args.length - 1] : origLoad
return insertInit(await loadHook(...args))
export async function load (url, context, nextLoad) {
const iitmExclusionsMatch = iitmExclusions.some((exclusion) => exclusion.test(url))
const loadHook = (brokenLoaders || iitmExclusionsMatch) ? nextLoad : origLoad
return insertInit(await loadHook(url, context, nextLoad))
}

export const resolve = brokenLoaders ? undefined : origResolve
Expand All @@ -53,6 +55,8 @@ if (isMainThread) {
const require = Module.createRequire(import.meta.url)
require('./init.js')
if (Module.register) {
Module.register('./loader-hook.mjs', import.meta.url)
Module.register('./loader-hook.mjs', import.meta.url, {
data: { exclude: iitmExclusions }
})
}
}
2 changes: 1 addition & 1 deletion integration-tests/pino/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const logger = require('pino')()
const server = http
.createServer((req, res) => {
const span = tracer.scope().active()
const contextTraceId = span.context().toTraceId()
const contextTraceId = span.context().toTraceId(true)
const contextSpanId = span.context().toSpanId()
logger.info(
{ custom: { trace_id: contextTraceId, span_id: contextSpanId } },
Expand Down
2 changes: 1 addition & 1 deletion packages/datadog-instrumentations/src/aws-sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function getMessage (request, error, result) {

function getChannelSuffix (name) {
// some resource identifiers have spaces between ex: bedrock runtime
name = name.replaceAll(' ', '')
name = String(name).replaceAll(' ', '')
return [
'cloudwatchlogs',
'dynamodb',
Expand Down
6 changes: 3 additions & 3 deletions packages/datadog-instrumentations/src/helpers/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ module.exports = {
'@jest/test-sequencer': () => require('../jest'),
'@jest/transform': () => require('../jest'),
'@koa/router': () => require('../koa'),
'@langchain/core': () => require('../langchain'),
'@langchain/openai': () => require('../langchain'),
'@langchain/core': { esmFirst: true, fn: () => require('../langchain') },
'@langchain/openai': { esmFirst: true, fn: () => require('../langchain') },
'@node-redis/client': () => require('../redis'),
'@opensearch-project/opensearch': () => require('../opensearch'),
'@opentelemetry/sdk-trace-node': () => require('../otel-sdk-trace'),
Expand Down Expand Up @@ -100,7 +100,7 @@ module.exports = {
'node:vm': () => require('../vm'),
nyc: () => require('../nyc'),
oracledb: () => require('../oracledb'),
openai: () => require('../openai'),
openai: { esmFirst: true, fn: () => require('../openai') },
paperplane: () => require('../paperplane'),
passport: () => require('../passport'),
'passport-http': () => require('../passport-http'),
Expand Down
5 changes: 5 additions & 0 deletions packages/datadog-instrumentations/src/http/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ function patch (http, methodName) {
} catch (e) {
ctx.error = e
errorChannel.publish(ctx)
// if the initial request failed, ctx.req will be unset, we must close the span here
// fix for: https://github.com/DataDog/dd-trace-js/issues/5016
if (!ctx.req) {
finish()
}
throw e
} finally {
endChannel.publish(ctx)
Expand Down
Loading

0 comments on commit b22bbac

Please sign in to comment.