dd-trace 4.44.0 → 4.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +2 -1
- package/package.json +3 -3
- package/packages/datadog-instrumentations/src/body-parser.js +14 -2
- package/packages/datadog-instrumentations/src/cucumber.js +10 -0
- package/packages/datadog-instrumentations/src/helpers/hooks.js +3 -2
- package/packages/datadog-instrumentations/src/helpers/register.js +8 -1
- package/packages/datadog-instrumentations/src/mocha/main.js +90 -70
- package/packages/datadog-instrumentations/src/nyc.js +23 -0
- package/packages/datadog-instrumentations/src/vitest.js +18 -2
- package/packages/datadog-plugin-cucumber/src/index.js +12 -2
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +16 -4
- package/packages/datadog-plugin-jest/src/index.js +17 -4
- package/packages/datadog-plugin-mocha/src/index.js +25 -6
- package/packages/datadog-plugin-nyc/src/index.js +35 -0
- package/packages/datadog-plugin-playwright/src/index.js +9 -4
- package/packages/datadog-plugin-vitest/src/index.js +30 -4
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +40 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -4
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +2 -4
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +8 -7
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -4
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +2 -4
- package/packages/dd-trace/src/ci-visibility/telemetry.js +29 -2
- package/packages/dd-trace/src/config.js +118 -112
- package/packages/dd-trace/src/opentelemetry/context_manager.js +22 -39
- package/packages/dd-trace/src/opentelemetry/span_context.js +2 -2
- package/packages/dd-trace/src/opentelemetry/tracer.js +23 -14
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +9 -1
- package/packages/dd-trace/src/opentracing/propagation/log.js +1 -1
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +60 -0
- package/packages/dd-trace/src/opentracing/span_context.js +1 -0
- package/packages/dd-trace/src/plugins/ci_plugin.js +2 -2
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/dd-trace/src/plugins/util/git.js +14 -1
- package/packages/dd-trace/src/telemetry/index.js +1 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const pick = require('../../../../datadog-core/src/utils/src/pick')
|
|
4
4
|
const id = require('../../id')
|
|
5
5
|
const DatadogSpanContext = require('../span_context')
|
|
6
|
+
const OtelSpanContext = require('../../opentelemetry/span_context')
|
|
6
7
|
const log = require('../../log')
|
|
7
8
|
const TraceState = require('./tracestate')
|
|
8
9
|
const tags = require('../../../../../ext/tags')
|
|
@@ -618,6 +619,65 @@ class TextMapPropagator {
|
|
|
618
619
|
|
|
619
620
|
return spanContext._traceId.toString(16)
|
|
620
621
|
}
|
|
622
|
+
|
|
623
|
+
static _convertOtelContextToDatadog (traceId, spanId, traceFlag, ts, meta = {}) {
|
|
624
|
+
const origin = null
|
|
625
|
+
let samplingPriority = traceFlag
|
|
626
|
+
|
|
627
|
+
ts = ts?.traceparent || null
|
|
628
|
+
|
|
629
|
+
if (ts) {
|
|
630
|
+
// Use TraceState.fromString to parse the tracestate header
|
|
631
|
+
const traceState = TraceState.fromString(ts)
|
|
632
|
+
let ddTraceStateData = null
|
|
633
|
+
|
|
634
|
+
// Extract Datadog specific trace state data
|
|
635
|
+
traceState.forVendor('dd', (state) => {
|
|
636
|
+
ddTraceStateData = state
|
|
637
|
+
return state // You might need to adjust this part based on actual logic needed
|
|
638
|
+
})
|
|
639
|
+
|
|
640
|
+
if (ddTraceStateData) {
|
|
641
|
+
// Assuming ddTraceStateData is now a Map or similar structure containing Datadog trace state data
|
|
642
|
+
// Extract values as needed, similar to the original logic
|
|
643
|
+
const samplingPriorityTs = ddTraceStateData.get('s')
|
|
644
|
+
const origin = ddTraceStateData.get('o')
|
|
645
|
+
// Convert Map to object for meta
|
|
646
|
+
const otherPropagatedTags = Object.fromEntries(ddTraceStateData.entries())
|
|
647
|
+
|
|
648
|
+
// Update meta and samplingPriority based on extracted values
|
|
649
|
+
Object.assign(meta, otherPropagatedTags)
|
|
650
|
+
samplingPriority = TextMapPropagator._getSamplingPriority(traceFlag, parseInt(samplingPriorityTs, 10), origin)
|
|
651
|
+
} else {
|
|
652
|
+
log.debug(`no dd list member in tracestate from incoming request: ${ts}`)
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
const spanContext = new OtelSpanContext({
|
|
657
|
+
traceId: id(traceId, 16), spanId: id(), tags: meta, parentId: id(spanId, 16)
|
|
658
|
+
})
|
|
659
|
+
|
|
660
|
+
spanContext._sampling = { priority: samplingPriority }
|
|
661
|
+
spanContext._trace = { origin }
|
|
662
|
+
return spanContext
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
static _getSamplingPriority (traceparentSampled, tracestateSamplingPriority, origin = null) {
|
|
666
|
+
const fromRumWithoutPriority = !tracestateSamplingPriority && origin === 'rum'
|
|
667
|
+
|
|
668
|
+
let samplingPriority
|
|
669
|
+
if (!fromRumWithoutPriority && traceparentSampled === 0 &&
|
|
670
|
+
(!tracestateSamplingPriority || tracestateSamplingPriority >= 0)) {
|
|
671
|
+
samplingPriority = 0
|
|
672
|
+
} else if (!fromRumWithoutPriority && traceparentSampled === 1 &&
|
|
673
|
+
(!tracestateSamplingPriority || tracestateSamplingPriority < 0)) {
|
|
674
|
+
samplingPriority = 1
|
|
675
|
+
} else {
|
|
676
|
+
samplingPriority = tracestateSamplingPriority
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
return samplingPriority
|
|
680
|
+
}
|
|
621
681
|
}
|
|
622
682
|
|
|
623
683
|
module.exports = TextMapPropagator
|
|
@@ -145,7 +145,7 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
145
145
|
incrementCountMetric(name, {
|
|
146
146
|
testLevel,
|
|
147
147
|
testFramework,
|
|
148
|
-
isUnsupportedCIProvider: this.
|
|
148
|
+
isUnsupportedCIProvider: !this.ciProviderName,
|
|
149
149
|
...tags
|
|
150
150
|
})
|
|
151
151
|
},
|
|
@@ -179,7 +179,7 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
179
179
|
|
|
180
180
|
this.codeOwnersEntries = getCodeOwnersFileEntries(repositoryRoot)
|
|
181
181
|
|
|
182
|
-
this.
|
|
182
|
+
this.ciProviderName = ciProviderName
|
|
183
183
|
|
|
184
184
|
this.testConfiguration = {
|
|
185
185
|
repositoryUrl,
|
|
@@ -69,6 +69,7 @@ module.exports = {
|
|
|
69
69
|
get 'node:http2' () { return require('../../../datadog-plugin-http2/src') },
|
|
70
70
|
get 'node:https' () { return require('../../../datadog-plugin-http/src') },
|
|
71
71
|
get 'node:net' () { return require('../../../datadog-plugin-net/src') },
|
|
72
|
+
get nyc () { return require('../../../datadog-plugin-nyc/src') },
|
|
72
73
|
get oracledb () { return require('../../../datadog-plugin-oracledb/src') },
|
|
73
74
|
get openai () { return require('../../../datadog-plugin-openai/src') },
|
|
74
75
|
get paperplane () { return require('../../../datadog-plugin-paperplane/src') },
|
|
@@ -77,6 +77,18 @@ function isDirectory (path) {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
function isGitAvailable () {
|
|
81
|
+
const isWindows = os.platform() === 'win32'
|
|
82
|
+
const command = isWindows ? 'where' : 'which'
|
|
83
|
+
try {
|
|
84
|
+
cp.execFileSync(command, ['git'], { stdio: 'pipe' })
|
|
85
|
+
return true
|
|
86
|
+
} catch (e) {
|
|
87
|
+
incrementCountMetric(TELEMETRY_GIT_COMMAND_ERRORS, { command: 'check_git', exitCode: 'missing' })
|
|
88
|
+
return false
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
80
92
|
function isShallowRepository () {
|
|
81
93
|
return sanitizedExec(
|
|
82
94
|
'git',
|
|
@@ -342,5 +354,6 @@ module.exports = {
|
|
|
342
354
|
getCommitsRevList,
|
|
343
355
|
GIT_REV_LIST_MAX_BUFFER,
|
|
344
356
|
isShallowRepository,
|
|
345
|
-
unshallowRepository
|
|
357
|
+
unshallowRepository,
|
|
358
|
+
isGitAvailable
|
|
346
359
|
}
|
|
@@ -317,7 +317,7 @@ function updateConfig (changes, config) {
|
|
|
317
317
|
'sampler.rules': 'DD_TRACE_SAMPLING_RULES'
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
-
const namesNeedFormatting = new Set(['DD_TAGS', 'peerServiceMapping'])
|
|
320
|
+
const namesNeedFormatting = new Set(['DD_TAGS', 'peerServiceMapping', 'serviceMapping'])
|
|
321
321
|
|
|
322
322
|
const configuration = []
|
|
323
323
|
const names = [] // list of config names whose values have been changed
|