dd-trace 5.24.0 → 5.26.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/LICENSE-3rdparty.csv +3 -0
- package/index.d.ts +345 -8
- package/init.js +60 -47
- package/package.json +16 -7
- package/packages/datadog-code-origin/index.js +4 -4
- package/packages/datadog-core/index.js +1 -3
- package/packages/datadog-core/src/storage.js +21 -0
- package/packages/datadog-core/src/utils/src/parse-tags.js +33 -0
- package/packages/datadog-esbuild/index.js +4 -2
- package/packages/datadog-instrumentations/src/amqplib.js +65 -5
- package/packages/datadog-instrumentations/src/child_process.js +135 -27
- package/packages/datadog-instrumentations/src/express.js +1 -1
- package/packages/datadog-instrumentations/src/handlebars.js +40 -0
- package/packages/datadog-instrumentations/src/helpers/hooks.js +5 -0
- package/packages/datadog-instrumentations/src/helpers/register.js +9 -0
- package/packages/datadog-instrumentations/src/jest.js +6 -2
- package/packages/datadog-instrumentations/src/kafkajs.js +123 -63
- package/packages/datadog-instrumentations/src/mocha/utils.js +2 -2
- package/packages/datadog-instrumentations/src/multer.js +37 -0
- package/packages/datadog-instrumentations/src/openai.js +2 -2
- package/packages/datadog-instrumentations/src/pug.js +23 -0
- package/packages/datadog-instrumentations/src/router.js +2 -3
- package/packages/datadog-instrumentations/src/url.js +84 -0
- package/packages/datadog-instrumentations/src/utils/src/extract-package-and-module-path.js +7 -4
- package/packages/datadog-plugin-amqplib/src/consumer.js +6 -5
- package/packages/datadog-plugin-aws-sdk/src/base.js +5 -0
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +1 -0
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +10 -7
- package/packages/datadog-plugin-aws-sdk/src/services/s3.js +35 -0
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +11 -9
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +59 -45
- package/packages/datadog-plugin-cypress/src/support.js +1 -0
- package/packages/datadog-plugin-fastify/src/code_origin.js +2 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +10 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +8 -0
- package/packages/datadog-plugin-grpc/src/client.js +3 -0
- package/packages/datadog-plugin-grpc/src/server.js +5 -1
- package/packages/datadog-plugin-http/src/client.js +42 -1
- package/packages/datadog-plugin-http2/src/client.js +26 -1
- package/packages/datadog-plugin-jest/src/index.js +2 -1
- package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +6 -3
- package/packages/datadog-plugin-kafkajs/src/consumer.js +10 -5
- package/packages/datadog-plugin-kafkajs/src/producer.js +10 -4
- package/packages/datadog-plugin-mocha/src/index.js +5 -2
- package/packages/datadog-plugin-moleculer/src/server.js +2 -2
- package/packages/datadog-plugin-openai/src/index.js +9 -1015
- package/packages/datadog-plugin-openai/src/tracing.js +1023 -0
- package/packages/datadog-plugin-rhea/src/consumer.js +2 -1
- package/packages/datadog-plugin-vitest/src/index.js +2 -1
- package/packages/dd-trace/src/appsec/addresses.js +2 -0
- package/packages/dd-trace/src/appsec/api_security_sampler.js +50 -27
- package/packages/dd-trace/src/appsec/channels.js +3 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +1 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/header-injection-analyzer.js +33 -16
- package/packages/dd-trace/src/appsec/iast/analyzers/template-injection-analyzer.js +18 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +55 -7
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +3 -2
- package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +1 -0
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +4 -2
- package/packages/dd-trace/src/appsec/index.js +9 -6
- package/packages/dd-trace/src/appsec/rasp/command_injection.js +49 -0
- package/packages/dd-trace/src/appsec/rasp/index.js +3 -0
- package/packages/dd-trace/src/appsec/rasp/ssrf.js +4 -3
- package/packages/dd-trace/src/appsec/rasp/utils.js +3 -2
- package/packages/dd-trace/src/appsec/recommended.json +354 -158
- package/packages/dd-trace/src/appsec/remote_config/capabilities.js +2 -1
- package/packages/dd-trace/src/appsec/remote_config/index.js +2 -7
- package/packages/dd-trace/src/appsec/reporter.js +6 -4
- package/packages/dd-trace/src/appsec/sdk/track_event.js +5 -3
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +4 -0
- package/packages/dd-trace/src/azure_metadata.js +120 -0
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +97 -0
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +90 -0
- package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +19 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +53 -0
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +8 -1
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +43 -0
- package/packages/dd-trace/src/config.js +88 -10
- package/packages/dd-trace/src/constants.js +8 -1
- package/packages/dd-trace/src/crashtracking/crashtracker.js +98 -0
- package/packages/dd-trace/src/crashtracking/index.js +15 -0
- package/packages/dd-trace/src/crashtracking/noop.js +8 -0
- package/packages/dd-trace/src/datastreams/pathway.js +1 -0
- package/packages/dd-trace/src/debugger/devtools_client/index.js +9 -13
- package/packages/dd-trace/src/debugger/devtools_client/send.js +15 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +57 -23
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +12 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +31 -20
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js +6 -0
- package/packages/dd-trace/src/debugger/devtools_client/state.js +11 -2
- package/packages/dd-trace/src/debugger/index.js +10 -3
- package/packages/dd-trace/src/llmobs/constants/tags.js +34 -0
- package/packages/dd-trace/src/llmobs/constants/text.js +6 -0
- package/packages/dd-trace/src/llmobs/constants/writers.js +13 -0
- package/packages/dd-trace/src/llmobs/index.js +103 -0
- package/packages/dd-trace/src/llmobs/noop.js +82 -0
- package/packages/dd-trace/src/llmobs/plugins/base.js +65 -0
- package/packages/dd-trace/src/llmobs/plugins/openai.js +205 -0
- package/packages/dd-trace/src/llmobs/sdk.js +377 -0
- package/packages/dd-trace/src/llmobs/span_processor.js +195 -0
- package/packages/dd-trace/src/llmobs/storage.js +7 -0
- package/packages/dd-trace/src/llmobs/tagger.js +322 -0
- package/packages/dd-trace/src/llmobs/util.js +176 -0
- package/packages/dd-trace/src/llmobs/writers/base.js +111 -0
- package/packages/dd-trace/src/llmobs/writers/evaluations.js +29 -0
- package/packages/dd-trace/src/llmobs/writers/spans/agentProxy.js +23 -0
- package/packages/dd-trace/src/llmobs/writers/spans/agentless.js +17 -0
- package/packages/dd-trace/src/llmobs/writers/spans/base.js +52 -0
- package/packages/dd-trace/src/log/index.js +10 -13
- package/packages/dd-trace/src/log/log.js +52 -0
- package/packages/dd-trace/src/log/writer.js +50 -19
- package/packages/dd-trace/src/noop/proxy.js +3 -0
- package/packages/dd-trace/src/noop/span.js +4 -0
- package/packages/dd-trace/src/opentelemetry/span.js +16 -1
- package/packages/dd-trace/src/opentelemetry/tracer.js +1 -0
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +106 -32
- package/packages/dd-trace/src/opentracing/span.js +26 -0
- package/packages/dd-trace/src/opentracing/span_context.js +1 -0
- package/packages/dd-trace/src/opentracing/tracer.js +8 -1
- package/packages/dd-trace/src/payload-tagging/config/aws.json +71 -3
- package/packages/dd-trace/src/plugins/outbound.js +9 -0
- package/packages/dd-trace/src/plugins/tracing.js +3 -3
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +121 -0
- package/packages/dd-trace/src/plugins/util/ip_extractor.js +0 -1
- package/packages/dd-trace/src/plugins/util/web.js +39 -11
- package/packages/dd-trace/src/priority_sampler.js +16 -0
- package/packages/dd-trace/src/profiling/config.js +3 -1
- package/packages/dd-trace/src/profiling/exporters/agent.js +7 -5
- package/packages/dd-trace/src/profiling/profilers/wall.js +2 -1
- package/packages/dd-trace/src/proxy.js +13 -1
- package/packages/dd-trace/src/span_processor.js +5 -0
- package/packages/dd-trace/src/telemetry/index.js +11 -1
- package/packages/dd-trace/src/telemetry/logs/index.js +16 -11
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +3 -8
- package/packages/dd-trace/src/telemetry/metrics.js +6 -1
- package/packages/dd-trace/src/util.js +16 -1
- package/version.js +4 -2
- /package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/{code-injection-sensitive-analyzer.js → tainted-range-based-sensitive-analyzer.js} +0 -0
package/LICENSE-3rdparty.csv
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Component,Origin,License,Copyright
|
|
2
|
+
require,@datadog/libdatadog,Apache license 2.0,Copyright 2024 Datadog Inc.
|
|
2
3
|
require,@datadog/native-appsec,Apache license 2.0,Copyright 2018 Datadog Inc.
|
|
3
4
|
require,@datadog/native-metrics,Apache license 2.0,Copyright 2018 Datadog Inc.
|
|
4
5
|
require,@datadog/native-iast-rewriter,Apache license 2.0,Copyright 2018 Datadog Inc.
|
|
@@ -7,6 +8,7 @@ require,@datadog/pprof,Apache license 2.0,Copyright 2019 Google Inc.
|
|
|
7
8
|
require,@datadog/sketches-js,Apache license 2.0,Copyright 2020 Datadog Inc.
|
|
8
9
|
require,@opentelemetry/api,Apache license 2.0,Copyright OpenTelemetry Authors
|
|
9
10
|
require,@opentelemetry/core,Apache license 2.0,Copyright OpenTelemetry Authors
|
|
11
|
+
require,@isaacs/ttlcache,ISC,Copyright (c) 2022-2023 - Isaac Z. Schlueter and Contributors
|
|
10
12
|
require,crypto-randomuuid,MIT,Copyright 2021 Node.js Foundation and contributors
|
|
11
13
|
require,dc-polyfill,MIT,Copyright 2023 Datadog Inc.
|
|
12
14
|
require,ignore,MIT,Copyright 2013 Kael Zhang and contributors
|
|
@@ -29,6 +31,7 @@ require,retry,MIT,Copyright 2011 Tim Koschützki Felix Geisendörfer
|
|
|
29
31
|
require,rfdc,MIT,Copyright 2019 David Mark Clements
|
|
30
32
|
require,semver,ISC,Copyright Isaac Z. Schlueter and Contributors
|
|
31
33
|
require,shell-quote,mit,Copyright (c) 2013 James Halliday
|
|
34
|
+
dev,@apollo/server,MIT,Copyright (c) 2016-2020 Apollo Graph, Inc. (Formerly Meteor Development Group, Inc.)
|
|
32
35
|
dev,@types/node,MIT,Copyright Authors
|
|
33
36
|
dev,autocannon,MIT,Copyright 2016 Matteo Collina
|
|
34
37
|
dev,aws-sdk,Apache 2.0,Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
package/index.d.ts
CHANGED
|
@@ -137,6 +137,11 @@ interface Tracer extends opentracing.Tracer {
|
|
|
137
137
|
TracerProvider: tracer.opentelemetry.TracerProvider;
|
|
138
138
|
|
|
139
139
|
dogstatsd: tracer.DogStatsD;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* LLM Observability SDK
|
|
143
|
+
*/
|
|
144
|
+
llmobs: tracer.llmobs.LLMObs;
|
|
140
145
|
}
|
|
141
146
|
|
|
142
147
|
// left out of the namespace, so it
|
|
@@ -657,19 +662,13 @@ declare namespace tracer {
|
|
|
657
662
|
mode?: 'safe' | 'extended' | 'disabled'
|
|
658
663
|
},
|
|
659
664
|
/**
|
|
660
|
-
* Configuration for Api Security
|
|
665
|
+
* Configuration for Api Security
|
|
661
666
|
*/
|
|
662
667
|
apiSecurity?: {
|
|
663
668
|
/** Whether to enable Api Security.
|
|
664
|
-
* @default
|
|
669
|
+
* @default true
|
|
665
670
|
*/
|
|
666
671
|
enabled?: boolean,
|
|
667
|
-
|
|
668
|
-
/** Controls the request sampling rate (between 0 and 1) in which Api Security is triggered.
|
|
669
|
-
* The value will be coerced back if it's outside of the 0-1 range.
|
|
670
|
-
* @default 0.1
|
|
671
|
-
*/
|
|
672
|
-
requestSampling?: number
|
|
673
672
|
},
|
|
674
673
|
/**
|
|
675
674
|
* Configuration for RASP
|
|
@@ -752,6 +751,11 @@ declare namespace tracer {
|
|
|
752
751
|
*/
|
|
753
752
|
maxDepth?: number
|
|
754
753
|
}
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Configuration enabling LLM Observability. Enablement is superceded by the DD_LLMOBS_ENABLED environment variable.
|
|
757
|
+
*/
|
|
758
|
+
llmobs?: llmobs.LLMObsEnableOptions
|
|
755
759
|
}
|
|
756
760
|
|
|
757
761
|
/**
|
|
@@ -1033,6 +1037,14 @@ declare namespace tracer {
|
|
|
1033
1037
|
* @default code => code < 500
|
|
1034
1038
|
*/
|
|
1035
1039
|
validateStatus?: (code: number) => boolean;
|
|
1040
|
+
|
|
1041
|
+
/**
|
|
1042
|
+
* Enable injection of tracing headers into requests signed with AWS IAM headers.
|
|
1043
|
+
* Disable this if you get AWS signature errors (HTTP 403).
|
|
1044
|
+
*
|
|
1045
|
+
* @default false
|
|
1046
|
+
*/
|
|
1047
|
+
enablePropagationWithAmazonHeaders?: boolean;
|
|
1036
1048
|
}
|
|
1037
1049
|
|
|
1038
1050
|
/** @hidden */
|
|
@@ -2198,6 +2210,331 @@ declare namespace tracer {
|
|
|
2198
2210
|
*/
|
|
2199
2211
|
telemetryVerbosity?: string
|
|
2200
2212
|
}
|
|
2213
|
+
|
|
2214
|
+
export namespace llmobs {
|
|
2215
|
+
export interface LLMObs {
|
|
2216
|
+
|
|
2217
|
+
/**
|
|
2218
|
+
* Whether or not LLM Observability is enabled.
|
|
2219
|
+
*/
|
|
2220
|
+
enabled: boolean,
|
|
2221
|
+
|
|
2222
|
+
/**
|
|
2223
|
+
* Enable LLM Observability tracing.
|
|
2224
|
+
*/
|
|
2225
|
+
enable (options: LLMObsEnableOptions): void,
|
|
2226
|
+
|
|
2227
|
+
/**
|
|
2228
|
+
* Disable LLM Observability tracing.
|
|
2229
|
+
*/
|
|
2230
|
+
disable (): void,
|
|
2231
|
+
|
|
2232
|
+
/**
|
|
2233
|
+
* Instruments a function by automatically creating a span activated on its
|
|
2234
|
+
* scope.
|
|
2235
|
+
*
|
|
2236
|
+
* The span will automatically be finished when one of these conditions is
|
|
2237
|
+
* met:
|
|
2238
|
+
*
|
|
2239
|
+
* * The function returns a promise, in which case the span will finish when
|
|
2240
|
+
* the promise is resolved or rejected.
|
|
2241
|
+
* * The function takes a callback as its second parameter, in which case the
|
|
2242
|
+
* span will finish when that callback is called.
|
|
2243
|
+
* * The function doesn't accept a callback and doesn't return a promise, in
|
|
2244
|
+
* which case the span will finish at the end of the function execution.
|
|
2245
|
+
* @param fn The function to instrument.
|
|
2246
|
+
* @param options Optional LLM Observability span options.
|
|
2247
|
+
* @returns The return value of the function.
|
|
2248
|
+
*/
|
|
2249
|
+
trace<T> (options: LLMObsNamedSpanOptions, fn: (span: tracer.Span, done: (error?: Error) => void) => T): T
|
|
2250
|
+
|
|
2251
|
+
/**
|
|
2252
|
+
* Wrap a function to automatically create a span activated on its
|
|
2253
|
+
* scope when it's called.
|
|
2254
|
+
*
|
|
2255
|
+
* The span will automatically be finished when one of these conditions is
|
|
2256
|
+
* met:
|
|
2257
|
+
*
|
|
2258
|
+
* * The function returns a promise, in which case the span will finish when
|
|
2259
|
+
* the promise is resolved or rejected.
|
|
2260
|
+
* * The function takes a callback as its last parameter, in which case the
|
|
2261
|
+
* span will finish when that callback is called.
|
|
2262
|
+
* * The function doesn't accept a callback and doesn't return a promise, in
|
|
2263
|
+
* which case the span will finish at the end of the function execution.
|
|
2264
|
+
* @param fn The function to instrument.
|
|
2265
|
+
* @param options Optional LLM Observability span options.
|
|
2266
|
+
* @returns A new function that wraps the provided function with span creation.
|
|
2267
|
+
*/
|
|
2268
|
+
wrap<T = (...args: any[]) => any> (options: LLMObsNamelessSpanOptions, fn: T): T
|
|
2269
|
+
|
|
2270
|
+
/**
|
|
2271
|
+
* Decorate a function in a javascript runtime that supports function decorators.
|
|
2272
|
+
* Note that this is **not** supported in the Node.js runtime, but is in TypeScript.
|
|
2273
|
+
*
|
|
2274
|
+
* In TypeScript, this decorator is only supported in contexts where general TypeScript
|
|
2275
|
+
* function decorators are supported.
|
|
2276
|
+
*
|
|
2277
|
+
* @param options Optional LLM Observability span options.
|
|
2278
|
+
*/
|
|
2279
|
+
decorate (options: llmobs.LLMObsNamelessSpanOptions): any
|
|
2280
|
+
|
|
2281
|
+
/**
|
|
2282
|
+
* Returns a representation of a span to export its span and trace IDs.
|
|
2283
|
+
* If no span is provided, the current LLMObs-type span will be used.
|
|
2284
|
+
* @param span Optional span to export.
|
|
2285
|
+
* @returns An object containing the span and trace IDs.
|
|
2286
|
+
*/
|
|
2287
|
+
exportSpan (span?: tracer.Span): llmobs.ExportedLLMObsSpan
|
|
2288
|
+
|
|
2289
|
+
|
|
2290
|
+
/**
|
|
2291
|
+
* Sets inputs, outputs, tags, metadata, and metrics as provided for a given LLM Observability span.
|
|
2292
|
+
* Note that with the exception of tags, this method will override any existing values for the provided fields.
|
|
2293
|
+
*
|
|
2294
|
+
* For example:
|
|
2295
|
+
* ```javascript
|
|
2296
|
+
* llmobs.trace({ kind: 'llm', name: 'myLLM', modelName: 'gpt-4o', modelProvider: 'openai' }, () => {
|
|
2297
|
+
* llmobs.annotate({
|
|
2298
|
+
* inputData: [{ content: 'system prompt, role: 'system' }, { content: 'user prompt', role: 'user' }],
|
|
2299
|
+
* outputData: { content: 'response', role: 'ai' },
|
|
2300
|
+
* metadata: { temperature: 0.7 },
|
|
2301
|
+
* tags: { host: 'localhost' },
|
|
2302
|
+
* metrics: { inputTokens: 10, outputTokens: 20, totalTokens: 30 }
|
|
2303
|
+
* })
|
|
2304
|
+
* })
|
|
2305
|
+
* ```
|
|
2306
|
+
*
|
|
2307
|
+
* @param span The span to annotate (defaults to the current LLM Observability span if not provided)
|
|
2308
|
+
* @param options An object containing the inputs, outputs, tags, metadata, and metrics to set on the span.
|
|
2309
|
+
*/
|
|
2310
|
+
annotate (options: llmobs.AnnotationOptions): void
|
|
2311
|
+
annotate (span: tracer.Span | undefined, options: llmobs.AnnotationOptions): void
|
|
2312
|
+
|
|
2313
|
+
/**
|
|
2314
|
+
* Submits a custom evalutation metric for a given span ID and trace ID.
|
|
2315
|
+
* @param spanContext The span context of the span to submit the evaluation metric for.
|
|
2316
|
+
* @param options An object containing the label, metric type, value, and tags of the evaluation metric.
|
|
2317
|
+
*/
|
|
2318
|
+
submitEvaluation (spanContext: llmobs.ExportedLLMObsSpan, options: llmobs.EvaluationOptions): void
|
|
2319
|
+
|
|
2320
|
+
/**
|
|
2321
|
+
* Flushes any remaining spans and evaluation metrics to LLM Observability.
|
|
2322
|
+
*/
|
|
2323
|
+
flush (): void
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
interface EvaluationOptions {
|
|
2327
|
+
/**
|
|
2328
|
+
* The name of the evalutation metric
|
|
2329
|
+
*/
|
|
2330
|
+
label: string,
|
|
2331
|
+
|
|
2332
|
+
/**
|
|
2333
|
+
* The type of evaluation metric, one of 'categorical' or 'score'
|
|
2334
|
+
*/
|
|
2335
|
+
metricType: 'categorical' | 'score',
|
|
2336
|
+
|
|
2337
|
+
/**
|
|
2338
|
+
* The value of the evaluation metric.
|
|
2339
|
+
* Must be string for 'categorical' metrics and number for 'score' metrics.
|
|
2340
|
+
*/
|
|
2341
|
+
value: string | number,
|
|
2342
|
+
|
|
2343
|
+
/**
|
|
2344
|
+
* An object of string key-value pairs to tag the evaluation metric with.
|
|
2345
|
+
*/
|
|
2346
|
+
tags?: { [key: string]: any },
|
|
2347
|
+
|
|
2348
|
+
/**
|
|
2349
|
+
* The name of the ML application
|
|
2350
|
+
*/
|
|
2351
|
+
mlApp?: string,
|
|
2352
|
+
|
|
2353
|
+
/**
|
|
2354
|
+
* The timestamp in milliseconds when the evaluation metric result was generated.
|
|
2355
|
+
*/
|
|
2356
|
+
timestampMs?: number
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
interface Document {
|
|
2360
|
+
/**
|
|
2361
|
+
* Document text
|
|
2362
|
+
*/
|
|
2363
|
+
text?: string,
|
|
2364
|
+
|
|
2365
|
+
/**
|
|
2366
|
+
* Document name
|
|
2367
|
+
*/
|
|
2368
|
+
name?: string,
|
|
2369
|
+
|
|
2370
|
+
/**
|
|
2371
|
+
* Document ID
|
|
2372
|
+
*/
|
|
2373
|
+
id?: string,
|
|
2374
|
+
|
|
2375
|
+
/**
|
|
2376
|
+
* Score of the document retrieval as a source of ground truth
|
|
2377
|
+
*/
|
|
2378
|
+
score?: number
|
|
2379
|
+
}
|
|
2380
|
+
|
|
2381
|
+
/**
|
|
2382
|
+
* Represents a single LLM chat model message
|
|
2383
|
+
*/
|
|
2384
|
+
interface Message {
|
|
2385
|
+
/**
|
|
2386
|
+
* Content of the message.
|
|
2387
|
+
*/
|
|
2388
|
+
content: string,
|
|
2389
|
+
|
|
2390
|
+
/**
|
|
2391
|
+
* Role of the message (ie system, user, ai)
|
|
2392
|
+
*/
|
|
2393
|
+
role?: string,
|
|
2394
|
+
|
|
2395
|
+
/**
|
|
2396
|
+
* Tool calls of the message
|
|
2397
|
+
*/
|
|
2398
|
+
toolCalls?: ToolCall[],
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
/**
|
|
2402
|
+
* Represents a single tool call for an LLM chat model message
|
|
2403
|
+
*/
|
|
2404
|
+
interface ToolCall {
|
|
2405
|
+
/**
|
|
2406
|
+
* Name of the tool
|
|
2407
|
+
*/
|
|
2408
|
+
name?: string,
|
|
2409
|
+
|
|
2410
|
+
/**
|
|
2411
|
+
* Arguments passed to the tool
|
|
2412
|
+
*/
|
|
2413
|
+
arguments?: { [key: string]: any },
|
|
2414
|
+
|
|
2415
|
+
/**
|
|
2416
|
+
* The tool ID
|
|
2417
|
+
*/
|
|
2418
|
+
toolId?: string,
|
|
2419
|
+
|
|
2420
|
+
/**
|
|
2421
|
+
* The tool type
|
|
2422
|
+
*/
|
|
2423
|
+
type?: string
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2426
|
+
/**
|
|
2427
|
+
* Annotation options for LLM Observability spans.
|
|
2428
|
+
*/
|
|
2429
|
+
interface AnnotationOptions {
|
|
2430
|
+
/**
|
|
2431
|
+
* A single input string, object, or a list of objects based on the span kind:
|
|
2432
|
+
* 1. LLM spans: accepts a string, or an object of the form {content: "...", role: "..."}, or a list of objects with the same signature.
|
|
2433
|
+
* 2. Embedding spans: accepts a string, list of strings, or an object of the form {text: "...", ...}, or a list of objects with the same signature.
|
|
2434
|
+
* 3. Other: any JSON serializable type
|
|
2435
|
+
*/
|
|
2436
|
+
inputData?: string | Message | Message[] | Document | Document[] | { [key: string]: any },
|
|
2437
|
+
|
|
2438
|
+
/**
|
|
2439
|
+
* A single output string, object, or a list of objects based on the span kind:
|
|
2440
|
+
* 1. LLM spans: accepts a string, or an object of the form {content: "...", role: "..."}, or a list of objects with the same signature.
|
|
2441
|
+
* 2. Retrieval spans: An object containing any of the key value pairs {name: str, id: str, text: str, source: number} or a list of dictionaries with the same signature.
|
|
2442
|
+
* 3. Other: any JSON serializable type
|
|
2443
|
+
*/
|
|
2444
|
+
outputData?: string | Message | Message[] | Document | Document[] | { [key: string]: any },
|
|
2445
|
+
|
|
2446
|
+
/**
|
|
2447
|
+
* Object of JSON serializable key-value metadata pairs relevant to the input/output operation described by the LLM Observability span.
|
|
2448
|
+
*/
|
|
2449
|
+
metadata?: { [key: string]: any },
|
|
2450
|
+
|
|
2451
|
+
/**
|
|
2452
|
+
* Object of JSON seraliazable key-value metrics (number) pairs, such as `{input,output,total}Tokens`
|
|
2453
|
+
*/
|
|
2454
|
+
metrics?: { [key: string]: number },
|
|
2455
|
+
|
|
2456
|
+
/**
|
|
2457
|
+
* Object of JSON serializable key-value tag pairs to set or update on the LLM Observability span regarding the span's context.
|
|
2458
|
+
*/
|
|
2459
|
+
tags?: { [key: string]: any }
|
|
2460
|
+
}
|
|
2461
|
+
|
|
2462
|
+
/**
|
|
2463
|
+
* An object containing the span ID and trace ID of interest
|
|
2464
|
+
*/
|
|
2465
|
+
interface ExportedLLMObsSpan {
|
|
2466
|
+
/**
|
|
2467
|
+
* Trace ID associated with the span of interest
|
|
2468
|
+
*/
|
|
2469
|
+
traceId: string,
|
|
2470
|
+
|
|
2471
|
+
/**
|
|
2472
|
+
* Span ID associated with the span of interest
|
|
2473
|
+
*/
|
|
2474
|
+
spanId: string,
|
|
2475
|
+
}
|
|
2476
|
+
|
|
2477
|
+
interface LLMObsSpanOptions extends SpanOptions {
|
|
2478
|
+
/**
|
|
2479
|
+
* LLM Observability span kind. One of `agent`, `workflow`, `task`, `tool`, `retrieval`, `embedding`, or `llm`.
|
|
2480
|
+
*/
|
|
2481
|
+
kind: llmobs.spanKind,
|
|
2482
|
+
|
|
2483
|
+
/**
|
|
2484
|
+
* The ID of the underlying user session. Required for tracking sessions.
|
|
2485
|
+
*/
|
|
2486
|
+
sessionId?: string,
|
|
2487
|
+
|
|
2488
|
+
/**
|
|
2489
|
+
* The name of the ML application that the agent is orchestrating.
|
|
2490
|
+
* If not provided, the default value will be set to mlApp provided during initalization, or `DD_LLMOBS_ML_APP`.
|
|
2491
|
+
*/
|
|
2492
|
+
mlApp?: string,
|
|
2493
|
+
|
|
2494
|
+
/**
|
|
2495
|
+
* The name of the invoked LLM or embedding model. Only used on `llm` and `embedding` spans.
|
|
2496
|
+
*/
|
|
2497
|
+
modelName?: string,
|
|
2498
|
+
|
|
2499
|
+
/**
|
|
2500
|
+
* The name of the invoked LLM or embedding model provider. Only used on `llm` and `embedding` spans.
|
|
2501
|
+
* If not provided for LLM or embedding spans, a default value of 'custom' will be set.
|
|
2502
|
+
*/
|
|
2503
|
+
modelProvider?: string,
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
interface LLMObsNamedSpanOptions extends LLMObsSpanOptions {
|
|
2507
|
+
/**
|
|
2508
|
+
* The name of the traced operation. This is a required option.
|
|
2509
|
+
*/
|
|
2510
|
+
name: string,
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2513
|
+
interface LLMObsNamelessSpanOptions extends LLMObsSpanOptions {
|
|
2514
|
+
/**
|
|
2515
|
+
* The name of the traced operation.
|
|
2516
|
+
*/
|
|
2517
|
+
name?: string,
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2520
|
+
/**
|
|
2521
|
+
* Options for enabling LLM Observability tracing.
|
|
2522
|
+
*/
|
|
2523
|
+
interface LLMObsEnableOptions {
|
|
2524
|
+
/**
|
|
2525
|
+
* The name of your ML application.
|
|
2526
|
+
*/
|
|
2527
|
+
mlApp?: string,
|
|
2528
|
+
|
|
2529
|
+
/**
|
|
2530
|
+
* Set to `true` to disbale sending data that requires a Datadog Agent.
|
|
2531
|
+
*/
|
|
2532
|
+
agentlessEnabled?: boolean,
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
/** @hidden */
|
|
2536
|
+
type spanKind = 'agent' | 'workflow' | 'task' | 'tool' | 'retrieval' | 'embedding' | 'llm'
|
|
2537
|
+
}
|
|
2201
2538
|
}
|
|
2202
2539
|
|
|
2203
2540
|
/**
|
package/init.js
CHANGED
|
@@ -1,58 +1,71 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
const Module = require('module')
|
|
5
|
-
const semver = require('semver')
|
|
6
|
-
const log = require('./packages/dd-trace/src/log')
|
|
7
|
-
const { isTrue } = require('./packages/dd-trace/src/util')
|
|
8
|
-
const telemetry = require('./packages/dd-trace/src/telemetry/init-telemetry')
|
|
3
|
+
/* eslint-disable no-var */
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
let clobberBailout = false
|
|
12
|
-
const forced = isTrue(process.env.DD_INJECT_FORCE)
|
|
5
|
+
var NODE_MAJOR = require('./version').NODE_MAJOR
|
|
13
6
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
7
|
+
// We use several things that are not supported by older versions of Node:
|
|
8
|
+
// - AsyncLocalStorage
|
|
9
|
+
// - The `semver` module
|
|
10
|
+
// - dc-polyfill
|
|
11
|
+
// - Mocha (for testing)
|
|
12
|
+
// and probably others.
|
|
13
|
+
// TODO: Remove all these dependencies so that we can report telemetry.
|
|
14
|
+
if (NODE_MAJOR >= 12) {
|
|
15
|
+
var path = require('path')
|
|
16
|
+
var Module = require('module')
|
|
17
|
+
var semver = require('semver')
|
|
18
|
+
var log = require('./packages/dd-trace/src/log')
|
|
19
|
+
var isTrue = require('./packages/dd-trace/src/util').isTrue
|
|
20
|
+
var telemetry = require('./packages/dd-trace/src/telemetry/init-telemetry')
|
|
21
|
+
|
|
22
|
+
var initBailout = false
|
|
23
|
+
var clobberBailout = false
|
|
24
|
+
var forced = isTrue(process.env.DD_INJECT_FORCE)
|
|
25
|
+
|
|
26
|
+
if (process.env.DD_INJECTION_ENABLED) {
|
|
27
|
+
// If we're running via single-step install, and we're not in the app's
|
|
28
|
+
// node_modules, then we should not initialize the tracer. This prevents
|
|
29
|
+
// single-step-installed tracer from clobbering the manually-installed tracer.
|
|
30
|
+
var resolvedInApp
|
|
31
|
+
var entrypoint = process.argv[1]
|
|
32
|
+
try {
|
|
33
|
+
resolvedInApp = Module.createRequire(entrypoint).resolve('dd-trace')
|
|
34
|
+
} catch (e) {
|
|
35
|
+
// Ignore. If we can't resolve the module, we assume it's not in the app.
|
|
36
|
+
}
|
|
37
|
+
if (resolvedInApp) {
|
|
38
|
+
var ourselves = path.join(__dirname, 'index.js')
|
|
39
|
+
if (ourselves !== resolvedInApp) {
|
|
40
|
+
clobberBailout = true
|
|
41
|
+
}
|
|
29
42
|
}
|
|
30
|
-
}
|
|
31
43
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
// If we're running via single-step install, and the runtime doesn't match
|
|
45
|
+
// the engines field in package.json, then we should not initialize the tracer.
|
|
46
|
+
if (!clobberBailout) {
|
|
47
|
+
var engines = require('./package.json').engines
|
|
48
|
+
var version = process.versions.node
|
|
49
|
+
if (!semver.satisfies(version, engines.node)) {
|
|
50
|
+
initBailout = true
|
|
51
|
+
telemetry([
|
|
52
|
+
{ name: 'abort', tags: ['reason:incompatible_runtime'] },
|
|
53
|
+
{ name: 'abort.runtime', tags: [] }
|
|
54
|
+
])
|
|
55
|
+
log.info('Aborting application instrumentation due to incompatible_runtime.')
|
|
56
|
+
log.info('Found incompatible runtime nodejs ' + version + ', Supported runtimes: nodejs ' + engines.node + '.')
|
|
57
|
+
if (forced) {
|
|
58
|
+
log.info('DD_INJECT_FORCE enabled, allowing unsupported runtimes and continuing.')
|
|
59
|
+
}
|
|
47
60
|
}
|
|
48
61
|
}
|
|
49
62
|
}
|
|
50
|
-
}
|
|
51
63
|
|
|
52
|
-
if (!clobberBailout && (!initBailout || forced)) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
if (!clobberBailout && (!initBailout || forced)) {
|
|
65
|
+
var tracer = require('.')
|
|
66
|
+
tracer.init()
|
|
67
|
+
module.exports = tracer
|
|
68
|
+
telemetry('complete', ['injection_forced:' + (forced && initBailout ? 'true' : 'false')])
|
|
69
|
+
log.info('Application instrumentation bootstrapping complete')
|
|
70
|
+
}
|
|
58
71
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dd-trace",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.26.0",
|
|
4
4
|
"description": "Datadog APM tracing client for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
+
"env": "bash ./plugin-env",
|
|
8
9
|
"preinstall": "node scripts/preinstall.js",
|
|
9
10
|
"bench": "node benchmark",
|
|
10
11
|
"bench:profiler": "node benchmark/profiler",
|
|
@@ -12,8 +13,9 @@
|
|
|
12
13
|
"bench:e2e:ci-visibility": "node benchmark/e2e-ci/benchmark-run.js",
|
|
13
14
|
"type:doc": "cd docs && yarn && yarn build",
|
|
14
15
|
"type:test": "cd docs && yarn && yarn test",
|
|
15
|
-
"lint": "node scripts/check_licenses.js && eslint . && yarn audit
|
|
16
|
-
"lint-fix": "node scripts/check_licenses.js && eslint . --fix && yarn audit
|
|
16
|
+
"lint": "node scripts/check_licenses.js && eslint . && yarn audit",
|
|
17
|
+
"lint-fix": "node scripts/check_licenses.js && eslint . --fix && yarn audit",
|
|
18
|
+
"release:proposal": "node scripts/release/proposal",
|
|
17
19
|
"services": "node ./scripts/install_plugin_modules && node packages/dd-trace/test/setup/services",
|
|
18
20
|
"test": "SERVICES=* yarn services && mocha --expose-gc 'packages/dd-trace/test/setup/node.js' 'packages/*/test/**/*.spec.js'",
|
|
19
21
|
"test:appsec": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" --exclude \"packages/dd-trace/test/appsec/**/*.plugin.spec.js\" \"packages/dd-trace/test/appsec/**/*.spec.js\"",
|
|
@@ -30,6 +32,10 @@
|
|
|
30
32
|
"test:core:ci": "npm run test:core -- --coverage --nyc-arg=--include=\"packages/datadog-core/src/**/*.js\"",
|
|
31
33
|
"test:lambda": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/dd-trace/test/lambda/**/*.spec.js\"",
|
|
32
34
|
"test:lambda:ci": "nyc --no-clean --include \"packages/dd-trace/src/lambda/**/*.js\" -- npm run test:lambda",
|
|
35
|
+
"test:llmobs:sdk": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" --exclude \"packages/dd-trace/test/llmobs/plugins/**/*.spec.js\" \"packages/dd-trace/test/llmobs/**/*.spec.js\" ",
|
|
36
|
+
"test:llmobs:sdk:ci": "nyc --no-clean --include \"packages/dd-trace/src/llmobs/**/*.js\" -- npm run test:llmobs:sdk",
|
|
37
|
+
"test:llmobs:plugins": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/dd-trace/test/llmobs/plugins/**/*.spec.js\"",
|
|
38
|
+
"test:llmobs:plugins:ci": "yarn services && nyc --no-clean --include \"packages/dd-trace/src/llmobs/**/*.js\" -- npm run test:llmobs:plugins",
|
|
33
39
|
"test:plugins": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/datadog-instrumentations/test/@($(echo $PLUGINS)).spec.js\" \"packages/datadog-plugin-@($(echo $PLUGINS))/test/**/*.spec.js\"",
|
|
34
40
|
"test:plugins:ci": "yarn services && nyc --no-clean --include \"packages/datadog-instrumentations/src/@($(echo $PLUGINS)).js\" --include \"packages/datadog-instrumentations/src/@($(echo $PLUGINS))/**/*.js\" --include \"packages/datadog-plugin-@($(echo $PLUGINS))/src/**/*.js\" -- npm run test:plugins",
|
|
35
41
|
"test:plugins:upstream": "node ./packages/dd-trace/test/plugins/suite.js",
|
|
@@ -76,12 +82,14 @@
|
|
|
76
82
|
"node": ">=18"
|
|
77
83
|
},
|
|
78
84
|
"dependencies": {
|
|
79
|
-
"@datadog/
|
|
85
|
+
"@datadog/libdatadog": "^0.2.2",
|
|
86
|
+
"@datadog/native-appsec": "8.3.0",
|
|
80
87
|
"@datadog/native-iast-rewriter": "2.5.0",
|
|
81
|
-
"@datadog/native-iast-taint-tracking": "3.
|
|
82
|
-
"@datadog/native-metrics": "^
|
|
83
|
-
"@datadog/pprof": "5.
|
|
88
|
+
"@datadog/native-iast-taint-tracking": "3.2.0",
|
|
89
|
+
"@datadog/native-metrics": "^3.0.1",
|
|
90
|
+
"@datadog/pprof": "5.4.1",
|
|
84
91
|
"@datadog/sketches-js": "^2.1.0",
|
|
92
|
+
"@isaacs/ttlcache": "^1.4.1",
|
|
85
93
|
"@opentelemetry/api": ">=1.0.0 <1.9.0",
|
|
86
94
|
"@opentelemetry/core": "^1.14.0",
|
|
87
95
|
"crypto-randomuuid": "^1.0.0",
|
|
@@ -108,6 +116,7 @@
|
|
|
108
116
|
"tlhunter-sorted-set": "^0.1.0"
|
|
109
117
|
},
|
|
110
118
|
"devDependencies": {
|
|
119
|
+
"@apollo/server": "^4.11.0",
|
|
111
120
|
"@types/node": "^16.18.103",
|
|
112
121
|
"autocannon": "^4.5.2",
|
|
113
122
|
"aws-sdk": "^2.1446.0",
|
|
@@ -5,15 +5,15 @@ const { getUserLandFrames } = require('../dd-trace/src/plugins/util/stacktrace')
|
|
|
5
5
|
const limit = Number(process.env._DD_CODE_ORIGIN_MAX_USER_FRAMES) || 8
|
|
6
6
|
|
|
7
7
|
module.exports = {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
entryTags,
|
|
9
|
+
exitTags
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
function
|
|
12
|
+
function entryTags (topOfStackFunc) {
|
|
13
13
|
return tag('entry', topOfStackFunc)
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
function
|
|
16
|
+
function exitTags (topOfStackFunc) {
|
|
17
17
|
return tag('exit', topOfStackFunc)
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { AsyncLocalStorage } = require('async_hooks')
|
|
4
|
+
|
|
5
|
+
const storages = Object.create(null)
|
|
6
|
+
const legacyStorage = new AsyncLocalStorage()
|
|
7
|
+
|
|
8
|
+
const storage = function (namespace) {
|
|
9
|
+
if (!storages[namespace]) {
|
|
10
|
+
storages[namespace] = new AsyncLocalStorage()
|
|
11
|
+
}
|
|
12
|
+
return storages[namespace]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
storage.disable = legacyStorage.disable.bind(legacyStorage)
|
|
16
|
+
storage.enterWith = legacyStorage.enterWith.bind(legacyStorage)
|
|
17
|
+
storage.exit = legacyStorage.exit.bind(legacyStorage)
|
|
18
|
+
storage.getStore = legacyStorage.getStore.bind(legacyStorage)
|
|
19
|
+
storage.run = legacyStorage.run.bind(legacyStorage)
|
|
20
|
+
|
|
21
|
+
module.exports = storage
|