dd-trace 5.58.0 → 5.60.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 +1 -0
- package/ci/cypress/after-run.js +2 -0
- package/ci/cypress/after-spec.js +2 -0
- package/ci/cypress/plugin.js +2 -0
- package/ci/cypress/polyfills.js +2 -0
- package/ci/cypress/support.js +2 -0
- package/ci/init.js +2 -0
- package/index.d.ts +7 -0
- package/init.js +0 -2
- package/initialize.mjs +2 -0
- package/package.json +40 -8
- package/packages/datadog-code-origin/index.js +14 -9
- package/packages/datadog-instrumentations/src/apollo-server.js +14 -3
- package/packages/datadog-instrumentations/src/apollo.js +7 -10
- package/packages/datadog-instrumentations/src/avsc.js +2 -0
- package/packages/datadog-instrumentations/src/child_process.js +21 -42
- package/packages/datadog-instrumentations/src/cucumber.js +10 -8
- package/packages/datadog-instrumentations/src/cypress.js +2 -0
- package/packages/datadog-instrumentations/src/fastify.js +19 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
- package/packages/datadog-instrumentations/src/helpers/register.js +1 -1
- package/packages/datadog-instrumentations/src/hono.js +102 -0
- package/packages/datadog-instrumentations/src/langchain.js +21 -0
- package/packages/datadog-instrumentations/src/mocha/common.js +2 -0
- package/packages/datadog-instrumentations/src/mocha.js +2 -0
- package/packages/datadog-instrumentations/src/nyc.js +2 -0
- package/packages/datadog-instrumentations/src/openai.js +13 -114
- package/packages/datadog-instrumentations/src/orchestrion-config/index.js +32 -0
- package/packages/datadog-instrumentations/src/playwright.js +5 -1
- package/packages/datadog-instrumentations/src/protobufjs.js +2 -0
- package/packages/datadog-instrumentations/src/selenium.js +2 -0
- package/packages/datadog-instrumentations/src/vitest.js +2 -0
- package/packages/datadog-plugin-avsc/src/index.js +2 -0
- package/packages/datadog-plugin-avsc/src/schema_iterator.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +2 -0
- package/packages/datadog-plugin-child_process/src/index.js +30 -10
- package/packages/datadog-plugin-cypress/src/after-run.js +2 -0
- package/packages/datadog-plugin-cypress/src/after-spec.js +2 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +8 -3
- package/packages/datadog-plugin-cypress/src/index.js +2 -0
- package/packages/datadog-plugin-cypress/src/plugin.js +2 -0
- package/packages/datadog-plugin-cypress/src/support.js +4 -2
- package/packages/datadog-plugin-google-cloud-vertexai/src/tracing.js +3 -155
- package/packages/datadog-plugin-google-cloud-vertexai/src/utils.js +2 -0
- package/packages/datadog-plugin-graphql/src/utils.js +2 -0
- package/packages/datadog-plugin-hono/src/index.js +28 -0
- package/packages/datadog-plugin-jest/src/index.js +2 -0
- package/packages/datadog-plugin-jest/src/util.js +2 -0
- package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +2 -0
- package/packages/datadog-plugin-langchain/src/tracing.js +36 -4
- package/packages/datadog-plugin-nyc/src/index.js +2 -0
- package/packages/datadog-plugin-openai/src/stream-helpers.js +114 -0
- package/packages/datadog-plugin-openai/src/tracing.js +38 -0
- package/packages/datadog-plugin-oracledb/src/connection-parser.js +2 -0
- package/packages/datadog-plugin-protobufjs/src/index.js +2 -0
- package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +2 -0
- package/packages/datadog-plugin-selenium/src/index.js +2 -0
- package/packages/datadog-plugin-vitest/src/index.js +2 -0
- package/packages/dd-trace/src/appsec/iast/iast-context.js +5 -1
- package/packages/dd-trace/src/appsec/iast/index.js +2 -0
- package/packages/dd-trace/src/appsec/iast/overhead-controller.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +0 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +2 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-regex.js +2 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +2 -0
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +3 -3
- package/packages/dd-trace/src/appsec/rasp/fs-plugin.js +18 -11
- package/packages/dd-trace/src/appsec/rasp/utils.js +1 -1
- package/packages/dd-trace/src/appsec/recommended.json +88 -2
- package/packages/dd-trace/src/appsec/reporter.js +7 -19
- package/packages/dd-trace/src/appsec/stack_trace.js +11 -11
- package/packages/dd-trace/src/appsec/telemetry/common.js +1 -1
- package/packages/dd-trace/src/appsec/waf/index.js +20 -1
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +2 -2
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +5 -4
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +2 -0
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -1
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -0
- package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +2 -0
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +2 -0
- package/packages/dd-trace/src/ci-visibility/telemetry.js +2 -0
- package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +2 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +7 -3
- package/packages/dd-trace/src/config.js +4 -16
- package/packages/dd-trace/src/config_stable.js +2 -0
- package/packages/dd-trace/src/datastreams/checkpointer.js +2 -0
- package/packages/dd-trace/src/datastreams/context.js +2 -0
- package/packages/dd-trace/src/datastreams/encoding.js +2 -0
- package/packages/dd-trace/src/datastreams/fnv.js +2 -0
- package/packages/dd-trace/src/datastreams/pathway.js +11 -9
- package/packages/dd-trace/src/datastreams/processor.js +8 -7
- package/packages/dd-trace/src/datastreams/schemas/schema.js +2 -0
- package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +45 -36
- package/packages/dd-trace/src/datastreams/schemas/schema_sampler.js +2 -0
- package/packages/dd-trace/src/datastreams/writer.js +2 -0
- package/packages/dd-trace/src/debugger/config.js +16 -0
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/config.js +2 -6
- package/packages/dd-trace/src/debugger/devtools_client/index.js +13 -5
- package/packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js +2 -0
- package/packages/dd-trace/src/debugger/devtools_client/log.js +19 -0
- package/packages/dd-trace/src/debugger/devtools_client/remote_config.js +9 -6
- package/packages/dd-trace/src/debugger/devtools_client/send.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/state.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/status.js +1 -1
- package/packages/dd-trace/src/debugger/index.js +48 -11
- package/packages/dd-trace/src/encode/tags-processors.js +2 -0
- package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +2 -0
- package/packages/dd-trace/src/exporters/common/util.js +2 -0
- package/packages/dd-trace/src/exporters/span-stats/index.js +2 -0
- package/packages/dd-trace/src/exporters/span-stats/writer.js +2 -0
- package/packages/dd-trace/src/external-logger/src/index.js +2 -0
- package/packages/dd-trace/src/git_metadata_tagger.js +2 -0
- package/packages/dd-trace/src/git_properties.js +2 -0
- package/packages/dd-trace/src/guardrails/index.js +3 -4
- package/packages/dd-trace/src/guardrails/log.js +2 -2
- package/packages/dd-trace/src/guardrails/telemetry.js +16 -14
- package/packages/dd-trace/src/guardrails/util.js +0 -2
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +2 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +5 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/tool.js +15 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +36 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +47 -4
- package/packages/dd-trace/src/llmobs/tagger.js +10 -1
- package/packages/dd-trace/src/noop/dogstatsd.js +2 -0
- package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +2 -0
- package/packages/dd-trace/src/payload-tagging/config/index.js +2 -0
- package/packages/dd-trace/src/payload-tagging/index.js +2 -0
- package/packages/dd-trace/src/payload-tagging/tagging.js +2 -0
- package/packages/dd-trace/src/plugins/apollo.js +2 -0
- package/packages/dd-trace/src/plugins/ci_plugin.js +8 -3
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/dd-trace/src/plugins/util/ci.js +17 -7
- package/packages/dd-trace/src/plugins/util/env.js +2 -0
- package/packages/dd-trace/src/plugins/util/git.js +40 -5
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +2 -0
- package/packages/dd-trace/src/plugins/util/llm.js +2 -0
- package/packages/dd-trace/src/plugins/util/serverless.js +2 -0
- package/packages/dd-trace/src/plugins/util/stacktrace.js +178 -50
- package/packages/dd-trace/src/plugins/util/tags.js +19 -1
- package/packages/dd-trace/src/plugins/util/test.js +9 -4
- package/packages/dd-trace/src/plugins/util/url.js +2 -0
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -0
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +4 -0
- package/packages/dd-trace/src/profiling/profiler.js +89 -70
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookup.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookupservice.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_resolve.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_reverse.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/fs.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/net.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/events.js +2 -0
- package/packages/dd-trace/src/profiling/webspan-utils.js +2 -0
- package/packages/dd-trace/src/remote_config/capabilities.js +4 -1
- package/packages/dd-trace/src/remote_config/index.js +6 -0
- package/packages/dd-trace/src/service-naming/index.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/definition.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/util.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/graphql.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/index.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/graphql.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/index.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/web.js +2 -0
- package/packages/dd-trace/src/span_stats.js +2 -0
- package/packages/dd-trace/src/supported-configurations.json +2 -0
- package/packages/dd-trace/src/telemetry/send-data.js +2 -0
- package/register.js +4 -0
- package/version.js +0 -3
|
@@ -53,6 +53,27 @@ for (const extension of extensions) {
|
|
|
53
53
|
return exports
|
|
54
54
|
})
|
|
55
55
|
|
|
56
|
+
addHook({ name: '@langchain/core', file: `dist/tools/index.${extension}`, versions: ['>=0.1'] }, exports => {
|
|
57
|
+
if (extension === 'cjs') {
|
|
58
|
+
wrap(exports.StructuredTool.prototype, 'invoke', 'orchestrion:@langchain/core:Tool_invoke')
|
|
59
|
+
}
|
|
60
|
+
return exports
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
addHook({ name: '@langchain/core', file: `dist/vectorstores.${extension}`, versions: ['>=0.1'] }, exports => {
|
|
64
|
+
if (extension === 'cjs') {
|
|
65
|
+
wrap(
|
|
66
|
+
exports.VectorStore.prototype, 'similaritySearch', 'orchestrion:@langchain/core:VectorStore_similaritySearch'
|
|
67
|
+
)
|
|
68
|
+
wrap(
|
|
69
|
+
exports.VectorStore.prototype, 'similaritySearchWithScore',
|
|
70
|
+
'orchestrion:@langchain/core:VectorStore_similaritySearchWithScore'
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return exports
|
|
75
|
+
})
|
|
76
|
+
|
|
56
77
|
addHook({ name: '@langchain/core', file: `dist/embeddings.${extension}`, versions: ['>=0.1'] }, exports => {
|
|
57
78
|
if (extension === 'cjs') {
|
|
58
79
|
shimmer.wrap(exports, 'Embeddings', Embeddings => {
|
|
@@ -5,6 +5,7 @@ const shimmer = require('../../datadog-shimmer')
|
|
|
5
5
|
|
|
6
6
|
const dc = require('dc-polyfill')
|
|
7
7
|
const ch = dc.tracingChannel('apm:openai:request')
|
|
8
|
+
const onStreamedChunkCh = dc.channel('apm:openai:request:chunk')
|
|
8
9
|
|
|
9
10
|
const V4_PACKAGE_SHIMS = [
|
|
10
11
|
{
|
|
@@ -160,79 +161,12 @@ addHook({ name: 'openai', file: 'dist/api.js', versions: ['>=3.0.0 <4'] }, expor
|
|
|
160
161
|
return exports
|
|
161
162
|
})
|
|
162
163
|
|
|
163
|
-
function addStreamedChunk (content, chunk) {
|
|
164
|
-
content.usage = chunk.usage // add usage if it was specified to be returned
|
|
165
|
-
for (const choice of chunk.choices) {
|
|
166
|
-
const choiceIdx = choice.index
|
|
167
|
-
const oldChoice = content.choices.find(choice => choice?.index === choiceIdx)
|
|
168
|
-
if (oldChoice) {
|
|
169
|
-
if (!oldChoice.finish_reason) {
|
|
170
|
-
oldChoice.finish_reason = choice.finish_reason
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// delta exists on chat completions
|
|
174
|
-
const delta = choice.delta
|
|
175
|
-
|
|
176
|
-
if (delta) {
|
|
177
|
-
const content = delta.content
|
|
178
|
-
if (content) {
|
|
179
|
-
if (oldChoice.delta.content) { // we don't want to append to undefined
|
|
180
|
-
oldChoice.delta.content += content
|
|
181
|
-
} else {
|
|
182
|
-
oldChoice.delta.content = content
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
} else {
|
|
186
|
-
const text = choice.text
|
|
187
|
-
if (text) {
|
|
188
|
-
if (oldChoice.text) {
|
|
189
|
-
oldChoice.text += text
|
|
190
|
-
} else {
|
|
191
|
-
oldChoice.text = text
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// tools only exist on chat completions
|
|
197
|
-
const tools = delta && choice.delta.tool_calls
|
|
198
|
-
|
|
199
|
-
if (tools) {
|
|
200
|
-
oldChoice.delta.tool_calls = tools.map((newTool, toolIdx) => {
|
|
201
|
-
const oldTool = oldChoice.delta.tool_calls?.[toolIdx]
|
|
202
|
-
|
|
203
|
-
if (oldTool) {
|
|
204
|
-
oldTool.function.arguments += newTool.function.arguments
|
|
205
|
-
return oldTool
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return newTool
|
|
209
|
-
})
|
|
210
|
-
}
|
|
211
|
-
} else {
|
|
212
|
-
// we don't know which choices arrive in which order
|
|
213
|
-
content.choices[choiceIdx] = choice
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function convertBufferstoObjects (chunks) {
|
|
219
|
-
return Buffer
|
|
220
|
-
.concat(chunks) // combine the buffers
|
|
221
|
-
.toString() // stringify
|
|
222
|
-
.split(/(?=data:)/) // split on "data:"
|
|
223
|
-
.map(chunk => chunk.replaceAll('\n', '').slice(6)) // remove newlines and 'data: ' from the front
|
|
224
|
-
.slice(0, -1) // remove the last [DONE] message
|
|
225
|
-
.map(JSON.parse) // parse all of the returned objects
|
|
226
|
-
}
|
|
227
|
-
|
|
228
164
|
/**
|
|
229
165
|
* For streamed responses, we need to accumulate all of the content in
|
|
230
166
|
* the chunks, and let the combined content be the final response.
|
|
231
167
|
* This way, spans look the same as when not streamed.
|
|
232
168
|
*/
|
|
233
|
-
function wrapStreamIterator (response, options,
|
|
234
|
-
let processChunksAsBuffers = false
|
|
235
|
-
let chunks = []
|
|
169
|
+
function wrapStreamIterator (response, options, ctx) {
|
|
236
170
|
return function (itr) {
|
|
237
171
|
return function () {
|
|
238
172
|
const iterator = itr.apply(this, arguments)
|
|
@@ -240,39 +174,11 @@ function wrapStreamIterator (response, options, n, ctx) {
|
|
|
240
174
|
return next.apply(this, arguments)
|
|
241
175
|
.then(res => {
|
|
242
176
|
const { done, value: chunk } = res
|
|
243
|
-
|
|
244
|
-
if (chunk) {
|
|
245
|
-
chunks.push(chunk)
|
|
246
|
-
// TODO(BridgeAR): It likely depends on the options being passed
|
|
247
|
-
// through if the stream returns buffers or not. By reading that,
|
|
248
|
-
// we don't have to do the instanceof check anymore, which is
|
|
249
|
-
// relatively expensive.
|
|
250
|
-
if (chunk instanceof Buffer) {
|
|
251
|
-
// this operation should be safe
|
|
252
|
-
// if one chunk is a buffer (versus a plain object), the rest should be as well
|
|
253
|
-
processChunksAsBuffers = true
|
|
254
|
-
}
|
|
255
|
-
}
|
|
177
|
+
onStreamedChunkCh.publish({ ctx, chunk, done })
|
|
256
178
|
|
|
257
179
|
if (done) {
|
|
258
|
-
let body = {}
|
|
259
|
-
if (processChunksAsBuffers) {
|
|
260
|
-
chunks = convertBufferstoObjects(chunks)
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
if (chunks.length) {
|
|
264
|
-
// Define the initial body having all the content outside of choices from the first chunk
|
|
265
|
-
// this will include import data like created, id, model, etc.
|
|
266
|
-
body = { ...chunks[0], choices: Array.from({ length: n }) }
|
|
267
|
-
// Start from the first chunk, and add its choices into the body
|
|
268
|
-
for (const chunk_ of chunks) {
|
|
269
|
-
addStreamedChunk(body, chunk_)
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
180
|
finish(ctx, {
|
|
274
181
|
headers: response.headers,
|
|
275
|
-
data: body,
|
|
276
182
|
request: {
|
|
277
183
|
path: response.url,
|
|
278
184
|
method: options.method
|
|
@@ -312,17 +218,6 @@ for (const extension of extensions) {
|
|
|
312
218
|
// chat.completions and completions
|
|
313
219
|
const stream = streamedResponse && getOption(arguments, 'stream', false)
|
|
314
220
|
|
|
315
|
-
// we need to compute how many prompts we are sending in streamed cases for completions
|
|
316
|
-
// not applicable for chat completiond
|
|
317
|
-
let n
|
|
318
|
-
if (stream) {
|
|
319
|
-
n = getOption(arguments, 'n', 1)
|
|
320
|
-
const prompt = getOption(arguments, 'prompt')
|
|
321
|
-
if (Array.isArray(prompt) && typeof prompt[0] !== 'number') {
|
|
322
|
-
n *= prompt.length
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
221
|
const client = this._client || this.client
|
|
327
222
|
|
|
328
223
|
const ctx = {
|
|
@@ -348,7 +243,7 @@ for (const extension of extensions) {
|
|
|
348
243
|
const parsedPromise = origApiPromParse.apply(this, arguments)
|
|
349
244
|
.then(body => Promise.all([this.responsePromise, body]))
|
|
350
245
|
|
|
351
|
-
return handleUnwrappedAPIPromise(parsedPromise, ctx, stream
|
|
246
|
+
return handleUnwrappedAPIPromise(parsedPromise, ctx, stream)
|
|
352
247
|
})
|
|
353
248
|
|
|
354
249
|
return unwrappedPromise
|
|
@@ -361,7 +256,7 @@ for (const extension of extensions) {
|
|
|
361
256
|
const parsedPromise = origApiPromParse.apply(this, arguments)
|
|
362
257
|
.then(body => Promise.all([this.responsePromise, body]))
|
|
363
258
|
|
|
364
|
-
return handleUnwrappedAPIPromise(parsedPromise, ctx, stream
|
|
259
|
+
return handleUnwrappedAPIPromise(parsedPromise, ctx, stream)
|
|
365
260
|
})
|
|
366
261
|
|
|
367
262
|
ch.end.publish(ctx)
|
|
@@ -375,15 +270,15 @@ for (const extension of extensions) {
|
|
|
375
270
|
}
|
|
376
271
|
}
|
|
377
272
|
|
|
378
|
-
function handleUnwrappedAPIPromise (apiProm, ctx, stream
|
|
273
|
+
function handleUnwrappedAPIPromise (apiProm, ctx, stream) {
|
|
379
274
|
return apiProm
|
|
380
275
|
.then(([{ response, options }, body]) => {
|
|
381
276
|
if (stream) {
|
|
382
277
|
if (body.iterator) {
|
|
383
|
-
shimmer.wrap(body, 'iterator', wrapStreamIterator(response, options,
|
|
278
|
+
shimmer.wrap(body, 'iterator', wrapStreamIterator(response, options, ctx))
|
|
384
279
|
} else {
|
|
385
280
|
shimmer.wrap(
|
|
386
|
-
body.response.body, Symbol.asyncIterator, wrapStreamIterator(response, options,
|
|
281
|
+
body.response.body, Symbol.asyncIterator, wrapStreamIterator(response, options, ctx)
|
|
387
282
|
)
|
|
388
283
|
}
|
|
389
284
|
} else {
|
|
@@ -412,7 +307,11 @@ function finish (ctx, response, error) {
|
|
|
412
307
|
ch.error.publish(ctx)
|
|
413
308
|
}
|
|
414
309
|
|
|
415
|
-
|
|
310
|
+
// for successful streamed responses, we've already set the result on ctx.body,
|
|
311
|
+
// so we don't want to override it here
|
|
312
|
+
ctx.result ??= {}
|
|
313
|
+
Object.assign(ctx.result, response)
|
|
314
|
+
|
|
416
315
|
ch.asyncEnd.publish(ctx)
|
|
417
316
|
}
|
|
418
317
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
1
3
|
module.exports = `
|
|
2
4
|
version: 1
|
|
3
5
|
dc_module: dc-polyfill
|
|
@@ -51,4 +53,34 @@ instrumentations:
|
|
|
51
53
|
class: Embeddings
|
|
52
54
|
operator: traceSync
|
|
53
55
|
channel_name: "Embeddings_constructor"
|
|
56
|
+
- module_name: "@langchain/core"
|
|
57
|
+
version_range: ">=0.1.0"
|
|
58
|
+
file_path: dist/tools/index.js
|
|
59
|
+
function_query:
|
|
60
|
+
name: invoke
|
|
61
|
+
type: method
|
|
62
|
+
kind: async
|
|
63
|
+
class: StructuredTool
|
|
64
|
+
operator: tracePromise
|
|
65
|
+
channel_name: "Tool_invoke"
|
|
66
|
+
- module_name: "@langchain/core"
|
|
67
|
+
version_range: ">=0.1.0"
|
|
68
|
+
file_path: dist/vectorstores.js
|
|
69
|
+
function_query:
|
|
70
|
+
name: similaritySearch
|
|
71
|
+
type: method
|
|
72
|
+
kind: async
|
|
73
|
+
class: VectorStore
|
|
74
|
+
operator: tracePromise
|
|
75
|
+
channel_name: "VectorStore_similaritySearch"
|
|
76
|
+
- module_name: "@langchain/core"
|
|
77
|
+
version_range: ">=0.1.0"
|
|
78
|
+
file_path: dist/vectorstores.js
|
|
79
|
+
function_query:
|
|
80
|
+
name: similaritySearchWithScore
|
|
81
|
+
type: method
|
|
82
|
+
kind: async
|
|
83
|
+
class: VectorStore
|
|
84
|
+
operator: tracePromise
|
|
85
|
+
channel_name: "VectorStore_similaritySearchWithScore"
|
|
54
86
|
`
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
1
3
|
const satisfies = require('semifies')
|
|
2
4
|
|
|
3
5
|
const { addHook, channel } = require('./helpers/instrument')
|
|
@@ -335,7 +337,9 @@ function testEndHandler (test, annotations, testStatus, error, isTimeout, isMain
|
|
|
335
337
|
testStatuses.push(testStatus)
|
|
336
338
|
}
|
|
337
339
|
|
|
338
|
-
|
|
340
|
+
const testProperties = getTestProperties(test)
|
|
341
|
+
|
|
342
|
+
if (testStatuses.length === testManagementAttemptToFixRetries + 1 && testProperties.attemptToFix) {
|
|
339
343
|
if (testStatuses.includes('fail')) {
|
|
340
344
|
test._ddHasFailedAttemptToFixRetries = true
|
|
341
345
|
}
|
|
@@ -35,7 +35,9 @@ class ChildProcessPlugin extends TracingPlugin {
|
|
|
35
35
|
return this._tracer
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
start (
|
|
38
|
+
start (ctx) {
|
|
39
|
+
const { command, shell } = ctx
|
|
40
|
+
|
|
39
41
|
if (typeof command !== 'string') {
|
|
40
42
|
return
|
|
41
43
|
}
|
|
@@ -58,10 +60,13 @@ class ChildProcessPlugin extends TracingPlugin {
|
|
|
58
60
|
resource: (shell === true) ? 'sh' : cmdFields[0],
|
|
59
61
|
type: 'system',
|
|
60
62
|
meta
|
|
61
|
-
})
|
|
63
|
+
}, ctx)
|
|
64
|
+
|
|
65
|
+
return ctx.currentStore
|
|
62
66
|
}
|
|
63
67
|
|
|
64
|
-
end (
|
|
68
|
+
end (ctx) {
|
|
69
|
+
const { result, error } = ctx
|
|
65
70
|
let exitCode
|
|
66
71
|
|
|
67
72
|
if (result !== undefined) {
|
|
@@ -74,17 +79,32 @@ class ChildProcessPlugin extends TracingPlugin {
|
|
|
74
79
|
exitCode = error?.status || error?.code || 0
|
|
75
80
|
}
|
|
76
81
|
|
|
77
|
-
this.activeSpan
|
|
78
|
-
|
|
82
|
+
const span = ctx.currentStore?.span || this.activeSpan
|
|
83
|
+
|
|
84
|
+
span?.setTag('cmd.exit_code', `${exitCode}`)
|
|
85
|
+
span?.finish()
|
|
86
|
+
|
|
87
|
+
return ctx.parentStore
|
|
79
88
|
}
|
|
80
89
|
|
|
81
|
-
error (
|
|
82
|
-
|
|
90
|
+
error (ctx) {
|
|
91
|
+
const { error } = ctx
|
|
92
|
+
|
|
93
|
+
const span = ctx.currentStore?.span || this.activeSpan
|
|
94
|
+
this.addError(error, span)
|
|
95
|
+
|
|
96
|
+
return ctx.parentStore
|
|
83
97
|
}
|
|
84
98
|
|
|
85
|
-
asyncEnd (
|
|
86
|
-
|
|
87
|
-
|
|
99
|
+
asyncEnd (ctx) {
|
|
100
|
+
const { result } = ctx
|
|
101
|
+
|
|
102
|
+
const span = ctx.currentStore?.span || this.activeSpan
|
|
103
|
+
|
|
104
|
+
span?.setTag('cmd.exit_code', `${result}`)
|
|
105
|
+
span?.finish()
|
|
106
|
+
|
|
107
|
+
return ctx.parentStore
|
|
88
108
|
}
|
|
89
109
|
}
|
|
90
110
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
1
3
|
const {
|
|
2
4
|
TEST_STATUS,
|
|
3
5
|
TEST_IS_RUM_ACTIVE,
|
|
@@ -76,7 +78,8 @@ const {
|
|
|
76
78
|
GIT_TAG,
|
|
77
79
|
GIT_PULL_REQUEST_BASE_BRANCH_SHA,
|
|
78
80
|
GIT_COMMIT_HEAD_SHA,
|
|
79
|
-
GIT_PULL_REQUEST_BASE_BRANCH
|
|
81
|
+
GIT_PULL_REQUEST_BASE_BRANCH,
|
|
82
|
+
GIT_COMMIT_HEAD_MESSAGE
|
|
80
83
|
} = require('../../dd-trace/src/plugins/util/tags')
|
|
81
84
|
const {
|
|
82
85
|
OS_VERSION,
|
|
@@ -238,7 +241,8 @@ class CypressPlugin {
|
|
|
238
241
|
[GIT_COMMIT_MESSAGE]: commitMessage,
|
|
239
242
|
[GIT_TAG]: tag,
|
|
240
243
|
[GIT_PULL_REQUEST_BASE_BRANCH_SHA]: pullRequestBaseSha,
|
|
241
|
-
[GIT_COMMIT_HEAD_SHA]: commitHeadSha
|
|
244
|
+
[GIT_COMMIT_HEAD_SHA]: commitHeadSha,
|
|
245
|
+
[GIT_COMMIT_HEAD_MESSAGE]: commitHeadMessage
|
|
242
246
|
} = this.testEnvironmentMetadata
|
|
243
247
|
|
|
244
248
|
this.repositoryRoot = repositoryRoot || process.cwd()
|
|
@@ -258,7 +262,8 @@ class CypressPlugin {
|
|
|
258
262
|
commitMessage,
|
|
259
263
|
tag,
|
|
260
264
|
pullRequestBaseSha,
|
|
261
|
-
commitHeadSha
|
|
265
|
+
commitHeadSha,
|
|
266
|
+
commitHeadMessage
|
|
262
267
|
}
|
|
263
268
|
this.finishedTestsByFile = {}
|
|
264
269
|
this.testStatuses = {}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
1
3
|
let isEarlyFlakeDetectionEnabled = false
|
|
2
4
|
let isKnownTestsEnabled = false
|
|
3
5
|
let knownTestsForSuite = []
|
|
@@ -28,8 +30,8 @@ function isNewTest (test) {
|
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
function getTestProperties (testName) {
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
+
// TODO: Use optional chaining when we drop support for older Cypress versions, which will happen when dd-trace@5 is
|
|
34
|
+
// EoL. Until then, this files needs to support Node.js 16.
|
|
33
35
|
const properties = testManagementTests[testName] && testManagementTests[testName].properties || {}
|
|
34
36
|
|
|
35
37
|
const { attempt_to_fix: isAttemptToFix, disabled: isDisabled, quarantined: isQuarantined } = properties
|
|
@@ -7,7 +7,6 @@ const makeUtilities = require('../../dd-trace/src/plugins/util/llm')
|
|
|
7
7
|
|
|
8
8
|
const {
|
|
9
9
|
extractModel,
|
|
10
|
-
extractSystemInstructions
|
|
11
10
|
} = require('./utils')
|
|
12
11
|
|
|
13
12
|
class GoogleCloudVertexAITracingPlugin extends TracingPlugin {
|
|
@@ -23,20 +22,18 @@ class GoogleCloudVertexAITracingPlugin extends TracingPlugin {
|
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
bindStart (ctx) {
|
|
26
|
-
const { instance,
|
|
25
|
+
const { instance, resource } = ctx
|
|
27
26
|
|
|
28
27
|
const span = this.startSpan('vertexai.request', {
|
|
29
28
|
service: this.config.service,
|
|
30
29
|
resource,
|
|
31
30
|
kind: 'client',
|
|
32
31
|
meta: {
|
|
33
|
-
[MEASURED]: 1
|
|
32
|
+
[MEASURED]: 1,
|
|
33
|
+
'vertexai.request.model': extractModel(instance)
|
|
34
34
|
}
|
|
35
35
|
}, false)
|
|
36
36
|
|
|
37
|
-
const tags = this.tagRequest(request, instance, stream, span)
|
|
38
|
-
span.addTags(tags)
|
|
39
|
-
|
|
40
37
|
const store = storage('legacy').getStore() || {}
|
|
41
38
|
ctx.currentStore = { ...store, span }
|
|
42
39
|
|
|
@@ -47,157 +44,8 @@ class GoogleCloudVertexAITracingPlugin extends TracingPlugin {
|
|
|
47
44
|
const span = ctx.currentStore?.span
|
|
48
45
|
if (!span) return
|
|
49
46
|
|
|
50
|
-
const { result } = ctx
|
|
51
|
-
|
|
52
|
-
const response = result?.response
|
|
53
|
-
if (response) {
|
|
54
|
-
const tags = this.tagResponse(response, span)
|
|
55
|
-
span.addTags(tags)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
47
|
span.finish()
|
|
59
48
|
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Generate the request tags.
|
|
63
|
-
*
|
|
64
|
-
* @param {Object} request
|
|
65
|
-
* @param {Object} instance
|
|
66
|
-
* @param {boolean} stream
|
|
67
|
-
* @param {Span} span
|
|
68
|
-
* @returns {Object}
|
|
69
|
-
*/
|
|
70
|
-
tagRequest (request, instance, stream, span) {
|
|
71
|
-
const model = extractModel(instance)
|
|
72
|
-
const tags = {
|
|
73
|
-
'vertexai.request.model': model
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const history = instance.historyInternal
|
|
77
|
-
|
|
78
|
-
let contents = typeof request === 'string' || Array.isArray(request) ? request : request.contents
|
|
79
|
-
if (history) {
|
|
80
|
-
contents = [...history, ...(Array.isArray(contents) ? contents : [contents])]
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const generationConfig = instance.generationConfig || {}
|
|
84
|
-
for (const key of Object.keys(generationConfig)) {
|
|
85
|
-
const transformedKey = key.replaceAll(/([a-z0-9])([A-Z])/g, '$1_$2').toLowerCase()
|
|
86
|
-
tags[`vertexai.request.generation_config.${transformedKey}`] = JSON.stringify(generationConfig[key])
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (stream) {
|
|
90
|
-
tags['vertexai.request.stream'] = true
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (!this.isPromptCompletionSampled(span)) return tags
|
|
94
|
-
|
|
95
|
-
const systemInstructions = extractSystemInstructions(instance)
|
|
96
|
-
|
|
97
|
-
for (const [idx, systemInstruction] of systemInstructions.entries()) {
|
|
98
|
-
tags[`vertexai.request.system_instruction.${idx}.text`] = systemInstruction
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (typeof contents === 'string') {
|
|
102
|
-
tags['vertexai.request.contents.0.text'] = contents
|
|
103
|
-
return tags
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
for (const [contentIdx, content] of contents.entries()) {
|
|
107
|
-
this.tagRequestContent(tags, content, contentIdx)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return tags
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
tagRequestPart (part, tags, partIdx, contentIdx) {
|
|
114
|
-
tags[`vertexai.request.contents.${contentIdx}.parts.${partIdx}.text`] = this.normalize(part.text)
|
|
115
|
-
|
|
116
|
-
const functionCall = part.functionCall
|
|
117
|
-
const functionResponse = part.functionResponse
|
|
118
|
-
|
|
119
|
-
if (functionCall) {
|
|
120
|
-
tags[`vertexai.request.contents.${contentIdx}.parts.${partIdx}.function_call.name`] = functionCall.name
|
|
121
|
-
tags[`vertexai.request.contents.${contentIdx}.parts.${partIdx}.function_call.args`] =
|
|
122
|
-
this.normalize(JSON.stringify(functionCall.args))
|
|
123
|
-
}
|
|
124
|
-
if (functionResponse) {
|
|
125
|
-
tags[`vertexai.request.contents.${contentIdx}.parts.${partIdx}.function_response.name`] =
|
|
126
|
-
functionResponse.name
|
|
127
|
-
tags[`vertexai.request.contents.${contentIdx}.parts.${partIdx}.function_response.response`] =
|
|
128
|
-
this.normalize(JSON.stringify(functionResponse.response))
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
tagRequestContent (tags, content, contentIdx) {
|
|
133
|
-
if (typeof content === 'string') {
|
|
134
|
-
tags[`vertexai.request.contents.${contentIdx}.text`] = this.normalize(content)
|
|
135
|
-
return
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (content.text || content.functionCall || content.functionResponse) {
|
|
139
|
-
this.tagRequestPart(content, tags, 0, contentIdx)
|
|
140
|
-
return
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const { role, parts } = content
|
|
144
|
-
if (role) {
|
|
145
|
-
tags[`vertexai.request.contents.${contentIdx}.role`] = role
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
for (const [partIdx, part] of parts.entries()) {
|
|
149
|
-
this.tagRequestPart(part, tags, partIdx, contentIdx)
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Generate the response tags.
|
|
155
|
-
*
|
|
156
|
-
* @param {Object} response
|
|
157
|
-
* @param {Span} span
|
|
158
|
-
* @returns {Object}
|
|
159
|
-
*/
|
|
160
|
-
tagResponse (response, span) {
|
|
161
|
-
const tags = {}
|
|
162
|
-
const isSampled = this.isPromptCompletionSampled(span)
|
|
163
|
-
|
|
164
|
-
const candidates = response.candidates
|
|
165
|
-
for (const [candidateIdx, candidate] of candidates.entries()) {
|
|
166
|
-
const finishReason = candidate.finishReason
|
|
167
|
-
if (finishReason) {
|
|
168
|
-
tags[`vertexai.response.candidates.${candidateIdx}.finish_reason`] = finishReason
|
|
169
|
-
}
|
|
170
|
-
const candidateContent = candidate.content
|
|
171
|
-
const role = candidateContent.role
|
|
172
|
-
tags[`vertexai.response.candidates.${candidateIdx}.content.role`] = role
|
|
173
|
-
|
|
174
|
-
if (!isSampled) continue
|
|
175
|
-
|
|
176
|
-
const parts = candidateContent.parts
|
|
177
|
-
for (const [partIdx, part] of parts.entries()) {
|
|
178
|
-
const text = part.text
|
|
179
|
-
tags[`vertexai.response.candidates.${candidateIdx}.content.parts.${partIdx}.text`] =
|
|
180
|
-
this.normalize(String(text))
|
|
181
|
-
|
|
182
|
-
const functionCall = part.functionCall
|
|
183
|
-
if (!functionCall) continue
|
|
184
|
-
|
|
185
|
-
tags[`vertexai.response.candidates.${candidateIdx}.content.parts.${partIdx}.function_call.name`] =
|
|
186
|
-
functionCall.name
|
|
187
|
-
tags[`vertexai.response.candidates.${candidateIdx}.content.parts.${partIdx}.function_call.args`] =
|
|
188
|
-
this.normalize(JSON.stringify(functionCall.args))
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
const tokenCounts = response.usageMetadata
|
|
193
|
-
if (tokenCounts) {
|
|
194
|
-
tags['vertexai.response.usage.prompt_tokens'] = tokenCounts.promptTokenCount
|
|
195
|
-
tags['vertexai.response.usage.completion_tokens'] = tokenCounts.candidatesTokenCount
|
|
196
|
-
tags['vertexai.response.usage.total_tokens'] = tokenCounts.totalTokenCount
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return tags
|
|
200
|
-
}
|
|
201
49
|
}
|
|
202
50
|
|
|
203
51
|
module.exports = GoogleCloudVertexAITracingPlugin
|