dd-trace 6.9.0 → 6.11.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/README.md +0 -17
- package/ci/vitest-no-worker-init-setup.mjs +112 -10
- package/index.d.ts +150 -3
- package/initialize.mjs +28 -17
- package/openfeature.js +2 -2
- package/package.json +14 -10
- package/packages/datadog-esbuild/index.js +0 -34
- package/packages/datadog-instrumentations/src/anthropic.js +210 -15
- package/packages/datadog-instrumentations/src/aws-sdk.js +9 -1
- package/packages/datadog-instrumentations/src/browser-bunyan.js +11 -0
- package/packages/datadog-instrumentations/src/bunyan.js +3 -16
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +111 -6
- package/packages/datadog-instrumentations/src/cucumber.js +26 -11
- package/packages/datadog-instrumentations/src/cypress-config.js +182 -16
- package/packages/datadog-instrumentations/src/cypress-legacy-finalizers.js +30 -0
- package/packages/datadog-instrumentations/src/cypress.js +2 -0
- package/packages/datadog-instrumentations/src/fastify.js +2 -0
- package/packages/datadog-instrumentations/src/helpers/bunyan.js +22 -0
- package/packages/datadog-instrumentations/src/helpers/hooks.js +2 -1
- package/packages/datadog-instrumentations/src/helpers/pool-acquire.js +634 -0
- package/packages/datadog-instrumentations/src/helpers/register.js +10 -8
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +2 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/webdriverio.js +81 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +1 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +83 -1
- package/packages/datadog-instrumentations/src/jest.js +26 -18
- package/packages/datadog-instrumentations/src/mariadb.js +278 -21
- package/packages/datadog-instrumentations/src/mocha/main.js +540 -56
- package/packages/datadog-instrumentations/src/mocha/utils.js +132 -25
- package/packages/datadog-instrumentations/src/mysql.js +45 -15
- package/packages/datadog-instrumentations/src/mysql2.js +119 -18
- package/packages/datadog-instrumentations/src/path-to-regexp.js +67 -1
- package/packages/datadog-instrumentations/src/pg.js +116 -92
- package/packages/datadog-instrumentations/src/playwright-reporter.js +99 -0
- package/packages/datadog-instrumentations/src/playwright.js +149 -2
- package/packages/datadog-instrumentations/src/router.js +2 -0
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +43 -4
- package/packages/datadog-instrumentations/src/vitest-main.js +180 -20
- package/packages/datadog-instrumentations/src/vitest-util.js +64 -5
- package/packages/datadog-instrumentations/src/vitest-worker.js +150 -25
- package/packages/datadog-instrumentations/src/webdriverio.js +31 -17
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/trace-checkpoint.js +12 -6
- package/packages/datadog-plugin-aws-sdk/src/base.js +1 -0
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +163 -44
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +4 -13
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +1 -5
- package/packages/datadog-plugin-azure-functions/src/index.js +1 -1
- package/packages/datadog-plugin-browser-bunyan/src/index.js +9 -0
- package/packages/datadog-plugin-bunyan/src/index.js +5 -8
- package/packages/datadog-plugin-cucumber/src/index.js +11 -0
- package/packages/datadog-plugin-cypress/src/after-run.js +5 -1
- package/packages/datadog-plugin-cypress/src/after-spec.js +5 -1
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +82 -30
- package/packages/datadog-plugin-cypress/src/finalization.js +76 -0
- package/packages/datadog-plugin-cypress/src/index.js +12 -6
- package/packages/datadog-plugin-cypress/src/plugin.js +16 -3
- package/packages/datadog-plugin-dd-trace-api/src/index.js +4 -0
- package/packages/datadog-plugin-electron/src/index.js +2 -0
- package/packages/datadog-plugin-fs/src/index.js +1 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +31 -17
- package/packages/datadog-plugin-jest/src/index.js +11 -4
- package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +2 -3
- package/packages/datadog-plugin-kafkajs/src/consumer.js +2 -3
- package/packages/datadog-plugin-kafkajs/src/producer.js +3 -2
- package/packages/datadog-plugin-kafkajs/src/utils.js +65 -7
- package/packages/datadog-plugin-mocha/src/index.js +606 -40
- package/packages/datadog-plugin-mysql/src/index.js +37 -0
- package/packages/datadog-plugin-nats/src/index.js +1 -1
- package/packages/datadog-plugin-next/src/index.js +1 -19
- package/packages/datadog-plugin-openai/src/tracing.js +41 -30
- package/packages/datadog-plugin-openai-agents/src/integration.js +279 -69
- package/packages/datadog-plugin-openai-agents/src/processor.js +16 -4
- package/packages/datadog-plugin-pg/src/index.js +1 -0
- package/packages/datadog-plugin-playwright/src/index.js +42 -13
- package/packages/datadog-plugin-vitest/src/index.js +14 -20
- package/packages/datadog-plugin-ws/src/util.js +2 -1
- package/packages/datadog-webpack/index.js +0 -11
- package/packages/dd-trace/index.js +0 -1
- package/packages/dd-trace/src/agent/info.js +6 -5
- package/packages/dd-trace/src/aiguard/client.js +100 -1
- package/packages/dd-trace/src/aiguard/errors.js +41 -0
- package/packages/dd-trace/src/aiguard/evaluation.js +357 -0
- package/packages/dd-trace/src/aiguard/integrations/anthropic.js +70 -0
- package/packages/dd-trace/src/aiguard/integrations/index.js +4 -0
- package/packages/dd-trace/src/aiguard/messages/anthropic.js +423 -0
- package/packages/dd-trace/src/aiguard/messages/openai.js +1 -24
- package/packages/dd-trace/src/aiguard/messages/utils.js +28 -0
- package/packages/dd-trace/src/aiguard/messages/vercel-ai.js +1 -11
- package/packages/dd-trace/src/aiguard/sdk.js +22 -278
- package/packages/dd-trace/src/appsec/api_security/normalized-route.js +453 -0
- package/packages/dd-trace/src/appsec/handlers/http-request.js +13 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +9 -12
- package/packages/dd-trace/src/carrier.js +356 -0
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +1 -0
- package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +27 -3
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +22 -6
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +21 -5
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/request-tracker.js +164 -0
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +22 -6
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +365 -32
- package/packages/dd-trace/src/ci-visibility/exporters/request.js +201 -0
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +5 -3
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +9 -5
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -1
- package/packages/dd-trace/src/ci-visibility/requests/rate-limit.js +39 -0
- package/packages/dd-trace/src/ci-visibility/requests/request.js +3 -6
- package/packages/dd-trace/src/ci-visibility/requests/upload-test-screenshot.js +6 -2
- package/packages/dd-trace/src/config/generated-config-types.d.ts +7 -0
- package/packages/dd-trace/src/config/index.js +13 -2
- package/packages/dd-trace/src/config/major-overrides.js +7 -0
- package/packages/dd-trace/src/config/supported-configurations.json +24 -0
- package/packages/dd-trace/src/datastreams/context.js +6 -1
- package/packages/dd-trace/src/datastreams/index.js +2 -0
- package/packages/dd-trace/src/datastreams/manager.js +14 -3
- package/packages/dd-trace/src/datastreams/pathway.js +23 -22
- package/packages/dd-trace/src/datastreams/processor.js +16 -13
- package/packages/dd-trace/src/datastreams/size.js +5 -0
- package/packages/dd-trace/src/debugger/devtools_client/index.js +3 -2
- package/packages/dd-trace/src/exporters/agent/writer.js +49 -9
- package/packages/dd-trace/src/exporters/common/buffering-exporter.js +6 -4
- package/packages/dd-trace/src/exporters/common/writer.js +11 -6
- package/packages/dd-trace/src/llmobs/constants/tags.js +5 -0
- package/packages/dd-trace/src/llmobs/experiments/client.js +163 -5
- package/packages/dd-trace/src/llmobs/experiments/dataset.js +241 -87
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +280 -20
- package/packages/dd-trace/src/llmobs/experiments/index.js +58 -59
- package/packages/dd-trace/src/llmobs/experiments/noop.js +71 -3
- package/packages/dd-trace/src/llmobs/experiments/result.js +1 -0
- package/packages/dd-trace/src/llmobs/experiments/util.js +41 -5
- package/packages/dd-trace/src/llmobs/index.js +34 -2
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +12 -3
- package/packages/dd-trace/src/llmobs/plugins/base.js +4 -2
- package/packages/dd-trace/src/llmobs/span_processor.js +16 -0
- package/packages/dd-trace/src/llmobs/tagger.js +96 -0
- package/packages/dd-trace/src/llmobs/util.js +78 -0
- package/packages/dd-trace/src/noop/proxy.js +3 -4
- package/packages/dd-trace/src/openfeature/flagging_provider.js +18 -2
- package/packages/dd-trace/src/openfeature/remote_config.js +1 -1
- package/packages/dd-trace/src/opentelemetry/context_manager.js +7 -7
- package/packages/dd-trace/src/opentelemetry/logs/batch_log_processor.js +2 -1
- package/packages/dd-trace/src/opentelemetry/logs/logger.js +67 -11
- package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +14 -3
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +25 -12
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +2 -5
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_transformer.js +96 -43
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +126 -120
- package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +4 -8
- package/packages/dd-trace/src/opentracing/tracer.js +5 -2
- package/packages/dd-trace/src/otel-thread-ctx.js +387 -0
- package/packages/dd-trace/src/plugin_manager.js +5 -3
- package/packages/dd-trace/src/plugins/ci_plugin.js +6 -1
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/{datadog-plugin-jest/src/util.js → dd-trace/src/plugins/util/jest.js} +5 -65
- package/packages/dd-trace/src/plugins/util/test.js +93 -14
- package/packages/dd-trace/src/plugins/util/web.js +56 -2
- package/packages/dd-trace/src/profiling/profiler.js +1 -1
- package/packages/dd-trace/src/profiling/profilers/space.js +1 -3
- package/packages/dd-trace/src/profiling/profilers/wall.js +37 -90
- package/packages/dd-trace/src/profiling/webspan-utils.js +45 -0
- package/packages/dd-trace/src/proxy.js +38 -29
- package/packages/dd-trace/src/ritm.js +9 -2
- package/packages/dd-trace/src/serverless.js +37 -0
- package/packages/dd-trace/src/span_format.js +1 -0
- package/packages/dd-trace/src/span_stats.js +30 -3
- package/packages/dd-trace/src/storage-channels.js +86 -0
- package/packages/dd-trace/src/tracer.js +9 -2
- package/packages/dd-trace/src/tracer_metadata.js +14 -1
- package/packages/dd-trace/src/web-tags-cache.js +132 -0
- package/vendor/dist/@datadog/openfeature-node-server/LICENSE +201 -0
- package/vendor/dist/@datadog/openfeature-node-server/index.js +1 -0
- package/packages/datadog-instrumentations/src/helpers/optional-peer-bundler.js +0 -65
- package/packages/datadog-webpack/src/optional-peer-loader.js +0 -17
- package/packages/dd-trace/src/feature-registry.js +0 -29
- package/packages/dd-trace/src/openfeature/register.js +0 -35
- package/packages/dd-trace/src/openfeature/require-provider.js +0 -18
|
@@ -21,6 +21,38 @@ class MySQLPlugin extends DatabasePlugin {
|
|
|
21
21
|
})
|
|
22
22
|
|
|
23
23
|
this.addBind(`apm:${this.component}:connection:finish`, ctx => ctx.currentStore)
|
|
24
|
+
|
|
25
|
+
// Explicit getConnection calls get an acquire span. Pool queries report their internal acquire
|
|
26
|
+
// on the query span instead, so each acquire is counted once.
|
|
27
|
+
this.addSub(`apm:${this.component}:pool:acquire:start`, ctx => {
|
|
28
|
+
const operation = `${this.component}.pool.acquire`
|
|
29
|
+
|
|
30
|
+
this.startSpan(operation, {
|
|
31
|
+
service: this.serviceName({ pluginConfig: this.config, dbConfig: ctx.conf, system: this.system }),
|
|
32
|
+
resource: operation,
|
|
33
|
+
startTime: ctx.startTime,
|
|
34
|
+
type: 'sql',
|
|
35
|
+
kind: 'client',
|
|
36
|
+
meta: {
|
|
37
|
+
'db.type': this.system,
|
|
38
|
+
'db.user': ctx.conf.user,
|
|
39
|
+
'db.name': ctx.conf.database,
|
|
40
|
+
'out.host': ctx.conf.host,
|
|
41
|
+
[CLIENT_PORT_KEY]: ctx.conf.port,
|
|
42
|
+
},
|
|
43
|
+
}, ctx)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
this.addSub(`apm:${this.component}:pool:acquire:finish`, ctx => {
|
|
47
|
+
const span = ctx.currentStore?.span
|
|
48
|
+
if (span === undefined) return
|
|
49
|
+
|
|
50
|
+
if (ctx.error) {
|
|
51
|
+
this.addError(ctx.error, span)
|
|
52
|
+
}
|
|
53
|
+
span.setTag(`${this.component}.pool.wait_time`, ctx.poolWaitTime)
|
|
54
|
+
this.finish(ctx)
|
|
55
|
+
})
|
|
24
56
|
}
|
|
25
57
|
|
|
26
58
|
bindStart (ctx) {
|
|
@@ -38,6 +70,11 @@ class MySQLPlugin extends DatabasePlugin {
|
|
|
38
70
|
[CLIENT_PORT_KEY]: ctx.conf.port,
|
|
39
71
|
},
|
|
40
72
|
}, ctx)
|
|
73
|
+
|
|
74
|
+
if (ctx.poolWaitTime !== undefined) {
|
|
75
|
+
span.setTag(`${this.component}.pool.wait_time`, ctx.poolWaitTime)
|
|
76
|
+
}
|
|
77
|
+
|
|
41
78
|
ctx.sql = this.injectDbmQuery(span, ctx.sql, service.name)
|
|
42
79
|
|
|
43
80
|
return ctx.currentStore
|
|
@@ -8,7 +8,7 @@ class NatsPlugin extends CompositePlugin {
|
|
|
8
8
|
static id = 'nats'
|
|
9
9
|
// Disabled by default — users must opt in via DD_TRACE_NATS_ENABLED=true
|
|
10
10
|
// or `tracer.use('nats')`. Matches the feature parity dashboard policy.
|
|
11
|
-
static
|
|
11
|
+
static optIn = true
|
|
12
12
|
static get plugins () {
|
|
13
13
|
return {
|
|
14
14
|
producer: ProducerPlugin,
|
|
@@ -145,7 +145,7 @@ class NextPlugin extends ServerPlugin {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
configure (config) {
|
|
148
|
-
return super.configure(normalizeConfig(config))
|
|
148
|
+
return super.configure(web.normalizeConfig(config))
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -178,22 +178,4 @@ function setHttpParentRoute (span, method, page, isStatic) {
|
|
|
178
178
|
span.setTag(RESOURCE_NAME, `${method} ${page}`.trim())
|
|
179
179
|
nextParentRoutes.set(span, page)
|
|
180
180
|
}
|
|
181
|
-
|
|
182
|
-
function normalizeConfig (config) {
|
|
183
|
-
const hooks = getHooks(config)
|
|
184
|
-
const validateStatus = typeof config.validateStatus === 'function'
|
|
185
|
-
? config.validateStatus
|
|
186
|
-
: code => code < 500
|
|
187
|
-
|
|
188
|
-
return { ...config, hooks, validateStatus }
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const noop = () => {}
|
|
192
|
-
|
|
193
|
-
function getHooks (config) {
|
|
194
|
-
const request = config.hooks?.request ?? noop
|
|
195
|
-
|
|
196
|
-
return { request }
|
|
197
|
-
}
|
|
198
|
-
|
|
199
181
|
module.exports = NextPlugin
|
|
@@ -102,23 +102,23 @@ class OpenAiTracingPlugin extends TracingPlugin {
|
|
|
102
102
|
},
|
|
103
103
|
}, false)
|
|
104
104
|
|
|
105
|
-
const openaiStore = Object.create(null)
|
|
106
|
-
|
|
107
105
|
const tags = {} // The remaining tags are added one at a time
|
|
108
106
|
|
|
109
107
|
if (payload.stream) {
|
|
110
108
|
tags['openai.request.stream'] = payload.stream
|
|
111
109
|
}
|
|
112
110
|
|
|
111
|
+
let openaiStore
|
|
112
|
+
|
|
113
113
|
switch (normalizedMethodName) {
|
|
114
114
|
case 'createImage':
|
|
115
115
|
case 'createImageEdit':
|
|
116
116
|
case 'createImageVariation':
|
|
117
|
-
commonCreateImageRequestExtraction(tags, payload
|
|
117
|
+
openaiStore = commonCreateImageRequestExtraction(tags, payload)
|
|
118
118
|
break
|
|
119
119
|
|
|
120
120
|
case 'createChatCompletion':
|
|
121
|
-
createChatCompletionRequestExtraction(tags, payload
|
|
121
|
+
openaiStore = createChatCompletionRequestExtraction(tags, payload)
|
|
122
122
|
break
|
|
123
123
|
|
|
124
124
|
case 'createFile':
|
|
@@ -128,7 +128,7 @@ class OpenAiTracingPlugin extends TracingPlugin {
|
|
|
128
128
|
|
|
129
129
|
case 'createTranscription':
|
|
130
130
|
case 'createTranslation':
|
|
131
|
-
commonCreateAudioRequestExtraction(tags, payload
|
|
131
|
+
openaiStore = commonCreateAudioRequestExtraction(tags, payload)
|
|
132
132
|
break
|
|
133
133
|
|
|
134
134
|
case 'retrieveModel':
|
|
@@ -136,11 +136,11 @@ class OpenAiTracingPlugin extends TracingPlugin {
|
|
|
136
136
|
break
|
|
137
137
|
|
|
138
138
|
case 'createEdit':
|
|
139
|
-
createEditRequestExtraction(tags, payload
|
|
139
|
+
openaiStore = createEditRequestExtraction(tags, payload)
|
|
140
140
|
break
|
|
141
141
|
|
|
142
142
|
case 'createResponse':
|
|
143
|
-
createResponseRequestExtraction(tags, payload
|
|
143
|
+
openaiStore = createResponseRequestExtraction(tags, payload)
|
|
144
144
|
break
|
|
145
145
|
}
|
|
146
146
|
|
|
@@ -177,8 +177,6 @@ class OpenAiTracingPlugin extends TracingPlugin {
|
|
|
177
177
|
|
|
178
178
|
body = coerceResponseBody(body, normalizedMethodName)
|
|
179
179
|
|
|
180
|
-
const openaiStore = store.openai
|
|
181
|
-
|
|
182
180
|
if (!error && (path?.startsWith('https://') || path?.startsWith('http://'))) {
|
|
183
181
|
// basic checking for if the path was set as a full URL
|
|
184
182
|
// not using a full regex as it will likely be "https://api.openai.com/..."
|
|
@@ -204,7 +202,7 @@ class OpenAiTracingPlugin extends TracingPlugin {
|
|
|
204
202
|
'openai.response.created_at': body.created_at,
|
|
205
203
|
}
|
|
206
204
|
|
|
207
|
-
responseDataExtractionByMethod(normalizedMethodName, tags, body,
|
|
205
|
+
const openaiStore = responseDataExtractionByMethod(normalizedMethodName, tags, body, store.openai)
|
|
208
206
|
span.addTags(tags)
|
|
209
207
|
|
|
210
208
|
span.finish()
|
|
@@ -298,7 +296,6 @@ class OpenAiTracingPlugin extends TracingPlugin {
|
|
|
298
296
|
|
|
299
297
|
sendLog (methodName, span, tags, openaiStore, error) {
|
|
300
298
|
if (!openaiStore) return
|
|
301
|
-
if (!Object.keys(openaiStore).length) return
|
|
302
299
|
if (!this.sampler.isSampled(span)) return
|
|
303
300
|
|
|
304
301
|
const log = {
|
|
@@ -395,45 +392,54 @@ function normalizeMethodName (methodName) {
|
|
|
395
392
|
}
|
|
396
393
|
}
|
|
397
394
|
|
|
398
|
-
function createEditRequestExtraction (tags, payload
|
|
399
|
-
const
|
|
400
|
-
openaiStore.instruction = instruction
|
|
395
|
+
function createEditRequestExtraction (tags, payload) {
|
|
396
|
+
const openaiStore = Object.create(null)
|
|
397
|
+
openaiStore.instruction = payload.instruction
|
|
398
|
+
return openaiStore
|
|
401
399
|
}
|
|
402
400
|
|
|
403
|
-
function createResponseRequestExtraction (tags, payload
|
|
401
|
+
function createResponseRequestExtraction (tags, payload) {
|
|
404
402
|
// Extract model information
|
|
405
403
|
if (payload.model) {
|
|
406
404
|
tags['openai.request.model'] = payload.model
|
|
407
405
|
}
|
|
408
406
|
|
|
409
407
|
// Store the full payload for response extraction
|
|
408
|
+
const openaiStore = Object.create(null)
|
|
410
409
|
openaiStore.responseData = payload
|
|
410
|
+
return openaiStore
|
|
411
411
|
}
|
|
412
412
|
|
|
413
413
|
function retrieveModelRequestExtraction (tags, payload) {
|
|
414
414
|
tags['openai.request.id'] = payload.id
|
|
415
415
|
}
|
|
416
416
|
|
|
417
|
-
function createChatCompletionRequestExtraction (tags, payload
|
|
417
|
+
function createChatCompletionRequestExtraction (tags, payload) {
|
|
418
418
|
const messages = payload.messages
|
|
419
419
|
if (!defensiveArrayLength(messages)) return
|
|
420
420
|
|
|
421
|
-
openaiStore
|
|
421
|
+
const openaiStore = Object.create(null)
|
|
422
|
+
openaiStore.messages = messages
|
|
423
|
+
return openaiStore
|
|
422
424
|
}
|
|
423
425
|
|
|
424
|
-
function commonCreateImageRequestExtraction (tags, payload
|
|
426
|
+
function commonCreateImageRequestExtraction (tags, payload) {
|
|
427
|
+
let openaiStore
|
|
428
|
+
|
|
425
429
|
// createImageEdit, createImageVariation
|
|
426
430
|
const img = payload.file || payload.image
|
|
427
431
|
if (img !== null && typeof img === 'object' && img.path) {
|
|
428
|
-
|
|
429
|
-
openaiStore.file =
|
|
432
|
+
openaiStore = Object.create(null)
|
|
433
|
+
openaiStore.file = path.basename(img.path)
|
|
430
434
|
}
|
|
431
435
|
|
|
432
436
|
// createImageEdit
|
|
433
437
|
if (payload.mask !== null && typeof payload.mask === 'object' && payload.mask.path) {
|
|
434
|
-
|
|
435
|
-
openaiStore.mask = mask
|
|
438
|
+
openaiStore ??= Object.create(null)
|
|
439
|
+
openaiStore.mask = path.basename(payload.mask.path)
|
|
436
440
|
}
|
|
441
|
+
|
|
442
|
+
return openaiStore
|
|
437
443
|
}
|
|
438
444
|
|
|
439
445
|
function responseDataExtractionByMethod (methodName, tags, body, openaiStore) {
|
|
@@ -441,12 +447,10 @@ function responseDataExtractionByMethod (methodName, tags, body, openaiStore) {
|
|
|
441
447
|
case 'createCompletion':
|
|
442
448
|
case 'createChatCompletion':
|
|
443
449
|
case 'createEdit':
|
|
444
|
-
commonCreateResponseExtraction(tags, body, openaiStore, methodName)
|
|
445
|
-
break
|
|
450
|
+
return commonCreateResponseExtraction(tags, body, openaiStore, methodName)
|
|
446
451
|
|
|
447
452
|
case 'createResponse':
|
|
448
|
-
createResponseResponseExtraction(tags, body, openaiStore)
|
|
449
|
-
break
|
|
453
|
+
return createResponseResponseExtraction(tags, body, openaiStore)
|
|
450
454
|
|
|
451
455
|
case 'listFiles':
|
|
452
456
|
case 'listFineTunes':
|
|
@@ -475,6 +479,8 @@ function responseDataExtractionByMethod (methodName, tags, body, openaiStore) {
|
|
|
475
479
|
retrieveModelResponseExtraction(tags, body)
|
|
476
480
|
break
|
|
477
481
|
}
|
|
482
|
+
|
|
483
|
+
return openaiStore
|
|
478
484
|
}
|
|
479
485
|
|
|
480
486
|
function retrieveModelResponseExtraction (tags, body) {
|
|
@@ -513,10 +519,11 @@ function deleteFileResponseExtraction (tags, body) {
|
|
|
513
519
|
tags['openai.response.id'] = body.id
|
|
514
520
|
}
|
|
515
521
|
|
|
516
|
-
function commonCreateAudioRequestExtraction (tags, body
|
|
522
|
+
function commonCreateAudioRequestExtraction (tags, body) {
|
|
517
523
|
if (body.file !== null && typeof body.file === 'object' && body.file.path) {
|
|
518
|
-
const
|
|
519
|
-
openaiStore.file =
|
|
524
|
+
const openaiStore = Object.create(null)
|
|
525
|
+
openaiStore.file = path.basename(body.file.path)
|
|
526
|
+
return openaiStore
|
|
520
527
|
}
|
|
521
528
|
}
|
|
522
529
|
|
|
@@ -546,9 +553,11 @@ function commonListCountResponseExtraction (tags, body) {
|
|
|
546
553
|
|
|
547
554
|
// createCompletion, createChatCompletion, createEdit
|
|
548
555
|
function commonCreateResponseExtraction (tags, body, openaiStore, methodName) {
|
|
549
|
-
if (!body.choices) return
|
|
556
|
+
if (!body.choices) return openaiStore
|
|
550
557
|
|
|
558
|
+
openaiStore ??= Object.create(null)
|
|
551
559
|
openaiStore.choices = body.choices
|
|
560
|
+
return openaiStore
|
|
552
561
|
}
|
|
553
562
|
|
|
554
563
|
function createResponseResponseExtraction (tags, body, openaiStore) {
|
|
@@ -568,7 +577,9 @@ function createResponseResponseExtraction (tags, body, openaiStore) {
|
|
|
568
577
|
}
|
|
569
578
|
|
|
570
579
|
// Store the full response for potential future use
|
|
580
|
+
openaiStore ??= Object.create(null)
|
|
571
581
|
openaiStore.response = body
|
|
582
|
+
return openaiStore
|
|
572
583
|
}
|
|
573
584
|
|
|
574
585
|
// The server almost always responds with JSON
|