dd-trace 5.100.0 → 5.102.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 +14 -0
- package/package.json +11 -9
- package/packages/datadog-instrumentations/src/aerospike.js +2 -2
- package/packages/datadog-instrumentations/src/ai.js +8 -8
- package/packages/datadog-instrumentations/src/amqplib.js +6 -7
- package/packages/datadog-instrumentations/src/anthropic.js +10 -10
- package/packages/datadog-instrumentations/src/apollo-server-core.js +3 -3
- package/packages/datadog-instrumentations/src/apollo-server.js +5 -5
- package/packages/datadog-instrumentations/src/avsc.js +6 -6
- package/packages/datadog-instrumentations/src/aws-sdk.js +151 -67
- package/packages/datadog-instrumentations/src/azure-durable-functions.js +8 -8
- package/packages/datadog-instrumentations/src/bluebird.js +2 -2
- package/packages/datadog-instrumentations/src/body-parser.js +2 -2
- package/packages/datadog-instrumentations/src/cassandra-driver.js +7 -7
- package/packages/datadog-instrumentations/src/child_process.js +12 -12
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +9 -9
- package/packages/datadog-instrumentations/src/connect.js +7 -7
- package/packages/datadog-instrumentations/src/cookie-parser.js +4 -4
- package/packages/datadog-instrumentations/src/cookie.js +2 -2
- package/packages/datadog-instrumentations/src/couchbase.js +16 -30
- package/packages/datadog-instrumentations/src/crypto.js +4 -4
- package/packages/datadog-instrumentations/src/cucumber.js +77 -16
- package/packages/datadog-instrumentations/src/cypress.js +5 -3
- package/packages/datadog-instrumentations/src/dns.js +0 -3
- package/packages/datadog-instrumentations/src/elasticsearch.js +8 -11
- package/packages/datadog-instrumentations/src/express-mongo-sanitize.js +6 -6
- package/packages/datadog-instrumentations/src/express-session.js +4 -4
- package/packages/datadog-instrumentations/src/express.js +10 -11
- package/packages/datadog-instrumentations/src/fastify.js +2 -2
- package/packages/datadog-instrumentations/src/fs.js +14 -14
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +5 -7
- package/packages/datadog-instrumentations/src/google-genai.js +4 -4
- package/packages/datadog-instrumentations/src/grpc/server.js +2 -2
- package/packages/datadog-instrumentations/src/hapi.js +2 -2
- package/packages/datadog-instrumentations/src/helpers/callback-instrumentor.js +8 -8
- package/packages/datadog-instrumentations/src/helpers/promise.js +2 -2
- package/packages/datadog-instrumentations/src/hono.js +2 -2
- package/packages/datadog-instrumentations/src/http/client.js +26 -9
- package/packages/datadog-instrumentations/src/http/server.js +9 -9
- package/packages/datadog-instrumentations/src/jest.js +93 -63
- package/packages/datadog-instrumentations/src/kafkajs.js +9 -9
- package/packages/datadog-instrumentations/src/knex.js +17 -17
- package/packages/datadog-instrumentations/src/koa.js +12 -12
- package/packages/datadog-instrumentations/src/ldapjs.js +5 -5
- package/packages/datadog-instrumentations/src/light-my-request.js +2 -2
- package/packages/datadog-instrumentations/src/limitd-client.js +4 -4
- package/packages/datadog-instrumentations/src/lodash.js +4 -4
- package/packages/datadog-instrumentations/src/mariadb.js +13 -13
- package/packages/datadog-instrumentations/src/memcached.js +2 -2
- package/packages/datadog-instrumentations/src/microgateway-core.js +2 -2
- package/packages/datadog-instrumentations/src/mocha/common.js +7 -4
- package/packages/datadog-instrumentations/src/mocha/main.js +37 -14
- package/packages/datadog-instrumentations/src/mocha/utils.js +133 -16
- package/packages/datadog-instrumentations/src/mocha/worker.js +12 -7
- package/packages/datadog-instrumentations/src/mongodb-core.js +9 -22
- package/packages/datadog-instrumentations/src/mongodb.js +5 -5
- package/packages/datadog-instrumentations/src/mongoose.js +21 -21
- package/packages/datadog-instrumentations/src/mquery.js +5 -5
- package/packages/datadog-instrumentations/src/multer.js +4 -4
- package/packages/datadog-instrumentations/src/mysql.js +16 -16
- package/packages/datadog-instrumentations/src/mysql2.js +4 -4
- package/packages/datadog-instrumentations/src/net.js +14 -8
- package/packages/datadog-instrumentations/src/nyc.js +5 -5
- package/packages/datadog-instrumentations/src/openai.js +19 -19
- package/packages/datadog-instrumentations/src/oracledb.js +6 -6
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -6
- package/packages/datadog-instrumentations/src/passport-utils.js +5 -5
- package/packages/datadog-instrumentations/src/pg.js +15 -15
- package/packages/datadog-instrumentations/src/pino.js +6 -10
- package/packages/datadog-instrumentations/src/playwright.js +20 -15
- package/packages/datadog-instrumentations/src/protobufjs.js +16 -16
- package/packages/datadog-instrumentations/src/redis.js +1 -2
- package/packages/datadog-instrumentations/src/restify.js +2 -2
- package/packages/datadog-instrumentations/src/router.js +12 -12
- package/packages/datadog-instrumentations/src/stripe.js +12 -12
- package/packages/datadog-instrumentations/src/vitest.js +107 -26
- package/packages/datadog-instrumentations/src/winston.js +4 -4
- package/packages/datadog-instrumentations/src/ws.js +7 -7
- package/packages/datadog-plugin-aws-sdk/src/base.js +52 -4
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +19 -12
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +45 -35
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +33 -22
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +12 -13
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +73 -54
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +19 -17
- package/packages/datadog-plugin-aws-sdk/src/util.js +22 -0
- package/packages/datadog-plugin-bullmq/src/consumer.js +2 -2
- package/packages/datadog-plugin-bullmq/src/producer.js +14 -20
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +6 -6
- package/packages/datadog-plugin-cucumber/src/index.js +4 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +18 -4
- package/packages/datadog-plugin-cypress/src/plugin.js +5 -14
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +1 -5
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +3 -1
- package/packages/datadog-plugin-http/src/client.js +1 -5
- package/packages/datadog-plugin-jest/src/util.js +1 -2
- package/packages/datadog-plugin-kafkajs/src/consumer.js +2 -9
- package/packages/datadog-plugin-kafkajs/src/producer.js +2 -8
- package/packages/datadog-plugin-mocha/src/index.js +4 -0
- package/packages/datadog-plugin-mongodb-core/src/index.js +2 -1
- package/packages/datadog-plugin-openai/src/tracing.js +12 -23
- package/packages/datadog-plugin-playwright/src/index.js +1 -1
- package/packages/datadog-plugin-vitest/src/index.js +8 -1
- package/packages/datadog-shimmer/src/shimmer.js +7 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +81 -81
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugins/kafka.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +2 -2
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +2 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +1 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +83 -48
- package/packages/dd-trace/src/appsec/index.js +21 -24
- package/packages/dd-trace/src/appsec/reporter.js +7 -2
- package/packages/dd-trace/src/appsec/rule_manager.js +4 -2
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +31 -16
- package/packages/dd-trace/src/ci-visibility/lage.js +2 -1
- package/packages/dd-trace/src/ci-visibility/requests/request.js +11 -33
- package/packages/dd-trace/src/config/config-types.d.ts +0 -2
- package/packages/dd-trace/src/config/git_properties.js +2 -2
- package/packages/dd-trace/src/config/index.js +1 -55
- package/packages/dd-trace/src/datastreams/checkpointer.js +4 -10
- package/packages/dd-trace/src/datastreams/encoding.js +39 -28
- package/packages/dd-trace/src/datastreams/index.js +2 -1
- package/packages/dd-trace/src/datastreams/pathway.js +29 -26
- package/packages/dd-trace/src/datastreams/processor.js +18 -17
- package/packages/dd-trace/src/datastreams/size.js +6 -2
- package/packages/dd-trace/src/debugger/config.js +5 -2
- package/packages/dd-trace/src/debugger/devtools_client/index.js +2 -5
- package/packages/dd-trace/src/debugger/devtools_client/send.js +2 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +1 -0
- package/packages/dd-trace/src/dogstatsd.js +10 -7
- package/packages/dd-trace/src/encode/0.4.js +759 -234
- package/packages/dd-trace/src/encode/0.5.js +15 -9
- package/packages/dd-trace/src/encode/agentless-json.js +2 -2
- package/packages/dd-trace/src/encode/tags-processors.js +2 -27
- package/packages/dd-trace/src/exporters/common/request.js +22 -11
- package/packages/dd-trace/src/exporters/common/retry.js +104 -0
- package/packages/dd-trace/src/git_metadata.js +66 -0
- package/packages/dd-trace/src/git_metadata_tagger.js +13 -5
- package/packages/dd-trace/src/id.js +15 -26
- package/packages/dd-trace/src/llmobs/constants/tags.js +2 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +1 -2
- package/packages/dd-trace/src/llmobs/plugins/anthropic/index.js +27 -16
- package/packages/dd-trace/src/llmobs/plugins/anthropic/util.js +3 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +33 -13
- package/packages/dd-trace/src/llmobs/plugins/openai/index.js +20 -50
- package/packages/dd-trace/src/llmobs/sdk.js +29 -27
- package/packages/dd-trace/src/llmobs/span_processor.js +52 -6
- package/packages/dd-trace/src/llmobs/tagger.js +42 -0
- package/packages/dd-trace/src/llmobs/telemetry.js +29 -0
- package/packages/dd-trace/src/llmobs/util.js +81 -5
- package/packages/dd-trace/src/msgpack/chunk.js +6 -3
- package/packages/dd-trace/src/openfeature/noop.js +40 -36
- package/packages/dd-trace/src/openfeature/writers/exposures.js +33 -52
- package/packages/dd-trace/src/opentelemetry/active-span-proxy.js +42 -0
- package/packages/dd-trace/src/opentelemetry/bridge-span-base.js +106 -0
- package/packages/dd-trace/src/opentelemetry/context_manager.js +11 -2
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +1 -2
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +188 -50
- package/packages/dd-trace/src/opentelemetry/span.js +42 -80
- package/packages/dd-trace/src/opentelemetry/tracer.js +0 -22
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +65 -27
- package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +2 -11
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +58 -22
- package/packages/dd-trace/src/opentracing/span.js +56 -48
- package/packages/dd-trace/src/opentracing/span_context.js +1 -0
- package/packages/dd-trace/src/plugins/util/ci.js +1 -1
- package/packages/dd-trace/src/plugins/util/git-cache.js +3 -5
- package/packages/dd-trace/src/plugins/util/test.js +19 -7
- package/packages/dd-trace/src/plugins/util/url.js +1 -3
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +1 -1
- package/packages/dd-trace/src/plugins/util/web.js +5 -7
- package/packages/dd-trace/src/priority_sampler.js +6 -4
- package/packages/dd-trace/src/profiling/config.js +5 -4
- package/packages/dd-trace/src/profiling/profilers/events.js +3 -23
- package/packages/dd-trace/src/profiling/profilers/wall.js +4 -5
- package/packages/dd-trace/src/remote_config/index.js +5 -3
- package/packages/dd-trace/src/runtime_metrics/index.js +2 -2
- package/packages/dd-trace/src/scope.js +3 -10
- package/packages/dd-trace/src/serverless.js +1 -4
- package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +7 -1
- package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +4 -0
- package/packages/dd-trace/src/span_format.js +52 -5
- package/packages/dd-trace/src/span_processor.js +0 -4
- package/packages/dd-trace/src/spanleak.js +0 -1
- package/packages/dd-trace/src/tracer.js +7 -7
- package/packages/dd-trace/src/util.js +17 -0
|
@@ -36,7 +36,7 @@ function removeEmptyValues (tagsAndValues) {
|
|
|
36
36
|
// https://github.com/jonschlinkert/is-git-url/blob/396965ffabf2f46656c8af4c47bef1d69f09292e/index.js#L9C15-L9C87
|
|
37
37
|
// The `.git` suffix is optional in this version
|
|
38
38
|
function validateGitRepositoryUrl (repoUrl) {
|
|
39
|
-
return /(?:git|ssh|https?|git@[-\w.]+):(\/\/)?(.*?)(\/?|#[-\
|
|
39
|
+
return /(?:git|ssh|https?|git@[-\w.]+):(\/\/)?(.*?)(\/?|#[-\w.]+?)$/.test(repoUrl)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
function validateGitCommitSha (gitCommitSha) {
|
|
@@ -217,9 +217,7 @@ const web = {
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
return span
|
|
220
|
+
return startSpanHelper(tracer, name, { childOf }, traceCtx, config)
|
|
223
221
|
},
|
|
224
222
|
|
|
225
223
|
// Validate a request's status code and then add error tags if necessary
|
|
@@ -309,10 +307,10 @@ const web = {
|
|
|
309
307
|
return contexts.get(req)
|
|
310
308
|
},
|
|
311
309
|
wrapRes (context, req, res, end) {
|
|
312
|
-
return function () {
|
|
310
|
+
return function (...args) {
|
|
313
311
|
web.finishAll(context)
|
|
314
312
|
|
|
315
|
-
return end.apply(res,
|
|
313
|
+
return end.apply(res, args)
|
|
316
314
|
}
|
|
317
315
|
},
|
|
318
316
|
wrapEnd (context) {
|
|
@@ -330,8 +328,8 @@ const web = {
|
|
|
330
328
|
return ends.get(this)
|
|
331
329
|
},
|
|
332
330
|
set (value) {
|
|
333
|
-
ends.set(this, function () {
|
|
334
|
-
return storage('legacy').run(context.store, value, ...
|
|
331
|
+
ends.set(this, function (...args) {
|
|
332
|
+
return storage('legacy').run(context.store, value, ...args)
|
|
335
333
|
})
|
|
336
334
|
},
|
|
337
335
|
})
|
|
@@ -148,9 +148,8 @@ class PrioritySampler {
|
|
|
148
148
|
update (rates) {
|
|
149
149
|
const samplers = {}
|
|
150
150
|
|
|
151
|
-
for (const key
|
|
152
|
-
|
|
153
|
-
samplers[key] = new Sampler(rate)
|
|
151
|
+
for (const key of Object.keys(rates)) {
|
|
152
|
+
samplers[key] = new Sampler(rates[key])
|
|
154
153
|
}
|
|
155
154
|
|
|
156
155
|
samplers[DEFAULT_KEY] = samplers[DEFAULT_KEY] || defaultSampler
|
|
@@ -334,7 +333,10 @@ class PrioritySampler {
|
|
|
334
333
|
if (!trace.tags[DECISION_MAKER_KEY]) {
|
|
335
334
|
trace.tags[DECISION_MAKER_KEY] = `-${mechanism}`
|
|
336
335
|
}
|
|
337
|
-
} else {
|
|
336
|
+
} else if (DECISION_MAKER_KEY in trace.tags) {
|
|
337
|
+
// Guard the `delete` so the common drop path doesn't pay the V8
|
|
338
|
+
// dictionary-mode transition unless a prior keep decision actually
|
|
339
|
+
// set the tag.
|
|
338
340
|
delete trace.tags[DECISION_MAKER_KEY]
|
|
339
341
|
}
|
|
340
342
|
}
|
|
@@ -4,6 +4,7 @@ const path = require('path')
|
|
|
4
4
|
const { pathToFileURL } = require('url')
|
|
5
5
|
|
|
6
6
|
const satisfies = require('../../../../vendor/dist/semifies')
|
|
7
|
+
const getGitMetadata = require('../git_metadata')
|
|
7
8
|
const { GIT_REPOSITORY_URL, GIT_COMMIT_SHA } = require('../plugins/util/tags')
|
|
8
9
|
const { getIsAzureFunction } = require('../serverless')
|
|
9
10
|
const { getAzureTagsFromMetadata, getAzureAppMetadata, getAzureFunctionMetadata } = require('../azure_metadata')
|
|
@@ -38,10 +39,10 @@ class Config {
|
|
|
38
39
|
...getAzureTagsFromMetadata(getIsAzureFunction() ? getAzureFunctionMetadata() : getAzureAppMetadata()),
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
if (
|
|
43
|
-
this.tags[GIT_REPOSITORY_URL] =
|
|
44
|
-
this.tags[GIT_COMMIT_SHA] =
|
|
42
|
+
const { commitSHA, repositoryUrl } = getGitMetadata(options)
|
|
43
|
+
if (repositoryUrl && commitSHA) {
|
|
44
|
+
this.tags[GIT_REPOSITORY_URL] = repositoryUrl
|
|
45
|
+
this.tags[GIT_COMMIT_SHA] = commitSHA
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
// Normalize from seconds to milliseconds. Default must be longer than a minute.
|
|
@@ -174,7 +174,7 @@ class NetDecorator {
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
class
|
|
177
|
+
class KeyValueDecorator {
|
|
178
178
|
constructor (stringTable) {
|
|
179
179
|
this.stringTable = stringTable
|
|
180
180
|
}
|
|
@@ -205,31 +205,11 @@ class ZlibDecorator {
|
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
class CryptoDecorator {
|
|
209
|
-
constructor (stringTable) {
|
|
210
|
-
this.stringTable = stringTable
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
decorateSample (sampleInput, item) {
|
|
214
|
-
const labels = sampleInput.label
|
|
215
|
-
const stringTable = this.stringTable
|
|
216
|
-
for (const [key, value] of Object.entries(item.detail)) {
|
|
217
|
-
switch (typeof value) {
|
|
218
|
-
case 'string':
|
|
219
|
-
labels.push(labelFromStrStr(stringTable, key, value))
|
|
220
|
-
break
|
|
221
|
-
case 'number':
|
|
222
|
-
labels.push(new Label({ key: stringTable.dedup(key), num: value }))
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
208
|
// Keys correspond to PerformanceEntry.entryType, values are constructor
|
|
229
209
|
// functions for type-specific decorators.
|
|
230
210
|
const decoratorTypes = {
|
|
231
|
-
crypto:
|
|
232
|
-
fs:
|
|
211
|
+
crypto: KeyValueDecorator,
|
|
212
|
+
fs: KeyValueDecorator,
|
|
233
213
|
dns: DNSDecorator,
|
|
234
214
|
gc: GCDecorator,
|
|
235
215
|
net: NetDecorator,
|
|
@@ -317,11 +317,10 @@ class NativeWallProfiler {
|
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
#setNewContext () {
|
|
320
|
-
this
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
)
|
|
320
|
+
this._currentContext = {
|
|
321
|
+
ref: {},
|
|
322
|
+
}
|
|
323
|
+
this.#pprof.time.setContext(this._currentContext)
|
|
325
324
|
}
|
|
326
325
|
|
|
327
326
|
#spanFinished (span) {
|
|
@@ -5,6 +5,7 @@ const tracerVersion = require('../../../../package.json').version
|
|
|
5
5
|
const request = require('../exporters/common/request')
|
|
6
6
|
const log = require('../log')
|
|
7
7
|
const { getExtraServices } = require('../service-naming/extra-services')
|
|
8
|
+
const getGitMetadata = require('../git_metadata')
|
|
8
9
|
const { GIT_REPOSITORY_URL, GIT_COMMIT_SHA } = require('../plugins/util/tags')
|
|
9
10
|
const tagger = require('../tagger')
|
|
10
11
|
const { getAgentUrl } = require('../agent/url')
|
|
@@ -37,11 +38,12 @@ class RemoteConfig {
|
|
|
37
38
|
'_dd.rc.client_id': clientId,
|
|
38
39
|
})
|
|
39
40
|
|
|
40
|
-
const
|
|
41
|
+
const { commitSHA, repositoryUrl } = getGitMetadata(config)
|
|
42
|
+
const tags = repositoryUrl
|
|
41
43
|
? {
|
|
42
44
|
...config.tags,
|
|
43
|
-
[GIT_REPOSITORY_URL]:
|
|
44
|
-
[GIT_COMMIT_SHA]:
|
|
45
|
+
[GIT_REPOSITORY_URL]: repositoryUrl,
|
|
46
|
+
[GIT_COMMIT_SHA]: commitSHA,
|
|
45
47
|
}
|
|
46
48
|
: config.tags
|
|
47
49
|
|
|
@@ -3,14 +3,11 @@
|
|
|
3
3
|
const { storage } = require('../../datadog-core')
|
|
4
4
|
|
|
5
5
|
// TODO: refactor bind to use shimmer once the new internal tracer lands
|
|
6
|
-
|
|
7
|
-
const originals = new WeakMap()
|
|
8
|
-
|
|
9
6
|
class Scope {
|
|
10
7
|
active () {
|
|
11
8
|
const store = storage('legacy').getStore()
|
|
12
9
|
|
|
13
|
-
return
|
|
10
|
+
return store?.span ?? null
|
|
14
11
|
}
|
|
15
12
|
|
|
16
13
|
activate (span, callback) {
|
|
@@ -40,15 +37,11 @@ class Scope {
|
|
|
40
37
|
const scope = this
|
|
41
38
|
const spanOrActive = this._spanOrActive(span)
|
|
42
39
|
|
|
43
|
-
|
|
40
|
+
return function (...args) {
|
|
44
41
|
return scope.activate(spanOrActive, () => {
|
|
45
|
-
return fn.apply(this,
|
|
42
|
+
return fn.apply(this, args)
|
|
46
43
|
})
|
|
47
44
|
}
|
|
48
|
-
|
|
49
|
-
originals.set(bound, fn)
|
|
50
|
-
|
|
51
|
-
return bound
|
|
52
45
|
}
|
|
53
46
|
|
|
54
47
|
_spanOrActive (span) {
|
|
@@ -24,11 +24,8 @@ function enableGCPPubSubPushSubscription () {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
function getIsAzureFunction () {
|
|
27
|
-
|
|
28
|
-
getEnvironmentVariable('FUNCTIONS_EXTENSION_VERSION') !== undefined &&
|
|
27
|
+
return getEnvironmentVariable('FUNCTIONS_EXTENSION_VERSION') !== undefined &&
|
|
29
28
|
getEnvironmentVariable('FUNCTIONS_WORKER_RUNTIME') !== undefined
|
|
30
|
-
|
|
31
|
-
return isAzureFunction
|
|
32
29
|
}
|
|
33
30
|
|
|
34
31
|
function getIsFlexConsumptionAzureFunction () {
|
|
@@ -81,7 +81,13 @@ const messaging = {
|
|
|
81
81
|
},
|
|
82
82
|
'google-cloud-pubsub': {
|
|
83
83
|
opName: () => 'pubsub.receive',
|
|
84
|
-
serviceName:
|
|
84
|
+
serviceName: ({ tracerService }) => `${tracerService}-pubsub`,
|
|
85
|
+
serviceSource: integrationSource('google-cloud-pubsub'),
|
|
86
|
+
},
|
|
87
|
+
'google-cloud-pubsub-push-subscription': {
|
|
88
|
+
opName: () => 'pubsub.receive',
|
|
89
|
+
serviceName: ({ tracerService }) => `${tracerService}-pubsub`,
|
|
90
|
+
serviceSource: integrationSource('google-cloud-pubsub'),
|
|
85
91
|
},
|
|
86
92
|
kafkajs: {
|
|
87
93
|
opName: () => 'kafka.consume',
|
|
@@ -57,6 +57,10 @@ const messaging = {
|
|
|
57
57
|
opName: () => 'gcp.pubsub.process',
|
|
58
58
|
serviceName: identityService,
|
|
59
59
|
},
|
|
60
|
+
'google-cloud-pubsub-push-subscription': {
|
|
61
|
+
opName: () => 'gcp.pubsub.process',
|
|
62
|
+
serviceName: identityService,
|
|
63
|
+
},
|
|
60
64
|
kafkajs: {
|
|
61
65
|
opName: () => 'kafka.process',
|
|
62
66
|
serviceName: identityService,
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
const tags = require('../../../ext/tags')
|
|
4
4
|
const constants = require('./constants')
|
|
5
|
+
const {
|
|
6
|
+
MAX_META_KEY_LENGTH,
|
|
7
|
+
MAX_META_VALUE_LENGTH,
|
|
8
|
+
MAX_METRIC_KEY_LENGTH,
|
|
9
|
+
} = require('./encode/tags-processors')
|
|
5
10
|
const id = require('./id')
|
|
6
11
|
const { isError } = require('./util')
|
|
7
12
|
const { registerExtraService } = require('./service-naming/extra-services')
|
|
@@ -33,6 +38,23 @@ const map = {
|
|
|
33
38
|
'resource.name': 'resource',
|
|
34
39
|
}
|
|
35
40
|
|
|
41
|
+
/**
|
|
42
|
+
* @typedef {object} FormattedSpan
|
|
43
|
+
* @property {import('./id').Identifier} trace_id
|
|
44
|
+
* @property {import('./id').Identifier} span_id
|
|
45
|
+
* @property {import('./id').Identifier} parent_id
|
|
46
|
+
* @property {string} name
|
|
47
|
+
* @property {string} resource
|
|
48
|
+
* @property {number} error
|
|
49
|
+
* @property {Record<string, string>} meta
|
|
50
|
+
* @property {Record<string, number>} metrics
|
|
51
|
+
* @property {Record<string, unknown> | undefined} meta_struct
|
|
52
|
+
* @property {number} start
|
|
53
|
+
* @property {number} duration
|
|
54
|
+
* @property {Array} links
|
|
55
|
+
* @property {Array<{ name: string, time_unix_nano: number, attributes?: Record<string, string> }>} [span_events]
|
|
56
|
+
*/
|
|
57
|
+
|
|
36
58
|
function format (span, isFirstSpanInChunk = false, tagForFirstSpanInChunk = false) {
|
|
37
59
|
const formatted = formatSpan(span)
|
|
38
60
|
|
|
@@ -71,12 +93,15 @@ function setSingleSpanIngestionTags (span, options) {
|
|
|
71
93
|
addTag({}, span.metrics, SPAN_SAMPLING_MAX_PER_SECOND, options.maxPerSecond)
|
|
72
94
|
}
|
|
73
95
|
|
|
96
|
+
/**
|
|
97
|
+
* @param {FormattedSpan} formattedSpan
|
|
98
|
+
* @param {import('./opentracing/span')} span
|
|
99
|
+
*/
|
|
74
100
|
function extractSpanLinks (formattedSpan, span) {
|
|
75
101
|
if (!span._links?.length) {
|
|
76
102
|
return
|
|
77
103
|
}
|
|
78
|
-
const links = span._links.map(
|
|
79
|
-
const { context, attributes } = link
|
|
104
|
+
const links = span._links.map(({ context, attributes }) => {
|
|
80
105
|
const formattedLink = {
|
|
81
106
|
trace_id: context.toTraceId(true),
|
|
82
107
|
span_id: context.toSpanId(true),
|
|
@@ -90,21 +115,28 @@ function extractSpanLinks (formattedSpan, span) {
|
|
|
90
115
|
|
|
91
116
|
return formattedLink
|
|
92
117
|
})
|
|
93
|
-
|
|
118
|
+
let serialized = JSON.stringify(links)
|
|
119
|
+
if (serialized.length > MAX_META_VALUE_LENGTH) {
|
|
120
|
+
serialized = `${serialized.slice(0, MAX_META_VALUE_LENGTH)}...`
|
|
121
|
+
}
|
|
122
|
+
formattedSpan.meta['_dd.span_links'] = serialized
|
|
94
123
|
}
|
|
95
124
|
|
|
125
|
+
/**
|
|
126
|
+
* @param {FormattedSpan} formattedSpan
|
|
127
|
+
* @param {import('./opentracing/span')} span
|
|
128
|
+
*/
|
|
96
129
|
function extractSpanEvents (formattedSpan, span) {
|
|
97
130
|
if (!span._events?.length) {
|
|
98
131
|
return
|
|
99
132
|
}
|
|
100
|
-
|
|
133
|
+
formattedSpan.span_events = span._events.map(event => {
|
|
101
134
|
return {
|
|
102
135
|
name: event.name,
|
|
103
136
|
time_unix_nano: Math.round(event.startTime * 1e6),
|
|
104
137
|
attributes: event.attributes && Object.keys(event.attributes).length > 0 ? event.attributes : undefined,
|
|
105
138
|
}
|
|
106
139
|
})
|
|
107
|
-
formattedSpan.span_events = events
|
|
108
140
|
}
|
|
109
141
|
|
|
110
142
|
function extractTags (formattedSpan, span) {
|
|
@@ -225,13 +257,25 @@ function extractError (formattedSpan, error) {
|
|
|
225
257
|
function addTag (meta, metrics, key, value, nested) {
|
|
226
258
|
switch (typeof value) {
|
|
227
259
|
case 'string':
|
|
260
|
+
if (key.length > MAX_META_KEY_LENGTH) {
|
|
261
|
+
key = `${key.slice(0, MAX_META_KEY_LENGTH)}...`
|
|
262
|
+
}
|
|
263
|
+
if (value.length > MAX_META_VALUE_LENGTH) {
|
|
264
|
+
value = `${value.slice(0, MAX_META_VALUE_LENGTH)}...`
|
|
265
|
+
}
|
|
228
266
|
meta[key] = value
|
|
229
267
|
break
|
|
230
268
|
case 'number':
|
|
231
269
|
if (Number.isNaN(value)) break
|
|
270
|
+
if (key.length > MAX_METRIC_KEY_LENGTH) {
|
|
271
|
+
key = `${key.slice(0, MAX_METRIC_KEY_LENGTH)}...`
|
|
272
|
+
}
|
|
232
273
|
metrics[key] = value
|
|
233
274
|
break
|
|
234
275
|
case 'boolean':
|
|
276
|
+
if (key.length > MAX_METRIC_KEY_LENGTH) {
|
|
277
|
+
key = `${key.slice(0, MAX_METRIC_KEY_LENGTH)}...`
|
|
278
|
+
}
|
|
235
279
|
metrics[key] = value ? 1 : 0
|
|
236
280
|
break
|
|
237
281
|
default:
|
|
@@ -240,6 +284,9 @@ function addTag (meta, metrics, key, value, nested) {
|
|
|
240
284
|
// Special case for Node.js Buffer and URL
|
|
241
285
|
// TODO(BridgeAR)[31.03.2025]: Figure out if all typed arrays should be treated as buffers.
|
|
242
286
|
if (isNodeBuffer(value) || isUrl(value)) {
|
|
287
|
+
if (key.length > MAX_METRIC_KEY_LENGTH) {
|
|
288
|
+
key = `${key.slice(0, MAX_METRIC_KEY_LENGTH)}...`
|
|
289
|
+
}
|
|
243
290
|
metrics[key] = value.toString()
|
|
244
291
|
} else if (!Array.isArray(value) && !nested) {
|
|
245
292
|
for (const [prop, val] of Object.entries(value)) {
|
|
@@ -100,27 +100,27 @@ class DatadogTracer extends Tracer {
|
|
|
100
100
|
wrap (name, options, fn) {
|
|
101
101
|
const tracer = this
|
|
102
102
|
|
|
103
|
-
return function () {
|
|
103
|
+
return function (...args) {
|
|
104
104
|
let optionsObj = options
|
|
105
105
|
if (typeof optionsObj === 'function' && typeof fn === 'function') {
|
|
106
|
-
optionsObj = optionsObj.apply(this,
|
|
106
|
+
optionsObj = optionsObj.apply(this, args)
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
const lastArgId =
|
|
110
|
-
const cb =
|
|
109
|
+
const lastArgId = args.length - 1
|
|
110
|
+
const cb = args[lastArgId]
|
|
111
111
|
|
|
112
112
|
if (typeof cb === 'function') {
|
|
113
113
|
const scopeBoundCb = tracer.scope().bind(cb)
|
|
114
114
|
return tracer.trace(name, optionsObj, (span, done) => {
|
|
115
|
-
|
|
115
|
+
args[lastArgId] = function (err) {
|
|
116
116
|
done(err)
|
|
117
117
|
return scopeBoundCb.apply(this, arguments)
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
return fn.apply(this,
|
|
120
|
+
return fn.apply(this, args)
|
|
121
121
|
})
|
|
122
122
|
}
|
|
123
|
-
return tracer.trace(name, optionsObj, () => fn.apply(this,
|
|
123
|
+
return tracer.trace(name, optionsObj, () => fn.apply(this, args))
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
|
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
const path = require('path')
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* `for-in` with an early return is the only allocation-free shape for
|
|
7
|
+
* "does this object have any own enumerable properties". Microbenchmarks
|
|
8
|
+
* pin it as 1.3-1.4x faster than `Object.keys(obj).length === 0` across
|
|
9
|
+
* small / medium / large objects -- enough that hot paths in the AWS SDK
|
|
10
|
+
* and AppSec reporter promote it.
|
|
11
|
+
*
|
|
12
|
+
* @param {object | undefined} obj
|
|
13
|
+
* @returns {boolean}
|
|
14
|
+
*/
|
|
15
|
+
function isEmpty (obj) {
|
|
16
|
+
// eslint-disable-next-line no-unreachable-loop
|
|
17
|
+
for (const _ in obj) return false
|
|
18
|
+
return true
|
|
19
|
+
}
|
|
20
|
+
|
|
5
21
|
function isTrue (str) {
|
|
6
22
|
str = String(str).toLowerCase()
|
|
7
23
|
return str === 'true' || str === '1'
|
|
@@ -76,6 +92,7 @@ function normalizePluginEnvName (envPluginName, makeLowercase = false) {
|
|
|
76
92
|
}
|
|
77
93
|
|
|
78
94
|
module.exports = {
|
|
95
|
+
isEmpty,
|
|
79
96
|
isTrue,
|
|
80
97
|
isFalse,
|
|
81
98
|
isError,
|