dd-trace 5.0.0-pre-b37a12e → 5.0.0-pre-12a0f76
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/LICENSE-3rdparty.csv +1 -0
- package/package.json +3 -2
- package/packages/datadog-plugin-jest/src/index.js +13 -2
- package/packages/datadog-plugin-jest/src/util.js +41 -0
- package/packages/datadog-plugin-memcached/src/index.js +10 -5
- package/packages/dd-trace/src/appsec/remote_config/manager.js +11 -3
- package/packages/dd-trace/src/config.js +8 -0
- package/packages/dd-trace/src/format.js +3 -0
- package/packages/dd-trace/src/plugin_manager.js +3 -1
- package/packages/dd-trace/src/plugins/util/git.js +26 -4
- package/packages/dd-trace/src/plugins/util/test.js +4 -0
- package/packages/dd-trace/src/profiling/config.js +36 -5
- package/packages/dd-trace/src/profiling/profilers/wall.js +7 -1
- package/packages/dd-trace/src/service-naming/extra-services.js +24 -0
package/LICENSE-3rdparty.csv
CHANGED
|
@@ -14,6 +14,7 @@ require,import-in-the-middle,Apache license 2.0,Copyright 2021 Datadog Inc.
|
|
|
14
14
|
require,int64-buffer,MIT,Copyright 2015-2016 Yusuke Kawasaki
|
|
15
15
|
require,ipaddr.js,MIT,Copyright 2011-2017 whitequark
|
|
16
16
|
require,istanbul-lib-coverage,BSD-3-Clause,Copyright 2012-2015 Yahoo! Inc.
|
|
17
|
+
require,jest-docblock,MIT,Copyright Meta Platforms, Inc. and affiliates.
|
|
17
18
|
require,koalas,MIT,Copyright 2013-2017 Brian Woodward
|
|
18
19
|
require,limiter,MIT,Copyright 2011 John Hurliman
|
|
19
20
|
require,lodash.kebabcase,MIT,Copyright JS Foundation and other contributors
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dd-trace",
|
|
3
|
-
"version": "5.0.0-pre-
|
|
3
|
+
"version": "5.0.0-pre-12a0f76",
|
|
4
4
|
"description": "Datadog APM tracing client for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@datadog/native-iast-rewriter": "2.1.3",
|
|
73
73
|
"@datadog/native-iast-taint-tracking": "1.5.0",
|
|
74
74
|
"@datadog/native-metrics": "^2.0.0",
|
|
75
|
-
"@datadog/pprof": "
|
|
75
|
+
"@datadog/pprof": "4.0.0",
|
|
76
76
|
"@datadog/sketches-js": "^2.1.0",
|
|
77
77
|
"@opentelemetry/api": "^1.0.0",
|
|
78
78
|
"@opentelemetry/core": "^1.14.0",
|
|
@@ -83,6 +83,7 @@
|
|
|
83
83
|
"int64-buffer": "^0.1.9",
|
|
84
84
|
"ipaddr.js": "^2.1.0",
|
|
85
85
|
"istanbul-lib-coverage": "3.2.0",
|
|
86
|
+
"jest-docblock": "^29.7.0",
|
|
86
87
|
"koalas": "^1.0.2",
|
|
87
88
|
"limiter": "^1.1.4",
|
|
88
89
|
"lodash.kebabcase": "^4.1.1",
|
|
@@ -10,7 +10,9 @@ const {
|
|
|
10
10
|
TEST_PARAMETERS,
|
|
11
11
|
TEST_COMMAND,
|
|
12
12
|
TEST_FRAMEWORK_VERSION,
|
|
13
|
-
TEST_SOURCE_START
|
|
13
|
+
TEST_SOURCE_START,
|
|
14
|
+
TEST_ITR_UNSKIPPABLE,
|
|
15
|
+
TEST_ITR_FORCED_RUN
|
|
14
16
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
15
17
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
16
18
|
const id = require('../../dd-trace/src/id')
|
|
@@ -89,7 +91,9 @@ class JestPlugin extends CiPlugin {
|
|
|
89
91
|
const {
|
|
90
92
|
_ddTestSessionId: testSessionId,
|
|
91
93
|
_ddTestCommand: testCommand,
|
|
92
|
-
_ddTestModuleId: testModuleId
|
|
94
|
+
_ddTestModuleId: testModuleId,
|
|
95
|
+
_ddForcedToRun,
|
|
96
|
+
_ddUnskippable
|
|
93
97
|
} = testEnvironmentOptions
|
|
94
98
|
|
|
95
99
|
const testSessionSpanContext = this.tracer.extract('text_map', {
|
|
@@ -99,6 +103,13 @@ class JestPlugin extends CiPlugin {
|
|
|
99
103
|
|
|
100
104
|
const testSuiteMetadata = getTestSuiteCommonTags(testCommand, frameworkVersion, testSuite, 'jest')
|
|
101
105
|
|
|
106
|
+
if (_ddUnskippable) {
|
|
107
|
+
testSuiteMetadata[TEST_ITR_UNSKIPPABLE] = 'true'
|
|
108
|
+
if (_ddForcedToRun) {
|
|
109
|
+
testSuiteMetadata[TEST_ITR_FORCED_RUN] = 'true'
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
102
113
|
this.testSuiteSpan = this.tracer.startSpan('jest.test_suite', {
|
|
103
114
|
childOf: testSessionSpanContext,
|
|
104
115
|
tags: {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
const { readFileSync } = require('fs')
|
|
2
|
+
const { parse, extract } = require('jest-docblock')
|
|
3
|
+
|
|
1
4
|
const { getTestSuitePath } = require('../../dd-trace/src/plugins/util/test')
|
|
5
|
+
const log = require('../../dd-trace/src/log')
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* There are two ways to call `test.each` in `jest`:
|
|
@@ -47,10 +51,47 @@ function getJestTestName (test) {
|
|
|
47
51
|
return titles.join(' ')
|
|
48
52
|
}
|
|
49
53
|
|
|
54
|
+
function isMarkedAsUnskippable (test) {
|
|
55
|
+
let docblocks
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
const testSource = readFileSync(test.path, 'utf8')
|
|
59
|
+
docblocks = parse(extract(testSource))
|
|
60
|
+
} catch (e) {
|
|
61
|
+
// If we have issues parsing the file, we'll assume no unskippable was passed
|
|
62
|
+
return false
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// docblocks were correctly parsed but it does not include a @datadog block
|
|
66
|
+
if (!docblocks?.datadog) {
|
|
67
|
+
return false
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
return JSON.parse(docblocks.datadog).unskippable
|
|
72
|
+
} catch (e) {
|
|
73
|
+
// If the @datadog block comment is present but malformed, we'll run the suite
|
|
74
|
+
log.warn('@datadog block comment is malformed.')
|
|
75
|
+
return true
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
50
79
|
function getJestSuitesToRun (skippableSuites, originalTests, rootDir) {
|
|
51
80
|
return originalTests.reduce((acc, test) => {
|
|
52
81
|
const relativePath = getTestSuitePath(test.path, rootDir)
|
|
53
82
|
const shouldBeSkipped = skippableSuites.includes(relativePath)
|
|
83
|
+
|
|
84
|
+
if (isMarkedAsUnskippable(test)) {
|
|
85
|
+
acc.suitesToRun.push(test)
|
|
86
|
+
if (test?.context?.config?.testEnvironmentOptions) {
|
|
87
|
+
test.context.config.testEnvironmentOptions['_ddUnskippable'] = true
|
|
88
|
+
if (shouldBeSkipped) {
|
|
89
|
+
test.context.config.testEnvironmentOptions['_ddForcedToRun'] = true
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return acc
|
|
93
|
+
}
|
|
94
|
+
|
|
54
95
|
if (shouldBeSkipped) {
|
|
55
96
|
acc.skippedSuites.push(relativePath)
|
|
56
97
|
} else {
|
|
@@ -9,15 +9,20 @@ class MemcachedPlugin extends CachePlugin {
|
|
|
9
9
|
start ({ client, server, query }) {
|
|
10
10
|
const address = getAddress(client, server, query)
|
|
11
11
|
|
|
12
|
+
const meta = {
|
|
13
|
+
'out.host': address[0],
|
|
14
|
+
[CLIENT_PORT_KEY]: address[1]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (this.config.memcachedCommandEnabled) {
|
|
18
|
+
meta['memcached.command'] = query.command
|
|
19
|
+
}
|
|
20
|
+
|
|
12
21
|
this.startSpan({
|
|
13
22
|
service: this.serviceName({ pluginConfig: this.config, system: this.system }),
|
|
14
23
|
resource: query.type,
|
|
15
24
|
type: 'memcached',
|
|
16
|
-
meta
|
|
17
|
-
'memcached.command': query.command,
|
|
18
|
-
'out.host': address[0],
|
|
19
|
-
[CLIENT_PORT_KEY]: address[1]
|
|
20
|
-
}
|
|
25
|
+
meta
|
|
21
26
|
})
|
|
22
27
|
}
|
|
23
28
|
}
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
const { URL, format } = require('url')
|
|
4
4
|
const uuid = require('crypto-randomuuid')
|
|
5
5
|
const { EventEmitter } = require('events')
|
|
6
|
-
const Scheduler = require('./scheduler')
|
|
7
6
|
const tracerVersion = require('../../../../../package.json').version
|
|
8
7
|
const request = require('../../exporters/common/request')
|
|
9
8
|
const log = require('../../log')
|
|
9
|
+
const { getExtraServices } = require('../../service-naming/extra-services')
|
|
10
10
|
const { UNACKNOWLEDGED, ACKNOWLEDGED, ERROR } = require('./apply_states')
|
|
11
|
+
const Scheduler = require('./scheduler')
|
|
11
12
|
|
|
12
13
|
const clientId = uuid()
|
|
13
14
|
|
|
@@ -57,7 +58,8 @@ class RemoteConfigManager extends EventEmitter {
|
|
|
57
58
|
tracer_version: tracerVersion,
|
|
58
59
|
service: config.service,
|
|
59
60
|
env: config.env,
|
|
60
|
-
app_version: config.version
|
|
61
|
+
app_version: config.version,
|
|
62
|
+
extra_services: []
|
|
61
63
|
},
|
|
62
64
|
capabilities: DEFAULT_CAPABILITY // updated by `updateCapabilities()`
|
|
63
65
|
},
|
|
@@ -113,8 +115,14 @@ class RemoteConfigManager extends EventEmitter {
|
|
|
113
115
|
this.state.client.products = this.eventNames().filter(e => typeof e === 'string')
|
|
114
116
|
}
|
|
115
117
|
|
|
118
|
+
getPayload () {
|
|
119
|
+
this.state.client.client_tracer.extra_services = getExtraServices()
|
|
120
|
+
|
|
121
|
+
return JSON.stringify(this.state)
|
|
122
|
+
}
|
|
123
|
+
|
|
116
124
|
poll (cb) {
|
|
117
|
-
request(
|
|
125
|
+
request(this.getPayload(), this.requestOptions, (err, data, statusCode) => {
|
|
118
126
|
// 404 means RC is disabled, ignore it
|
|
119
127
|
if (statusCode === 404) return cb()
|
|
120
128
|
|
|
@@ -179,6 +179,11 @@ class Config {
|
|
|
179
179
|
false
|
|
180
180
|
)
|
|
181
181
|
|
|
182
|
+
const DD_TRACE_MEMCACHED_COMMAND_ENABLED = coalesce(
|
|
183
|
+
process.env.DD_TRACE_MEMCACHED_COMMAND_ENABLED,
|
|
184
|
+
false
|
|
185
|
+
)
|
|
186
|
+
|
|
182
187
|
const DD_SERVICE = options.service ||
|
|
183
188
|
process.env.DD_SERVICE ||
|
|
184
189
|
process.env.DD_SERVICE_NAME ||
|
|
@@ -629,6 +634,9 @@ ken|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?)
|
|
|
629
634
|
|
|
630
635
|
this.openaiSpanCharLimit = DD_OPENAI_SPAN_CHAR_LIMIT
|
|
631
636
|
|
|
637
|
+
// Requires an accompanying DD_APM_OBFUSCATION_MEMCACHED_KEEP_COMMAND=true in the agent
|
|
638
|
+
this.memcachedCommandEnabled = isTrue(DD_TRACE_MEMCACHED_COMMAND_ENABLED)
|
|
639
|
+
|
|
632
640
|
if (this.gitMetadataEnabled) {
|
|
633
641
|
this.repositoryUrl = coalesce(
|
|
634
642
|
process.env.DD_GIT_REPOSITORY_URL,
|
|
@@ -4,6 +4,7 @@ const constants = require('./constants')
|
|
|
4
4
|
const tags = require('../../../ext/tags')
|
|
5
5
|
const id = require('./id')
|
|
6
6
|
const { isError } = require('./util')
|
|
7
|
+
const { registerExtraService } = require('./service-naming/extra-services')
|
|
7
8
|
|
|
8
9
|
const SAMPLING_PRIORITY_KEY = constants.SAMPLING_PRIORITY_KEY
|
|
9
10
|
const SAMPLING_RULE_DECISION = constants.SAMPLING_RULE_DECISION
|
|
@@ -76,6 +77,8 @@ function extractTags (trace, span) {
|
|
|
76
77
|
const tracerService = span.tracer()._service.toLowerCase()
|
|
77
78
|
if (tags['service.name']?.toLowerCase() !== tracerService) {
|
|
78
79
|
span.setTag(BASE_SERVICE, tracerService)
|
|
80
|
+
|
|
81
|
+
registerExtraService(tags['service.name'])
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
for (const tag in tags) {
|
|
@@ -136,7 +136,8 @@ module.exports = class PluginManager {
|
|
|
136
136
|
headerTags,
|
|
137
137
|
dbmPropagationMode,
|
|
138
138
|
dsmEnabled,
|
|
139
|
-
clientIpEnabled
|
|
139
|
+
clientIpEnabled,
|
|
140
|
+
memcachedCommandEnabled
|
|
140
141
|
} = this._tracerConfig
|
|
141
142
|
|
|
142
143
|
const sharedConfig = {}
|
|
@@ -151,6 +152,7 @@ module.exports = class PluginManager {
|
|
|
151
152
|
|
|
152
153
|
sharedConfig.dbmPropagationMode = dbmPropagationMode
|
|
153
154
|
sharedConfig.dsmEnabled = dsmEnabled
|
|
155
|
+
sharedConfig.memcachedCommandEnabled = memcachedCommandEnabled
|
|
154
156
|
|
|
155
157
|
if (serviceMapping && serviceMapping[name]) {
|
|
156
158
|
sharedConfig.service = serviceMapping[name]
|
|
@@ -61,15 +61,37 @@ function unshallowRepository () {
|
|
|
61
61
|
}
|
|
62
62
|
const defaultRemoteName = sanitizedExec('git', ['config', '--default', 'origin', '--get', 'clone.defaultRemoteName'])
|
|
63
63
|
const revParseHead = sanitizedExec('git', ['rev-parse', 'HEAD'])
|
|
64
|
-
|
|
64
|
+
|
|
65
|
+
const baseGitOptions = [
|
|
65
66
|
'fetch',
|
|
66
67
|
'--shallow-since="1 month ago"',
|
|
67
68
|
'--update-shallow',
|
|
68
69
|
'--filter=blob:none',
|
|
69
70
|
'--recurse-submodules=no',
|
|
70
|
-
defaultRemoteName
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
defaultRemoteName
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
execFileSync('git', [
|
|
76
|
+
...baseGitOptions,
|
|
77
|
+
revParseHead
|
|
78
|
+
])
|
|
79
|
+
} catch (e) {
|
|
80
|
+
// If the local HEAD is a commit that has not been pushed to the remote, the above command will fail.
|
|
81
|
+
log.error(e)
|
|
82
|
+
const upstreamRemote = sanitizedExec('git', ['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{upstream}'])
|
|
83
|
+
try {
|
|
84
|
+
execFileSync('git', [
|
|
85
|
+
...baseGitOptions,
|
|
86
|
+
upstreamRemote
|
|
87
|
+
])
|
|
88
|
+
} catch (e) {
|
|
89
|
+
// If the CI is working on a detached HEAD or branch tracking hasn’t been set up, the above command will fail.
|
|
90
|
+
log.error(e)
|
|
91
|
+
// We use sanitizedExec here because if this last option fails, we'll give up.
|
|
92
|
+
sanitizedExec('git', baseGitOptions)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
73
95
|
}
|
|
74
96
|
|
|
75
97
|
function getRepositoryUrl () {
|
|
@@ -58,6 +58,8 @@ const TEST_ITR_SKIPPING_ENABLED = 'test.itr.tests_skipping.enabled'
|
|
|
58
58
|
const TEST_ITR_SKIPPING_TYPE = 'test.itr.tests_skipping.type'
|
|
59
59
|
const TEST_ITR_SKIPPING_COUNT = 'test.itr.tests_skipping.count'
|
|
60
60
|
const TEST_CODE_COVERAGE_ENABLED = 'test.code_coverage.enabled'
|
|
61
|
+
const TEST_ITR_UNSKIPPABLE = 'test.itr.unskippable'
|
|
62
|
+
const TEST_ITR_FORCED_RUN = 'test.itr.forced_run'
|
|
61
63
|
|
|
62
64
|
const TEST_CODE_COVERAGE_LINES_PCT = 'test.code_coverage.lines_pct'
|
|
63
65
|
|
|
@@ -107,6 +109,8 @@ module.exports = {
|
|
|
107
109
|
TEST_ITR_SKIPPING_COUNT,
|
|
108
110
|
TEST_CODE_COVERAGE_ENABLED,
|
|
109
111
|
TEST_CODE_COVERAGE_LINES_PCT,
|
|
112
|
+
TEST_ITR_UNSKIPPABLE,
|
|
113
|
+
TEST_ITR_FORCED_RUN,
|
|
110
114
|
addIntelligentTestRunnerSpanTags,
|
|
111
115
|
getCoveredFilenamesFromCoverage,
|
|
112
116
|
resetCoverage,
|
|
@@ -37,6 +37,8 @@ class Config {
|
|
|
37
37
|
DD_PROFILING_EXPERIMENTAL_OOM_HEAP_LIMIT_EXTENSION_SIZE,
|
|
38
38
|
DD_PROFILING_EXPERIMENTAL_OOM_MAX_HEAP_EXTENSION_COUNT,
|
|
39
39
|
DD_PROFILING_EXPERIMENTAL_OOM_EXPORT_STRATEGIES,
|
|
40
|
+
DD_PROFILING_CODEHOTSPOTS_ENABLED,
|
|
41
|
+
DD_PROFILING_ENDPOINT_COLLECTION_ENABLED,
|
|
40
42
|
DD_PROFILING_EXPERIMENTAL_CODEHOTSPOTS_ENABLED,
|
|
41
43
|
DD_PROFILING_EXPERIMENTAL_ENDPOINT_COLLECTION_ENABLED
|
|
42
44
|
} = process.env
|
|
@@ -53,8 +55,6 @@ class Config {
|
|
|
53
55
|
Number(DD_PROFILING_UPLOAD_TIMEOUT), 60 * 1000)
|
|
54
56
|
const sourceMap = coalesce(options.sourceMap,
|
|
55
57
|
DD_PROFILING_SOURCE_MAP, true)
|
|
56
|
-
const endpointCollectionEnabled = coalesce(options.endpointCollection,
|
|
57
|
-
DD_PROFILING_EXPERIMENTAL_ENDPOINT_COLLECTION_ENABLED, false)
|
|
58
58
|
const pprofPrefix = coalesce(options.pprofPrefix,
|
|
59
59
|
DD_PROFILING_PPROF_PREFIX, '')
|
|
60
60
|
|
|
@@ -71,11 +71,25 @@ class Config {
|
|
|
71
71
|
tagger.parse({ env, host, service, version, functionname })
|
|
72
72
|
)
|
|
73
73
|
this.logger = ensureLogger(options.logger)
|
|
74
|
+
const logger = this.logger
|
|
75
|
+
function logExperimentalVarDeprecation (shortVarName) {
|
|
76
|
+
const deprecatedEnvVarName = `DD_PROFILING_EXPERIMENTAL_${shortVarName}`
|
|
77
|
+
const v = process.env[deprecatedEnvVarName]
|
|
78
|
+
// not null, undefined, or NaN -- same logic as koalas.hasValue
|
|
79
|
+
// eslint-disable-next-line no-self-compare
|
|
80
|
+
if (v != null && v === v) {
|
|
81
|
+
logger.warn(`${deprecatedEnvVarName} is deprecated. Use DD_PROFILING_${shortVarName} instead.`)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
74
84
|
this.flushInterval = flushInterval
|
|
75
85
|
this.uploadTimeout = uploadTimeout
|
|
76
86
|
this.sourceMap = sourceMap
|
|
77
87
|
this.debugSourceMaps = isTrue(coalesce(options.debugSourceMaps, DD_PROFILING_DEBUG_SOURCE_MAPS, false))
|
|
78
|
-
this.endpointCollectionEnabled =
|
|
88
|
+
this.endpointCollectionEnabled = isTrue(coalesce(options.endpointCollection,
|
|
89
|
+
DD_PROFILING_ENDPOINT_COLLECTION_ENABLED,
|
|
90
|
+
DD_PROFILING_EXPERIMENTAL_ENDPOINT_COLLECTION_ENABLED, false))
|
|
91
|
+
logExperimentalVarDeprecation('ENDPOINT_COLLECTION_ENABLED')
|
|
92
|
+
|
|
79
93
|
this.pprofPrefix = pprofPrefix
|
|
80
94
|
this.v8ProfilerBugWorkaroundEnabled = isTrue(coalesce(options.v8ProfilerBugWorkaround,
|
|
81
95
|
DD_PROFILING_V8_PROFILER_BUG_WORKAROUND, true))
|
|
@@ -113,8 +127,25 @@ class Config {
|
|
|
113
127
|
const profilers = options.profilers
|
|
114
128
|
? options.profilers
|
|
115
129
|
: getProfilers({ DD_PROFILING_HEAP_ENABLED, DD_PROFILING_WALLTIME_ENABLED, DD_PROFILING_PROFILERS })
|
|
116
|
-
|
|
117
|
-
|
|
130
|
+
|
|
131
|
+
function getCodeHotspotsOptionsOr (defvalue) {
|
|
132
|
+
return coalesce(options.codeHotspotsEnabled,
|
|
133
|
+
DD_PROFILING_CODEHOTSPOTS_ENABLED,
|
|
134
|
+
DD_PROFILING_EXPERIMENTAL_CODEHOTSPOTS_ENABLED, defvalue)
|
|
135
|
+
}
|
|
136
|
+
this.codeHotspotsEnabled = isTrue(getCodeHotspotsOptionsOr(false))
|
|
137
|
+
logExperimentalVarDeprecation('CODEHOTSPOTS_ENABLED')
|
|
138
|
+
if (this.endpointCollectionEnabled && !this.codeHotspotsEnabled) {
|
|
139
|
+
if (getCodeHotspotsOptionsOr(undefined) !== undefined) {
|
|
140
|
+
this.logger.warn(
|
|
141
|
+
'Endpoint collection is enabled, but Code Hotspots are disabled. ' +
|
|
142
|
+
'Enable Code Hotspots too for endpoint collection to work.')
|
|
143
|
+
this.endpointCollectionEnabled = false
|
|
144
|
+
} else {
|
|
145
|
+
this.logger.info('Code Hotspots are implicitly enabled by endpoint collection.')
|
|
146
|
+
this.codeHotspotsEnabled = true
|
|
147
|
+
}
|
|
148
|
+
}
|
|
118
149
|
|
|
119
150
|
this.profilers = ensureProfilers(profilers, this)
|
|
120
151
|
}
|
|
@@ -23,7 +23,7 @@ function getStartedSpans (context) {
|
|
|
23
23
|
return context._trace.started
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
function generateLabels ({ spanId, rootSpanId, webTags, endpoint }) {
|
|
26
|
+
function generateLabels ({ context: { spanId, rootSpanId, webTags, endpoint }, timestamp }) {
|
|
27
27
|
const labels = {}
|
|
28
28
|
if (spanId) {
|
|
29
29
|
labels['span id'] = spanId
|
|
@@ -37,6 +37,8 @@ function generateLabels ({ spanId, rootSpanId, webTags, endpoint }) {
|
|
|
37
37
|
// fallback to endpoint computed when sample was taken
|
|
38
38
|
labels['trace endpoint'] = endpoint
|
|
39
39
|
}
|
|
40
|
+
// Incoming timestamps are in microseconds, we emit nanos.
|
|
41
|
+
labels['end_timestamp_ns'] = timestamp * 1000n
|
|
40
42
|
|
|
41
43
|
return labels
|
|
42
44
|
}
|
|
@@ -100,6 +102,10 @@ class NativeWallProfiler {
|
|
|
100
102
|
return this._codeHotspotsEnabled
|
|
101
103
|
}
|
|
102
104
|
|
|
105
|
+
endpointCollectionEnabled () {
|
|
106
|
+
return this._endpointCollectionEnabled
|
|
107
|
+
}
|
|
108
|
+
|
|
103
109
|
start ({ mapper } = {}) {
|
|
104
110
|
if (this._started) return
|
|
105
111
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const maxExtraServices = 64
|
|
4
|
+
const extraServices = new Set()
|
|
5
|
+
|
|
6
|
+
function getExtraServices () {
|
|
7
|
+
return [...extraServices]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function registerExtraService (serviceName) {
|
|
11
|
+
if (serviceName && extraServices.size < maxExtraServices) {
|
|
12
|
+
extraServices.add(serviceName)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function clear () {
|
|
17
|
+
extraServices.clear()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = {
|
|
21
|
+
registerExtraService,
|
|
22
|
+
getExtraServices,
|
|
23
|
+
clear
|
|
24
|
+
}
|