dd-trace 5.96.0 → 5.97.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 +34 -0
- package/package.json +9 -7
- package/packages/datadog-esbuild/index.js +20 -9
- package/packages/datadog-instrumentations/src/child_process.js +7 -17
- package/packages/datadog-instrumentations/src/crypto.js +1 -2
- package/packages/datadog-instrumentations/src/cucumber.js +4 -1
- package/packages/datadog-instrumentations/src/cypress-config.js +324 -0
- package/packages/datadog-instrumentations/src/cypress.js +86 -4
- package/packages/datadog-instrumentations/src/dns.js +1 -2
- package/packages/datadog-instrumentations/src/express.js +4 -4
- package/packages/datadog-instrumentations/src/fs.js +27 -29
- package/packages/datadog-instrumentations/src/graphql.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/bundler-register.js +41 -13
- package/packages/datadog-instrumentations/src/helpers/hook.js +31 -6
- package/packages/datadog-instrumentations/src/helpers/hooks.js +12 -19
- package/packages/datadog-instrumentations/src/helpers/instrument.js +27 -13
- package/packages/datadog-instrumentations/src/helpers/register.js +103 -142
- package/packages/datadog-instrumentations/src/http/client.js +2 -3
- package/packages/datadog-instrumentations/src/http/server.js +2 -5
- package/packages/datadog-instrumentations/src/http2/client.js +1 -3
- package/packages/datadog-instrumentations/src/http2/server.js +1 -3
- package/packages/datadog-instrumentations/src/jest.js +13 -4
- package/packages/datadog-instrumentations/src/limitd-client.js +1 -1
- package/packages/datadog-instrumentations/src/mocha/utils.js +4 -1
- package/packages/datadog-instrumentations/src/net.js +2 -8
- package/packages/datadog-instrumentations/src/pino.js +1 -1
- package/packages/datadog-instrumentations/src/playwright.js +4 -1
- package/packages/datadog-instrumentations/src/prisma.js +1 -2
- package/packages/datadog-instrumentations/src/selenium.js +4 -1
- package/packages/datadog-instrumentations/src/sequelize.js +1 -1
- package/packages/datadog-instrumentations/src/url.js +1 -3
- package/packages/datadog-instrumentations/src/vitest.js +5 -1
- package/packages/datadog-instrumentations/src/vm.js +1 -3
- package/packages/datadog-plugin-aws-sdk/src/base.js +4 -3
- package/packages/datadog-plugin-cucumber/src/index.js +7 -3
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +57 -5
- package/packages/datadog-plugin-graphql/src/resolve.js +1 -1
- package/packages/datadog-plugin-jest/src/index.js +4 -2
- package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +31 -4
- package/packages/datadog-plugin-mocha/src/index.js +5 -2
- package/packages/datadog-plugin-next/src/index.js +2 -14
- package/packages/datadog-plugin-openai/src/services.js +1 -0
- package/packages/datadog-webpack/index.js +3 -3
- package/packages/dd-trace/index.js +12 -10
- package/packages/dd-trace/src/agent/url.js +2 -2
- package/packages/dd-trace/src/aiguard/sdk.js +4 -0
- package/packages/dd-trace/src/appsec/blocking.js +3 -0
- package/packages/dd-trace/src/appsec/iast/iast-plugin.js +1 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +1 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +1 -1
- package/packages/dd-trace/src/appsec/remote_config.js +1 -0
- package/packages/dd-trace/src/appsec/sdk/index.js +4 -0
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +6 -1
- package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +4 -0
- package/packages/dd-trace/src/config/defaults.js +316 -146
- package/packages/dd-trace/src/config/generated-config-types.d.ts +4 -1
- package/packages/dd-trace/src/config/helper.js +59 -10
- package/packages/dd-trace/src/config/index.js +569 -1505
- package/packages/dd-trace/src/config/parsers.js +256 -0
- package/packages/dd-trace/src/config/remote_config.js +59 -2
- package/packages/dd-trace/src/config/supported-configurations.json +350 -433
- package/packages/dd-trace/src/crashtracking/crashtracker.js +7 -1
- package/packages/dd-trace/src/crashtracking/index.js +1 -7
- package/packages/dd-trace/src/debugger/index.js +1 -1
- package/packages/dd-trace/src/dogstatsd.js +12 -9
- package/packages/dd-trace/src/encode/0.4.js +1 -1
- package/packages/dd-trace/src/exporters/agent/writer.js +7 -1
- package/packages/dd-trace/src/exporters/common/request.js +9 -0
- package/packages/dd-trace/src/exporters/common/writer.js +12 -2
- package/packages/dd-trace/src/heap_snapshots.js +3 -0
- package/packages/dd-trace/src/index.js +5 -2
- package/packages/dd-trace/src/lambda/runtime/ritm.js +6 -6
- package/packages/dd-trace/src/llmobs/index.js +4 -1
- package/packages/dd-trace/src/llmobs/plugins/ai/index.js +5 -1
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +60 -12
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +4 -2
- package/packages/dd-trace/src/llmobs/sdk.js +12 -8
- package/packages/dd-trace/src/llmobs/span_processor.js +1 -1
- package/packages/dd-trace/src/llmobs/tagger.js +9 -6
- package/packages/dd-trace/src/llmobs/writers/base.js +2 -0
- package/packages/dd-trace/src/llmobs/writers/util.js +3 -0
- package/packages/dd-trace/src/log/index.js +26 -55
- package/packages/dd-trace/src/log/writer.js +7 -19
- package/packages/dd-trace/src/noop/proxy.js +8 -0
- package/packages/dd-trace/src/opentelemetry/logs/index.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +1 -1
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +9 -4
- package/packages/dd-trace/src/payload-tagging/config/index.js +6 -5
- package/packages/dd-trace/src/plugin_manager.js +8 -6
- package/packages/dd-trace/src/plugins/ci_plugin.js +4 -0
- package/packages/dd-trace/src/plugins/plugin.js +7 -4
- package/packages/dd-trace/src/process-tags/index.js +3 -0
- package/packages/dd-trace/src/profiler.js +27 -2
- package/packages/dd-trace/src/profiling/config.js +73 -241
- package/packages/dd-trace/src/profiling/exporter_cli.js +1 -4
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +6 -2
- package/packages/dd-trace/src/profiling/profiler.js +56 -44
- package/packages/dd-trace/src/profiling/profilers/events.js +2 -3
- package/packages/dd-trace/src/profiling/profilers/wall.js +89 -6
- package/packages/dd-trace/src/profiling/ssi-heuristics.js +4 -1
- package/packages/dd-trace/src/propagation-hash/index.js +2 -1
- package/packages/dd-trace/src/proxy.js +32 -3
- package/packages/dd-trace/src/remote_config/index.js +3 -0
- package/packages/dd-trace/src/require-package-json.js +8 -4
- package/packages/dd-trace/src/ritm.js +58 -26
- package/packages/dd-trace/src/runtime_metrics/index.js +3 -0
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +3 -0
- package/packages/dd-trace/src/sampler.js +1 -1
- package/packages/dd-trace/src/standalone/index.js +3 -0
- package/packages/dd-trace/src/telemetry/index.js +2 -3
- package/packages/dd-trace/src/telemetry/send-data.js +5 -19
- package/packages/dd-trace/src/telemetry/session-propagation.js +19 -44
- package/packages/dd-trace/src/telemetry/telemetry.js +28 -171
- package/packages/dd-trace/src/util.js +0 -9
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
+
|
|
2
3
|
const { inspect } = require('util')
|
|
4
|
+
|
|
5
|
+
const { defaults } = require('../config/defaults')
|
|
3
6
|
const { isTrue } = require('../util')
|
|
4
7
|
const { getValueFromEnvSources } = require('../config/helper')
|
|
5
8
|
const { traceChannel, debugChannel, infoChannel, warnChannel, errorChannel } = require('./channels')
|
|
@@ -8,12 +11,17 @@ const { Log, LogConfig, NoTransmitError } = require('./log')
|
|
|
8
11
|
const { memoize } = require('./utils')
|
|
9
12
|
|
|
10
13
|
const config = {
|
|
11
|
-
enabled:
|
|
14
|
+
enabled: defaults.DD_TRACE_DEBUG,
|
|
12
15
|
logger: undefined,
|
|
13
|
-
logLevel:
|
|
16
|
+
logLevel: defaults.logLevel,
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
const deprecate = memoize((code, message) => {
|
|
20
|
+
publishFormatted(errorChannel, null, message)
|
|
21
|
+
return true
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
// In most places where we know we want to mute a log we use log.error() directly
|
|
17
25
|
const NO_TRANSMIT = new LogConfig(false)
|
|
18
26
|
|
|
19
27
|
const log = {
|
|
@@ -21,36 +29,6 @@ const log = {
|
|
|
21
29
|
NO_TRANSMIT,
|
|
22
30
|
NoTransmitError,
|
|
23
31
|
|
|
24
|
-
/**
|
|
25
|
-
* @returns Read-only version of logging config. To modify config, call `log.use` and `log.toggle`
|
|
26
|
-
*/
|
|
27
|
-
getConfig () {
|
|
28
|
-
return { ...config }
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
use (logger) {
|
|
32
|
-
config.logger = logger
|
|
33
|
-
logWriter.use(logger)
|
|
34
|
-
return log
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
toggle (enabled, logLevel) {
|
|
38
|
-
config.enabled = enabled
|
|
39
|
-
config.logLevel = logLevel
|
|
40
|
-
logWriter.toggle(enabled, logLevel)
|
|
41
|
-
return log
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
reset () {
|
|
45
|
-
logWriter.reset()
|
|
46
|
-
log._deprecate = memoize((code, message) => {
|
|
47
|
-
publishFormatted(errorChannel, null, message)
|
|
48
|
-
return true
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
return log
|
|
52
|
-
},
|
|
53
|
-
|
|
54
32
|
trace (...args) {
|
|
55
33
|
if (traceChannel.hasSubscribers) {
|
|
56
34
|
const logRecord = {}
|
|
@@ -66,6 +44,8 @@ const log = {
|
|
|
66
44
|
|
|
67
45
|
publishFormatted(traceChannel, null, stack.join('\n'))
|
|
68
46
|
}
|
|
47
|
+
// TODO: Why do we allow chaining here? This is likely not used anywhere.
|
|
48
|
+
// If it is used, that seems like a mistake.
|
|
69
49
|
return log
|
|
70
50
|
},
|
|
71
51
|
|
|
@@ -103,30 +83,23 @@ const log = {
|
|
|
103
83
|
},
|
|
104
84
|
|
|
105
85
|
deprecate (code, message) {
|
|
106
|
-
return
|
|
86
|
+
return deprecate(code, message)
|
|
107
87
|
},
|
|
108
88
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
89
|
+
configure (options) {
|
|
90
|
+
config.logger = options.logger
|
|
91
|
+
config.logLevel = options.logLevel ??
|
|
92
|
+
getValueFromEnvSources('DD_TRACE_LOG_LEVEL') ??
|
|
93
|
+
config.logLevel
|
|
94
|
+
config.enabled = isTrue(
|
|
112
95
|
getValueFromEnvSources('DD_TRACE_DEBUG') ??
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
config.enabled
|
|
96
|
+
// TODO: Handle this by adding a log buffer so that configure may be called with the actual configurations.
|
|
97
|
+
// eslint-disable-next-line eslint-rules/eslint-process-env
|
|
98
|
+
(process.env.OTEL_LOG_LEVEL === 'debug' || config.enabled)
|
|
116
99
|
)
|
|
117
|
-
|
|
100
|
+
logWriter.configure(config.enabled, config.logLevel, options.logger)
|
|
118
101
|
|
|
119
|
-
|
|
120
|
-
optionsValue,
|
|
121
|
-
fleetStableConfigValue,
|
|
122
|
-
localStableConfigValue
|
|
123
|
-
) {
|
|
124
|
-
return optionsValue ??
|
|
125
|
-
fleetStableConfigValue ??
|
|
126
|
-
getValueFromEnvSources('DD_TRACE_LOG_LEVEL') ??
|
|
127
|
-
getValueFromEnvSources('OTEL_LOG_LEVEL') ??
|
|
128
|
-
localStableConfigValue ??
|
|
129
|
-
config.logLevel
|
|
102
|
+
return config.enabled
|
|
130
103
|
},
|
|
131
104
|
}
|
|
132
105
|
|
|
@@ -150,8 +123,6 @@ function getErrorLog (err) {
|
|
|
150
123
|
return err
|
|
151
124
|
}
|
|
152
125
|
|
|
153
|
-
log.
|
|
154
|
-
|
|
155
|
-
log.toggle(log.isEnabled(), log.getLogLevel())
|
|
126
|
+
log.configure({})
|
|
156
127
|
|
|
157
128
|
module.exports = log
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { storage } = require('../../../datadog-core')
|
|
4
4
|
const { LogChannel } = require('./channels')
|
|
5
|
+
|
|
5
6
|
const defaultLogger = {
|
|
6
7
|
debug: msg => console.debug(msg), /* eslint-disable-line no-console */
|
|
7
8
|
info: msg => console.info(msg), /* eslint-disable-line no-console */
|
|
@@ -17,12 +18,8 @@ function withNoop (fn) {
|
|
|
17
18
|
storage('legacy').run({ noop: true }, fn)
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
function unsubscribeAll () {
|
|
21
|
-
logChannel.unsubscribe({ trace, debug, info, warn, error })
|
|
22
|
-
}
|
|
23
|
-
|
|
24
21
|
function toggleSubscription (enable, level) {
|
|
25
|
-
|
|
22
|
+
logChannel.unsubscribe({ trace, debug, info, warn, error })
|
|
26
23
|
|
|
27
24
|
if (enable) {
|
|
28
25
|
logChannel = new LogChannel(level)
|
|
@@ -30,23 +27,14 @@ function toggleSubscription (enable, level) {
|
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
29
|
|
|
33
|
-
function
|
|
30
|
+
function configure (enable, level, newLogger) {
|
|
34
31
|
enabled = enable
|
|
32
|
+
logger = typeof newLogger?.debug === 'function' && typeof newLogger.error === 'function'
|
|
33
|
+
? newLogger
|
|
34
|
+
: defaultLogger
|
|
35
35
|
toggleSubscription(enabled, level)
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
function use (newLogger) {
|
|
39
|
-
if (typeof newLogger?.debug === 'function' && typeof newLogger.error === 'function') {
|
|
40
|
-
logger = newLogger
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function reset () {
|
|
45
|
-
logger = defaultLogger
|
|
46
|
-
enabled = false
|
|
47
|
-
toggleSubscription(false)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
38
|
function error (err) {
|
|
51
39
|
withNoop(() => logger.error(err))
|
|
52
40
|
}
|
|
@@ -69,4 +57,4 @@ function trace (log) {
|
|
|
69
57
|
withNoop(() => logger.debug(log))
|
|
70
58
|
}
|
|
71
59
|
|
|
72
|
-
module.exports = {
|
|
60
|
+
module.exports = { configure, error, warn, info, debug, trace }
|
|
@@ -13,6 +13,10 @@ const noopDogStatsDClient = new NoopDogStatsDClient()
|
|
|
13
13
|
const noopLLMObs = new NoopLLMObsSDK(noop)
|
|
14
14
|
const noopOpenFeatureProvider = new NoopFlaggingProvider()
|
|
15
15
|
const noopAIGuard = new NoopAIGuardSDK()
|
|
16
|
+
const noopProfiling = {
|
|
17
|
+
setCustomLabelKeys () {},
|
|
18
|
+
runWithLabels (labels, fn) { return fn() },
|
|
19
|
+
}
|
|
16
20
|
|
|
17
21
|
/** @type {import('../../src/index')} Proxy */
|
|
18
22
|
class NoopProxy {
|
|
@@ -98,6 +102,10 @@ class NoopProxy {
|
|
|
98
102
|
return this
|
|
99
103
|
}
|
|
100
104
|
|
|
105
|
+
get profiling () {
|
|
106
|
+
return noopProfiling
|
|
107
|
+
}
|
|
108
|
+
|
|
101
109
|
get TracerProvider () {
|
|
102
110
|
return require('../opentelemetry/tracer_provider')
|
|
103
111
|
}
|
|
@@ -33,7 +33,7 @@ const OtlpHttpLogExporter = require('./otlp_http_log_exporter')
|
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Initializes OpenTelemetry Logs support
|
|
36
|
-
* @param {
|
|
36
|
+
* @param {import('../../config/config-base')} config - Tracer configuration instance
|
|
37
37
|
*/
|
|
38
38
|
function initializeOpenTelemetryLogs (config) {
|
|
39
39
|
// Build resource attributes
|
|
@@ -35,7 +35,7 @@ const OtlpHttpMetricExporter = require('./otlp_http_metric_exporter')
|
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Initializes OpenTelemetry Metrics support
|
|
38
|
-
* @param {
|
|
38
|
+
* @param {import('../../config/config-base')} config - Tracer configuration instance
|
|
39
39
|
*/
|
|
40
40
|
function initializeOpenTelemetryMetrics (config) {
|
|
41
41
|
const resourceAttributes = {
|
|
@@ -6,6 +6,7 @@ const id = require('../../id')
|
|
|
6
6
|
const DatadogSpanContext = require('../span_context')
|
|
7
7
|
const log = require('../../log')
|
|
8
8
|
const tags = require('../../../../../ext/tags')
|
|
9
|
+
const { getConfiguredEnvName } = require('../../config/helper')
|
|
9
10
|
const { setBaggageItem, getAllBaggageItems, removeAllBaggageItems } = require('../../baggage')
|
|
10
11
|
const telemetryMetrics = require('../../telemetry/metrics')
|
|
11
12
|
|
|
@@ -65,8 +66,15 @@ const zeroTraceId = '0000000000000000'
|
|
|
65
66
|
const hex16 = /^[0-9A-Fa-f]{16}$/
|
|
66
67
|
|
|
67
68
|
class TextMapPropagator {
|
|
69
|
+
#extractB3Context
|
|
70
|
+
|
|
68
71
|
constructor (config) {
|
|
69
72
|
this._config = config
|
|
73
|
+
|
|
74
|
+
// TODO: should match "b3 single header" in next major
|
|
75
|
+
const envName = getConfiguredEnvName('DD_TRACE_PROPAGATION_STYLE')
|
|
76
|
+
// eslint-disable-next-line eslint-rules/eslint-env-aliases
|
|
77
|
+
this.#extractB3Context = envName === 'OTEL_PROPAGATORS' ? this._extractB3SingleContext : this._extractB3MultiContext
|
|
70
78
|
}
|
|
71
79
|
|
|
72
80
|
inject (spanContext, carrier) {
|
|
@@ -363,10 +371,7 @@ class TextMapPropagator {
|
|
|
363
371
|
extractedContext = this._extractB3SingleContext(carrier)
|
|
364
372
|
break
|
|
365
373
|
case 'b3':
|
|
366
|
-
extractedContext = this
|
|
367
|
-
// TODO: should match "b3 single header" in next major
|
|
368
|
-
? this._extractB3SingleContext(carrier)
|
|
369
|
-
: this._extractB3MultiContext(carrier)
|
|
374
|
+
extractedContext = this.#extractB3Context(carrier)
|
|
370
375
|
break
|
|
371
376
|
case 'b3multi':
|
|
372
377
|
extractedContext = this._extractB3MultiContext(carrier)
|
|
@@ -3,16 +3,17 @@
|
|
|
3
3
|
const aws = require('./aws.json')
|
|
4
4
|
const sdks = { aws }
|
|
5
5
|
|
|
6
|
+
/** @typedef {Record<string, { request: string[], response: string[], expand: string[] }>} SDKRules */
|
|
6
7
|
/**
|
|
7
8
|
* Builds rules per service for a given SDK, appending user-provided rules.
|
|
8
9
|
*
|
|
9
|
-
* @param {
|
|
10
|
+
* @param {SDKRules} sdk
|
|
10
11
|
* @param {string[]} requestInput
|
|
11
12
|
* @param {string[]} responseInput
|
|
12
|
-
* @returns {
|
|
13
|
+
* @returns {SDKRules}
|
|
13
14
|
*/
|
|
14
15
|
function getSDKRules (sdk, requestInput, responseInput) {
|
|
15
|
-
const sdkServiceRules = {}
|
|
16
|
+
const sdkServiceRules = /** @type {SDKRules} */ ({})
|
|
16
17
|
for (const [service, serviceRules] of Object.entries(sdk)) {
|
|
17
18
|
sdkServiceRules[service] = {
|
|
18
19
|
// Make a copy. Otherwise calling the function multiple times would append
|
|
@@ -31,10 +32,10 @@ function getSDKRules (sdk, requestInput, responseInput) {
|
|
|
31
32
|
*
|
|
32
33
|
* @param {string[]} [requestInput=[]]
|
|
33
34
|
* @param {string[]} [responseInput=[]]
|
|
34
|
-
* @returns {Record<string,
|
|
35
|
+
* @returns {Record<string, SDKRules>}
|
|
35
36
|
*/
|
|
36
37
|
function appendRules (requestInput = [], responseInput = []) {
|
|
37
|
-
const sdkRules = {}
|
|
38
|
+
const sdkRules = /** @type {Record<string, SDKRules>} */ ({})
|
|
38
39
|
for (const [name, sdk] of Object.entries(sdks)) {
|
|
39
40
|
sdkRules[name] = getSDKRules(sdk, requestInput, responseInput)
|
|
40
41
|
}
|
|
@@ -67,7 +67,6 @@ function getEnabled (Plugin) {
|
|
|
67
67
|
module.exports = class PluginManager {
|
|
68
68
|
constructor (tracer) {
|
|
69
69
|
this._tracer = tracer
|
|
70
|
-
this._tracerConfig = null
|
|
71
70
|
this._pluginsByName = {}
|
|
72
71
|
this._configsByName = {}
|
|
73
72
|
|
|
@@ -104,7 +103,7 @@ module.exports = class PluginManager {
|
|
|
104
103
|
|
|
105
104
|
// extracts predetermined configuration from tracer and combines it with plugin-specific config
|
|
106
105
|
this._pluginsByName[name].configure({
|
|
107
|
-
...this
|
|
106
|
+
...this.#getSharedConfig(name),
|
|
108
107
|
...pluginConfig,
|
|
109
108
|
})
|
|
110
109
|
}
|
|
@@ -121,8 +120,11 @@ module.exports = class PluginManager {
|
|
|
121
120
|
this.loadPlugin(name)
|
|
122
121
|
}
|
|
123
122
|
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Like instrumenter.enable()
|
|
125
|
+
* @param {import('./config/config-base')} config - Tracer configuration
|
|
126
|
+
*/
|
|
127
|
+
configure (config) {
|
|
126
128
|
this._tracerConfig = config
|
|
127
129
|
this._tracer._nomenclature.configure(config)
|
|
128
130
|
|
|
@@ -148,7 +150,7 @@ module.exports = class PluginManager {
|
|
|
148
150
|
}
|
|
149
151
|
|
|
150
152
|
// TODO: figure out a better way to handle this
|
|
151
|
-
|
|
153
|
+
#getSharedConfig (name) {
|
|
152
154
|
const {
|
|
153
155
|
logInjection,
|
|
154
156
|
serviceMapping,
|
|
@@ -172,7 +174,7 @@ module.exports = class PluginManager {
|
|
|
172
174
|
traceWebsocketMessagesSeparateTraces,
|
|
173
175
|
experimental,
|
|
174
176
|
resourceRenamingEnabled,
|
|
175
|
-
} = this._tracerConfig
|
|
177
|
+
} = /** @type {import('./config/config-base')} */ (this._tracerConfig)
|
|
176
178
|
|
|
177
179
|
const sharedConfig = {
|
|
178
180
|
codeOriginForSpans,
|
|
@@ -469,6 +469,10 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
469
469
|
return getSessionRequestErrorTags(this.testSessionSpan)
|
|
470
470
|
}
|
|
471
471
|
|
|
472
|
+
/**
|
|
473
|
+
* @param {import('../config/config-base')} config - Tracer configuration
|
|
474
|
+
* @param {boolean} shouldGetEnvironmentData - Whether to get environment data
|
|
475
|
+
*/
|
|
472
476
|
configure (config, shouldGetEnvironmentData = true) {
|
|
473
477
|
super.configure(config)
|
|
474
478
|
|
|
@@ -72,7 +72,7 @@ module.exports = class Plugin {
|
|
|
72
72
|
* Create a new plugin instance.
|
|
73
73
|
*
|
|
74
74
|
* @param {object} tracer Tracer instance or wrapper containing it under `_tracer`.
|
|
75
|
-
* @param {
|
|
75
|
+
* @param {import('../config/config-base')} tracerConfig Global tracer configuration object.
|
|
76
76
|
*/
|
|
77
77
|
constructor (tracer, tracerConfig) {
|
|
78
78
|
this._subscriptions = []
|
|
@@ -80,6 +80,8 @@ module.exports = class Plugin {
|
|
|
80
80
|
this._enabled = false
|
|
81
81
|
this._tracer = tracer
|
|
82
82
|
this.config = {} // plugin-specific configuration, unset until .configure() is called
|
|
83
|
+
|
|
84
|
+
/** @type {import('../config/config-base')} */
|
|
83
85
|
this._tracerConfig = tracerConfig // global tracer configuration
|
|
84
86
|
}
|
|
85
87
|
|
|
@@ -163,9 +165,10 @@ module.exports = class Plugin {
|
|
|
163
165
|
/**
|
|
164
166
|
* Enable or disable the plugin and (re)apply its configuration.
|
|
165
167
|
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* @
|
|
168
|
+
* TODO: Remove the overloading with `enabled` and use the config object directly.
|
|
169
|
+
*
|
|
170
|
+
* @param {boolean|import('../config/config-base')} config Either a boolean to enable/disable
|
|
171
|
+
* or a configuration object containing at least `{ enabled: boolean }`.
|
|
169
172
|
*/
|
|
170
173
|
configure (config) {
|
|
171
174
|
if (typeof config === 'boolean') {
|
|
@@ -72,6 +72,9 @@ function buildProcessTags (config) {
|
|
|
72
72
|
|
|
73
73
|
// Singleton with constant defaults so pre-init reads don't blow up
|
|
74
74
|
const processTags = module.exports = {
|
|
75
|
+
/**
|
|
76
|
+
* @param {import('../config/config-base')} config
|
|
77
|
+
*/
|
|
75
78
|
initialize (config) {
|
|
76
79
|
// check if one of the properties added during build exist and if so return
|
|
77
80
|
if (processTags.tags) return
|
|
@@ -5,13 +5,38 @@ const { profiler } = require('./profiling')
|
|
|
5
5
|
globalThis[Symbol.for('dd-trace')].beforeExitHandlers.add(() => { profiler.stop() })
|
|
6
6
|
|
|
7
7
|
module.exports = {
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* @param {import('./config/config-base')} config - Tracer configuration
|
|
10
|
+
*/
|
|
11
|
+
start (config) {
|
|
9
12
|
// Forward the full tracer config to the profiling layer.
|
|
10
13
|
// Profiling code is responsible for deriving the specific options it needs.
|
|
11
14
|
return profiler.start(config)
|
|
12
15
|
},
|
|
13
16
|
|
|
14
|
-
stop
|
|
17
|
+
stop () {
|
|
15
18
|
profiler.stop()
|
|
16
19
|
},
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Declares the set of custom label keys that will be used with
|
|
23
|
+
* {@link runWithLabels}.
|
|
24
|
+
*
|
|
25
|
+
* @param {Iterable<string>} keys - Custom label key names
|
|
26
|
+
*/
|
|
27
|
+
setCustomLabelKeys: (keys) => {
|
|
28
|
+
profiler.setCustomLabelKeys(keys)
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Runs a function with custom profiling labels attached to wall profiler samples.
|
|
33
|
+
*
|
|
34
|
+
* @param {Record<string, string | number>} labels - Custom labels to attach
|
|
35
|
+
* @param {function(): T} fn - Function to execute with the labels
|
|
36
|
+
* @returns {T} The return value of fn
|
|
37
|
+
* @template T
|
|
38
|
+
*/
|
|
39
|
+
runWithLabels: (labels, fn) => {
|
|
40
|
+
return profiler.runWithLabels(labels, fn)
|
|
41
|
+
},
|
|
17
42
|
}
|