dd-trace 5.79.0 → 5.81.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 +79 -87
- package/ext/tags.d.ts +1 -0
- package/ext/tags.js +1 -0
- package/index.d.ts +46 -39
- package/initialize.mjs +10 -10
- package/loader-hook.mjs +10 -3
- package/package.json +23 -40
- package/packages/datadog-core/src/storage.js +4 -4
- package/packages/datadog-esbuild/index.js +36 -19
- package/packages/datadog-esbuild/src/utils.js +5 -1
- package/packages/datadog-instrumentations/index.js +1 -0
- package/packages/datadog-instrumentations/src/anthropic.js +12 -0
- package/packages/datadog-instrumentations/src/aws-sdk.js +13 -2
- package/packages/datadog-instrumentations/src/azure-service-bus.js +43 -36
- package/packages/datadog-instrumentations/src/cucumber.js +2 -2
- package/packages/datadog-instrumentations/src/find-my-way.js +6 -5
- package/packages/datadog-instrumentations/src/google-genai.js +120 -0
- package/packages/datadog-instrumentations/src/graphql.js +20 -0
- package/packages/datadog-instrumentations/src/helpers/hook.js +1 -0
- package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
- package/packages/datadog-instrumentations/src/helpers/instrument.js +12 -1
- package/packages/datadog-instrumentations/src/helpers/register.js +6 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/compiler.js +27 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +152 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +5 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/langchain.js +237 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.js +9 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs +11 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +139 -0
- package/packages/datadog-instrumentations/src/jest.js +1 -1
- package/packages/datadog-instrumentations/src/langchain.js +3 -109
- package/packages/datadog-instrumentations/src/mocha/main.js +1 -1
- package/packages/datadog-instrumentations/src/mysql2.js +1 -1
- package/packages/datadog-instrumentations/src/playwright.js +65 -16
- package/packages/datadog-instrumentations/src/router.js +1 -1
- package/packages/datadog-instrumentations/src/selenium.js +3 -1
- package/packages/datadog-instrumentations/src/ws.js +35 -17
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +3 -2
- package/packages/datadog-plugin-azure-service-bus/src/producer.js +14 -5
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +1 -1
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +23 -2
- package/packages/datadog-plugin-cypress/src/plugin.js +1 -1
- package/packages/datadog-plugin-cypress/src/support.js +73 -31
- package/packages/datadog-plugin-google-genai/src/index.js +17 -0
- package/packages/datadog-plugin-google-genai/src/tracing.js +41 -0
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +5 -4
- package/packages/datadog-plugin-jest/src/util.js +4 -3
- package/packages/datadog-plugin-kafkajs/src/consumer.js +2 -1
- package/packages/datadog-plugin-kafkajs/src/producer.js +3 -1
- package/packages/datadog-plugin-langchain/src/tracing.js +7 -3
- package/packages/datadog-plugin-next/src/index.js +11 -3
- package/packages/datadog-plugin-openai/src/stream-helpers.js +1 -1
- package/packages/datadog-shimmer/src/shimmer.js +2 -2
- package/packages/dd-trace/src/aiguard/sdk.js +29 -14
- package/packages/dd-trace/src/appsec/api_security_sampler.js +1 -1
- package/packages/dd-trace/src/appsec/iast/overhead-controller.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +1 -2
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +1 -1
- package/packages/dd-trace/src/appsec/reporter.js +0 -4
- package/packages/dd-trace/src/baggage.js +11 -0
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +4 -8
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +1 -1
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +4 -2
- package/packages/dd-trace/src/config.js +81 -7
- package/packages/dd-trace/src/config_defaults.js +15 -2
- package/packages/dd-trace/src/datastreams/encoding.js +23 -6
- package/packages/dd-trace/src/datastreams/pathway.js +40 -1
- package/packages/dd-trace/src/datastreams/processor.js +1 -1
- package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +15 -5
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/config.js +2 -0
- package/packages/dd-trace/src/debugger/devtools_client/index.js +30 -15
- package/packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js +2 -0
- package/packages/dd-trace/src/debugger/devtools_client/json-buffer.js +24 -18
- package/packages/dd-trace/src/debugger/devtools_client/send.js +18 -8
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +103 -15
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/constants.js +25 -0
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/index.js +56 -25
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +64 -23
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js +3 -1
- package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +404 -0
- package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/state.js +7 -2
- package/packages/dd-trace/src/debugger/devtools_client/status.js +1 -1
- package/packages/dd-trace/src/debugger/index.js +1 -1
- package/packages/dd-trace/src/encode/0.4.js +3 -3
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +2 -2
- package/packages/dd-trace/src/encode/span-stats.js +7 -1
- package/packages/dd-trace/src/exporters/agent/writer.js +6 -13
- package/packages/dd-trace/src/histogram.js +1 -1
- package/packages/dd-trace/src/id.js +60 -0
- package/packages/dd-trace/src/lambda/runtime/ritm.js +2 -3
- package/packages/dd-trace/src/llmobs/constants/tags.js +1 -0
- package/packages/dd-trace/src/llmobs/index.js +5 -5
- package/packages/dd-trace/src/llmobs/noop.js +6 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/index.js +1 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +104 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +486 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +2 -2
- package/packages/dd-trace/src/llmobs/plugins/{openai.js → openai/index.js} +87 -39
- package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +114 -0
- package/packages/dd-trace/src/llmobs/sdk.js +10 -1
- package/packages/dd-trace/src/llmobs/span_processor.js +11 -6
- package/packages/dd-trace/src/llmobs/tagger.js +35 -17
- package/packages/dd-trace/src/msgpack/chunk.js +2 -2
- package/packages/dd-trace/src/msgpack/encoder.js +2 -3
- package/packages/dd-trace/src/msgpack/index.js +2 -2
- package/packages/dd-trace/src/openfeature/flagging_provider.js +5 -3
- package/packages/dd-trace/src/opentelemetry/logs/index.js +3 -3
- package/packages/dd-trace/src/opentelemetry/logs/logger.js +14 -8
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +6 -4
- package/packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js +9 -17
- package/packages/dd-trace/src/opentelemetry/metrics/constants.js +34 -0
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +81 -0
- package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +225 -0
- package/packages/dd-trace/src/opentelemetry/metrics/meter.js +171 -0
- package/packages/dd-trace/src/opentelemetry/metrics/meter_provider.js +54 -0
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +62 -0
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_transformer.js +251 -0
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +532 -0
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +10 -18
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +36 -22
- package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +2 -2
- package/packages/dd-trace/src/opentelemetry/span.js +1 -1
- package/packages/dd-trace/src/opentelemetry/tracer.js +1 -1
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +1 -1
- package/packages/dd-trace/src/payload-tagging/index.js +2 -2
- package/packages/dd-trace/src/plugin_manager.js +4 -2
- package/packages/dd-trace/src/plugins/database.js +1 -0
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/dd-trace/src/plugins/plugin.js +7 -9
- package/packages/dd-trace/src/plugins/util/test.js +3 -3
- package/packages/dd-trace/src/plugins/util/url.js +119 -1
- package/packages/dd-trace/src/plugins/util/web.js +10 -41
- package/packages/dd-trace/src/process-tags/index.js +81 -0
- package/packages/dd-trace/src/profiling/config.js +1 -1
- package/packages/dd-trace/src/profiling/exporter_cli.js +7 -6
- package/packages/dd-trace/src/profiling/exporters/agent.js +1 -1
- package/packages/dd-trace/src/profiling/profilers/events.js +10 -1
- package/packages/dd-trace/src/proxy.js +5 -0
- package/packages/dd-trace/src/rate_limiter.js +1 -1
- package/packages/dd-trace/src/remote_config/manager.js +1 -1
- package/packages/dd-trace/src/require-package-json.js +1 -1
- package/packages/dd-trace/src/ritm.js +1 -1
- package/packages/dd-trace/src/service-naming/index.js +31 -4
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +4 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/web.js +4 -0
- package/packages/dd-trace/src/{format.js → span_format.js} +9 -4
- package/packages/dd-trace/src/span_processor.js +16 -11
- package/packages/dd-trace/src/span_stats.js +15 -4
- package/packages/dd-trace/src/spanleak.js +1 -1
- package/packages/dd-trace/src/supported-configurations.json +13 -0
- package/packages/dd-trace/src/telemetry/dependencies.js +1 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +11 -2
- package/vendor/dist/@datadog/sketches-js/LICENSE +39 -0
- package/vendor/dist/@datadog/sketches-js/index.js +1 -0
- package/vendor/dist/@datadog/source-map/LICENSE +28 -0
- package/vendor/dist/@datadog/source-map/index.js +1 -0
- package/vendor/dist/@isaacs/ttlcache/LICENSE +55 -0
- package/vendor/dist/@isaacs/ttlcache/index.js +1 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +201 -0
- package/vendor/dist/@opentelemetry/core/index.js +1 -0
- package/vendor/dist/@opentelemetry/resources/LICENSE +201 -0
- package/vendor/dist/@opentelemetry/resources/index.js +1 -0
- package/vendor/dist/astring/LICENSE +19 -0
- package/vendor/dist/astring/index.js +1 -0
- package/vendor/dist/crypto-randomuuid/index.js +1 -0
- package/vendor/dist/escape-string-regexp/LICENSE +9 -0
- package/vendor/dist/escape-string-regexp/index.js +1 -0
- package/vendor/dist/esquery/LICENSE +24 -0
- package/vendor/dist/esquery/index.js +1 -0
- package/vendor/dist/ignore/LICENSE +21 -0
- package/vendor/dist/ignore/index.js +1 -0
- package/vendor/dist/istanbul-lib-coverage/LICENSE +24 -0
- package/vendor/dist/istanbul-lib-coverage/index.js +1 -0
- package/vendor/dist/jest-docblock/LICENSE +21 -0
- package/vendor/dist/jest-docblock/index.js +1 -0
- package/vendor/dist/jsonpath-plus/LICENSE +22 -0
- package/vendor/dist/jsonpath-plus/index.js +1 -0
- package/vendor/dist/limiter/LICENSE +19 -0
- package/vendor/dist/limiter/index.js +1 -0
- package/vendor/dist/lodash.sortby/LICENSE +47 -0
- package/vendor/dist/lodash.sortby/index.js +1 -0
- package/vendor/dist/lru-cache/LICENSE +15 -0
- package/vendor/dist/lru-cache/index.js +1 -0
- package/vendor/dist/meriyah/LICENSE +7 -0
- package/vendor/dist/meriyah/index.js +1 -0
- package/vendor/dist/module-details-from-path/LICENSE +21 -0
- package/vendor/dist/module-details-from-path/index.js +1 -0
- package/vendor/dist/mutexify/promise/LICENSE +21 -0
- package/vendor/dist/mutexify/promise/index.js +1 -0
- package/vendor/dist/opentracing/LICENSE +201 -0
- package/vendor/dist/opentracing/binary_carrier.d.ts +11 -0
- package/vendor/dist/opentracing/constants.d.ts +61 -0
- package/vendor/dist/opentracing/examples/demo/demo.d.ts +2 -0
- package/vendor/dist/opentracing/ext/tags.d.ts +90 -0
- package/vendor/dist/opentracing/functions.d.ts +20 -0
- package/vendor/dist/opentracing/global_tracer.d.ts +14 -0
- package/vendor/dist/opentracing/index.d.ts +12 -0
- package/vendor/dist/opentracing/index.js +1 -0
- package/vendor/dist/opentracing/mock_tracer/index.d.ts +5 -0
- package/vendor/dist/opentracing/mock_tracer/mock_context.d.ts +13 -0
- package/vendor/dist/opentracing/mock_tracer/mock_report.d.ts +16 -0
- package/vendor/dist/opentracing/mock_tracer/mock_span.d.ts +50 -0
- package/vendor/dist/opentracing/mock_tracer/mock_tracer.d.ts +26 -0
- package/vendor/dist/opentracing/noop.d.ts +8 -0
- package/vendor/dist/opentracing/reference.d.ts +33 -0
- package/vendor/dist/opentracing/span.d.ts +147 -0
- package/vendor/dist/opentracing/span_context.d.ts +26 -0
- package/vendor/dist/opentracing/test/api_compatibility.d.ts +16 -0
- package/vendor/dist/opentracing/test/mocktracer_implemenation.d.ts +3 -0
- package/vendor/dist/opentracing/test/noop_implementation.d.ts +4 -0
- package/vendor/dist/opentracing/test/opentracing_api.d.ts +3 -0
- package/vendor/dist/opentracing/test/unittest.d.ts +2 -0
- package/vendor/dist/opentracing/tracer.d.ts +127 -0
- package/vendor/dist/path-to-regexp/LICENSE +21 -0
- package/vendor/dist/path-to-regexp/index.js +1 -0
- package/vendor/dist/pprof-format/LICENSE +8 -0
- package/vendor/dist/pprof-format/index.js +1 -0
- package/vendor/dist/protobufjs/LICENSE +39 -0
- package/vendor/dist/protobufjs/index.js +1 -0
- package/vendor/dist/protobufjs/minimal/LICENSE +39 -0
- package/vendor/dist/protobufjs/minimal/index.js +1 -0
- package/vendor/dist/retry/LICENSE +21 -0
- package/vendor/dist/retry/index.js +1 -0
- package/vendor/dist/rfdc/LICENSE +15 -0
- package/vendor/dist/rfdc/index.js +1 -0
- package/vendor/dist/semifies/LICENSE +201 -0
- package/vendor/dist/semifies/index.js +1 -0
- package/vendor/dist/shell-quote/LICENSE +24 -0
- package/vendor/dist/shell-quote/index.js +1 -0
- package/vendor/dist/source-map/LICENSE +28 -0
- package/vendor/dist/source-map/index.js +1 -0
- package/vendor/dist/source-map/lib/util/LICENSE +28 -0
- package/vendor/dist/source-map/lib/util/index.js +1 -0
- package/vendor/dist/source-map/mappings.wasm +0 -0
- package/vendor/dist/tlhunter-sorted-set/LICENSE +21 -0
- package/vendor/dist/tlhunter-sorted-set/index.js +1 -0
- package/vendor/dist/ttl-set/LICENSE +21 -0
- package/vendor/dist/ttl-set/index.js +1 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
This rewriter is basically a JavaScript version of Orchestrion-JS. The goal is
|
|
5
|
+
not to replace Orchestrion-JS, but rather to make it easier and faster to write
|
|
6
|
+
new integrations in the short-term, especially as many changes to the rewriter
|
|
7
|
+
will be needed as all the patterns we need have not been identified yet. This
|
|
8
|
+
will avoid the back and forth of having to make Rust changes to an external
|
|
9
|
+
library for every integration change or addition that requires something new.
|
|
10
|
+
|
|
11
|
+
In the meantime, we'll work concurrently on a change to Orchestrion-JS that
|
|
12
|
+
adds an "arbitrary transform" or "plugin" system that can be used from
|
|
13
|
+
JavaScript, in order to enable quick iteration while still using Orchestrion-JS.
|
|
14
|
+
Once that's done we'll use that, so that we can remove this JS approach and
|
|
15
|
+
return to using Orchestrion-JS.
|
|
16
|
+
|
|
17
|
+
The long term goal is to backport any additional features we add to the JS
|
|
18
|
+
rewriter (or using the plugin system in Orchestrion-JS once we're using that)
|
|
19
|
+
to Orchestrion-JS once we're confident that the implementation is fairly
|
|
20
|
+
complete and has all features we need.
|
|
21
|
+
|
|
22
|
+
Here is a list of the additions and changes in this rewriter compared to
|
|
23
|
+
Orchestrion-JS that will need to be backported:
|
|
24
|
+
|
|
25
|
+
(NOTE: Please keep this list up-to-date whenever new features are added)
|
|
26
|
+
|
|
27
|
+
- Supports an `astQuery` field to filter AST nodes with an esquery query. This
|
|
28
|
+
is mostly meant to be used when experimenting or if what needs to be queried
|
|
29
|
+
is not a function. We'll see over time if something like this is needed to be
|
|
30
|
+
backported or if it can be replaced by simpler queries.
|
|
31
|
+
- Supports replacing methods of child class instances in the base constructor.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
const { readFileSync } = require('fs')
|
|
35
|
+
const { join } = require('path')
|
|
36
|
+
const semifies = require('../../../../../vendor/dist/semifies')
|
|
37
|
+
const transforms = require('./transforms')
|
|
38
|
+
const { generate, parse, traverse } = require('./compiler')
|
|
39
|
+
const log = require('../../../../dd-trace/src/log')
|
|
40
|
+
const instrumentations = require('./instrumentations')
|
|
41
|
+
const { getEnvironmentVariable } = require('../../../../dd-trace/src/config-helper')
|
|
42
|
+
|
|
43
|
+
const NODE_OPTIONS = getEnvironmentVariable('NODE_OPTIONS')
|
|
44
|
+
|
|
45
|
+
const supported = {}
|
|
46
|
+
const disabled = new Set()
|
|
47
|
+
|
|
48
|
+
// TODO: Source maps without `--enable-source-maps`.
|
|
49
|
+
const enableSourceMaps = NODE_OPTIONS?.includes('--enable-source-maps') ||
|
|
50
|
+
process.execArgv?.some(arg => arg.includes('--enable-source-maps'))
|
|
51
|
+
|
|
52
|
+
let SourceMapGenerator
|
|
53
|
+
|
|
54
|
+
function rewrite (content, filename, format) {
|
|
55
|
+
if (!content) return content
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
let ast
|
|
59
|
+
|
|
60
|
+
filename = filename.replace('file://', '')
|
|
61
|
+
|
|
62
|
+
for (const inst of instrumentations) {
|
|
63
|
+
const { astQuery, functionQuery = {}, module: { name, versionRange, filePath } } = inst
|
|
64
|
+
const { kind } = functionQuery
|
|
65
|
+
const operator = kind === 'Async' ? 'tracePromise' : kind === 'Callback' ? 'traceCallback' : 'traceSync'
|
|
66
|
+
const transform = transforms[operator]
|
|
67
|
+
|
|
68
|
+
if (disabled.has(name)) continue
|
|
69
|
+
if (!filename.endsWith(`${name}/${filePath}`)) continue
|
|
70
|
+
if (!transform) continue
|
|
71
|
+
if (!satisfies(filename, filePath, versionRange)) continue
|
|
72
|
+
|
|
73
|
+
ast ??= parse(content.toString(), { loc: true, ranges: true, module: format === 'module' })
|
|
74
|
+
|
|
75
|
+
const query = astQuery || fromFunctionQuery(functionQuery)
|
|
76
|
+
const state = { ...inst, format, functionQuery, operator }
|
|
77
|
+
|
|
78
|
+
traverse(ast, query, (...args) => transform(state, ...args))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (ast) {
|
|
82
|
+
if (!enableSourceMaps) return generate(ast)
|
|
83
|
+
|
|
84
|
+
// TODO: Can we use the same version of `source-map` that DI uses?
|
|
85
|
+
SourceMapGenerator ??= require('../../../../../vendor/dist/@datadog/source-map').SourceMapGenerator
|
|
86
|
+
|
|
87
|
+
const sourceMap = new SourceMapGenerator({ file: filename })
|
|
88
|
+
const code = generate(ast, { sourceMap })
|
|
89
|
+
const map = Buffer.from(sourceMap.toString()).toString('base64')
|
|
90
|
+
|
|
91
|
+
return code + '\n' + `//# sourceMappingURL=data:application/json;base64,${map}`
|
|
92
|
+
}
|
|
93
|
+
} catch (e) {
|
|
94
|
+
log.error(e)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return content
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function disable (instrumentation) {
|
|
101
|
+
disabled.add(instrumentation)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function satisfies (filename, filePath, versions) {
|
|
105
|
+
const [basename] = filename.split(filePath)
|
|
106
|
+
|
|
107
|
+
if (supported[basename] === undefined) {
|
|
108
|
+
try {
|
|
109
|
+
const pkg = JSON.parse(readFileSync(
|
|
110
|
+
join(basename, 'package.json'), 'utf8'
|
|
111
|
+
))
|
|
112
|
+
|
|
113
|
+
supported[basename] = semifies(pkg.version, versions)
|
|
114
|
+
} catch {
|
|
115
|
+
supported[basename] = false
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return supported[basename]
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// TODO: Support index
|
|
123
|
+
function fromFunctionQuery (functionQuery) {
|
|
124
|
+
const { methodName, functionName, expressionName, className } = functionQuery
|
|
125
|
+
const queries = []
|
|
126
|
+
|
|
127
|
+
if (className) {
|
|
128
|
+
queries.push(
|
|
129
|
+
`[id.name="${className}"]`,
|
|
130
|
+
`[id.name="${className}"] > ClassBody > [key.name="${methodName}"] > [async]`,
|
|
131
|
+
`[id.name="${className}"] > ClassExpression > ClassBody > [key.name="${methodName}"] > [async]`
|
|
132
|
+
)
|
|
133
|
+
} else if (methodName) {
|
|
134
|
+
queries.push(
|
|
135
|
+
`ClassBody > [key.name="${methodName}"] > [async]`,
|
|
136
|
+
`Property[key.name="${methodName}"] > [async]`
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (functionName) {
|
|
141
|
+
queries.push(`FunctionDeclaration[id.name="${functionName}"][async]`)
|
|
142
|
+
} else if (expressionName) {
|
|
143
|
+
queries.push(
|
|
144
|
+
`FunctionExpression[id.name="${expressionName}"][async]`,
|
|
145
|
+
`ArrowFunctionExpression[id.name="${expressionName}"][async]`
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return queries.join(', ')
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
module.exports = { rewrite, disable }
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
module.exports = [
|
|
4
|
+
{
|
|
5
|
+
module: {
|
|
6
|
+
name: '@langchain/core',
|
|
7
|
+
versionRange: '>=0.1',
|
|
8
|
+
filePath: 'dist/runnables/base.cjs'
|
|
9
|
+
},
|
|
10
|
+
functionQuery: {
|
|
11
|
+
methodName: 'invoke',
|
|
12
|
+
kind: 'Async',
|
|
13
|
+
className: 'RunnableSequence'
|
|
14
|
+
},
|
|
15
|
+
channelName: 'RunnableSequence_invoke'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
module: {
|
|
19
|
+
name: '@langchain/core',
|
|
20
|
+
versionRange: '>=0.1',
|
|
21
|
+
filePath: 'dist/runnables/base.cjs'
|
|
22
|
+
},
|
|
23
|
+
functionQuery: {
|
|
24
|
+
methodName: 'batch',
|
|
25
|
+
kind: 'Async',
|
|
26
|
+
className: 'RunnableSequence'
|
|
27
|
+
},
|
|
28
|
+
channelName: 'RunnableSequence_batch'
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
module: {
|
|
32
|
+
name: '@langchain/core',
|
|
33
|
+
versionRange: '>=0.1',
|
|
34
|
+
filePath: 'dist/language_models/chat_models.cjs'
|
|
35
|
+
},
|
|
36
|
+
functionQuery: {
|
|
37
|
+
methodName: 'generate',
|
|
38
|
+
kind: 'Async',
|
|
39
|
+
className: 'BaseChatModel'
|
|
40
|
+
},
|
|
41
|
+
channelName: 'BaseChatModel_generate'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
module: {
|
|
45
|
+
name: '@langchain/core',
|
|
46
|
+
versionRange: '>=0.1',
|
|
47
|
+
filePath: 'dist/language_models/llms.cjs'
|
|
48
|
+
},
|
|
49
|
+
functionQuery: {
|
|
50
|
+
methodName: 'generate',
|
|
51
|
+
kind: 'Async'
|
|
52
|
+
},
|
|
53
|
+
channelName: 'BaseLLM_generate'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
module: {
|
|
57
|
+
name: '@langchain/core',
|
|
58
|
+
versionRange: '>=0.1',
|
|
59
|
+
filePath: 'dist/embeddings.cjs'
|
|
60
|
+
},
|
|
61
|
+
functionQuery: {
|
|
62
|
+
methodName: 'embedQuery',
|
|
63
|
+
kind: 'Async',
|
|
64
|
+
className: 'Embeddings'
|
|
65
|
+
},
|
|
66
|
+
channelName: 'Embeddings_embedQuery'
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
module: {
|
|
70
|
+
name: '@langchain/core',
|
|
71
|
+
versionRange: '>=0.1',
|
|
72
|
+
filePath: 'dist/embeddings.cjs'
|
|
73
|
+
},
|
|
74
|
+
functionQuery: {
|
|
75
|
+
methodName: 'embedDocuments',
|
|
76
|
+
kind: 'Async',
|
|
77
|
+
className: 'Embeddings'
|
|
78
|
+
},
|
|
79
|
+
channelName: 'Embeddings_embedDocuments'
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
module: {
|
|
83
|
+
name: '@langchain/core',
|
|
84
|
+
versionRange: '>=0.1',
|
|
85
|
+
filePath: 'dist/tools/index.cjs'
|
|
86
|
+
},
|
|
87
|
+
functionQuery: {
|
|
88
|
+
methodName: 'invoke',
|
|
89
|
+
kind: 'Async',
|
|
90
|
+
className: 'StructuredTool'
|
|
91
|
+
},
|
|
92
|
+
channelName: 'Tool_invoke'
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
module: {
|
|
96
|
+
name: '@langchain/core',
|
|
97
|
+
versionRange: '>=0.1',
|
|
98
|
+
filePath: 'dist/vectorstores.cjs'
|
|
99
|
+
},
|
|
100
|
+
functionQuery: {
|
|
101
|
+
methodName: 'similaritySearch',
|
|
102
|
+
kind: 'Async',
|
|
103
|
+
className: 'VectorStore'
|
|
104
|
+
},
|
|
105
|
+
channelName: 'VectorStore_similaritySearch'
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
module: {
|
|
109
|
+
name: '@langchain/core',
|
|
110
|
+
versionRange: '>=0.1',
|
|
111
|
+
filePath: 'dist/vectorstores.cjs'
|
|
112
|
+
},
|
|
113
|
+
functionQuery: {
|
|
114
|
+
methodName: 'similaritySearchWithScore',
|
|
115
|
+
kind: 'Async',
|
|
116
|
+
className: 'VectorStore'
|
|
117
|
+
},
|
|
118
|
+
channelName: 'VectorStore_similaritySearchWithScore'
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
module: {
|
|
122
|
+
name: '@langchain/core',
|
|
123
|
+
versionRange: '>=0.1',
|
|
124
|
+
filePath: 'dist/runnables/base.js'
|
|
125
|
+
},
|
|
126
|
+
functionQuery: {
|
|
127
|
+
methodName: 'invoke',
|
|
128
|
+
kind: 'Async',
|
|
129
|
+
className: 'RunnableSequence'
|
|
130
|
+
},
|
|
131
|
+
channelName: 'RunnableSequence_invoke'
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
module: {
|
|
135
|
+
name: '@langchain/core',
|
|
136
|
+
versionRange: '>=0.1',
|
|
137
|
+
filePath: 'dist/runnables/base.js'
|
|
138
|
+
},
|
|
139
|
+
functionQuery: {
|
|
140
|
+
methodName: 'batch',
|
|
141
|
+
kind: 'Async',
|
|
142
|
+
className: 'RunnableSequence'
|
|
143
|
+
},
|
|
144
|
+
channelName: 'RunnableSequence_batch'
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
module: {
|
|
148
|
+
name: '@langchain/core',
|
|
149
|
+
versionRange: '>=0.1',
|
|
150
|
+
filePath: 'dist/language_models/chat_models.js'
|
|
151
|
+
},
|
|
152
|
+
functionQuery: {
|
|
153
|
+
methodName: 'generate',
|
|
154
|
+
kind: 'Async',
|
|
155
|
+
className: 'BaseChatModel'
|
|
156
|
+
},
|
|
157
|
+
channelName: 'BaseChatModel_generate'
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
module: {
|
|
161
|
+
name: '@langchain/core',
|
|
162
|
+
versionRange: '>=0.1',
|
|
163
|
+
filePath: 'dist/language_models/llms.js'
|
|
164
|
+
},
|
|
165
|
+
functionQuery: {
|
|
166
|
+
methodName: 'generate',
|
|
167
|
+
kind: 'Async'
|
|
168
|
+
},
|
|
169
|
+
channelName: 'BaseLLM_generate'
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
module: {
|
|
173
|
+
name: '@langchain/core',
|
|
174
|
+
versionRange: '>=0.1',
|
|
175
|
+
filePath: 'dist/embeddings.js'
|
|
176
|
+
},
|
|
177
|
+
functionQuery: {
|
|
178
|
+
methodName: 'embedQuery',
|
|
179
|
+
kind: 'Async',
|
|
180
|
+
className: 'Embeddings'
|
|
181
|
+
},
|
|
182
|
+
channelName: 'Embeddings_embedQuery'
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
module: {
|
|
186
|
+
name: '@langchain/core',
|
|
187
|
+
versionRange: '>=0.1',
|
|
188
|
+
filePath: 'dist/embeddings.js'
|
|
189
|
+
},
|
|
190
|
+
functionQuery: {
|
|
191
|
+
methodName: 'embedDocuments',
|
|
192
|
+
kind: 'Async',
|
|
193
|
+
className: 'Embeddings'
|
|
194
|
+
},
|
|
195
|
+
channelName: 'Embeddings_embedDocuments'
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
module: {
|
|
199
|
+
name: '@langchain/core',
|
|
200
|
+
versionRange: '>=0.1',
|
|
201
|
+
filePath: 'dist/tools/index.js'
|
|
202
|
+
},
|
|
203
|
+
functionQuery: {
|
|
204
|
+
methodName: 'invoke',
|
|
205
|
+
kind: 'Async',
|
|
206
|
+
className: 'StructuredTool'
|
|
207
|
+
},
|
|
208
|
+
channelName: 'Tool_invoke'
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
module: {
|
|
212
|
+
name: '@langchain/core',
|
|
213
|
+
versionRange: '>=0.1',
|
|
214
|
+
filePath: 'dist/vectorstores.js'
|
|
215
|
+
},
|
|
216
|
+
functionQuery: {
|
|
217
|
+
methodName: 'similaritySearch',
|
|
218
|
+
kind: 'Async',
|
|
219
|
+
className: 'VectorStore'
|
|
220
|
+
},
|
|
221
|
+
channelName: 'VectorStore_similaritySearch'
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
|
|
225
|
+
module: {
|
|
226
|
+
name: '@langchain/core',
|
|
227
|
+
versionRange: '>=0.1',
|
|
228
|
+
filePath: 'dist/vectorstores.js'
|
|
229
|
+
},
|
|
230
|
+
functionQuery: {
|
|
231
|
+
methodName: 'similaritySearchWithScore',
|
|
232
|
+
kind: 'Async',
|
|
233
|
+
className: 'VectorStore'
|
|
234
|
+
},
|
|
235
|
+
channelName: 'VectorStore_similaritySearchWithScore'
|
|
236
|
+
}
|
|
237
|
+
]
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const Module = require('module')
|
|
4
|
+
const shimmer = require('../../../../datadog-shimmer')
|
|
5
|
+
const { rewrite } = require('./')
|
|
6
|
+
|
|
7
|
+
shimmer.wrap(Module.prototype, '_compile', compile => function (content, filename, format) {
|
|
8
|
+
return compile.call(this, rewrite(content, filename, format), filename, format)
|
|
9
|
+
})
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { parse } = require('./compiler')
|
|
4
|
+
|
|
5
|
+
const tracingChannelPredicate = (node) => (
|
|
6
|
+
node.specifiers?.[0]?.local?.name === 'tr_ch_apm_tracingChannel' ||
|
|
7
|
+
node.declarations?.[0]?.id?.properties?.[0]?.value?.name === 'tr_ch_apm_tracingChannel'
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
const transforms = module.exports = {
|
|
11
|
+
tracingChannelImport ({ format }, node) {
|
|
12
|
+
if (node.body.some(tracingChannelPredicate)) return
|
|
13
|
+
|
|
14
|
+
const index = node.body.findIndex(child => child.directive === 'use strict')
|
|
15
|
+
const code = format === 'module'
|
|
16
|
+
? 'import { tracingChannel as tr_ch_apm_tracingChannel } from "diagnostics_channel"'
|
|
17
|
+
: 'const {tracingChannel: tr_ch_apm_tracingChannel} = require("diagnostics_channel")'
|
|
18
|
+
|
|
19
|
+
node.body.splice(index + 1, 0, parse(code, { module: format === 'module' }).body[0])
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
tracingChannelDeclaration (state, node) {
|
|
23
|
+
const { channelName, module: { name } } = state
|
|
24
|
+
const channelVariable = 'tr_ch_apm$' + channelName.replaceAll(':', '_')
|
|
25
|
+
|
|
26
|
+
if (node.body.some(child => child.declarations?.[0]?.id?.name === channelVariable)) return
|
|
27
|
+
|
|
28
|
+
transforms.tracingChannelImport(state, node)
|
|
29
|
+
|
|
30
|
+
const index = node.body.findIndex(tracingChannelPredicate)
|
|
31
|
+
const code = `
|
|
32
|
+
const ${channelVariable} = tr_ch_apm_tracingChannel("orchestrion:${name}:${channelName}")
|
|
33
|
+
`
|
|
34
|
+
|
|
35
|
+
node.body.splice(index + 1, 0, parse(code).body[0])
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
traceCallback: traceAny,
|
|
39
|
+
tracePromise: traceAny,
|
|
40
|
+
traceSync: traceAny,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function traceAny (state, node, _parent, ancestry) {
|
|
44
|
+
const program = ancestry[ancestry.length - 1]
|
|
45
|
+
|
|
46
|
+
if (node.type === 'ClassDeclaration' || node.type === 'ClassExpression') {
|
|
47
|
+
traceInstanceMethod(state, node, program)
|
|
48
|
+
} else {
|
|
49
|
+
traceFunction(state, node, program)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function traceFunction (state, node, program) {
|
|
54
|
+
const { operator } = state
|
|
55
|
+
|
|
56
|
+
transforms.tracingChannelDeclaration(state, program)
|
|
57
|
+
|
|
58
|
+
node.body = wrap(state, {
|
|
59
|
+
type: 'ArrowFunctionExpression',
|
|
60
|
+
params: node.params,
|
|
61
|
+
body: node.body,
|
|
62
|
+
async: operator === 'tracePromise',
|
|
63
|
+
expression: false,
|
|
64
|
+
generator: false
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function traceInstanceMethod (state, node, program) {
|
|
69
|
+
const { functionQuery, operator } = state
|
|
70
|
+
const { methodName } = functionQuery
|
|
71
|
+
|
|
72
|
+
const classBody = node.body
|
|
73
|
+
|
|
74
|
+
// If the method exists on the class, we return as it will be patched later
|
|
75
|
+
// while traversing child nodes later on.
|
|
76
|
+
if (classBody.body.some(({ key }) => key.name === methodName)) return
|
|
77
|
+
|
|
78
|
+
// Method doesn't exist on the class so we assume an instance method and
|
|
79
|
+
// wrap it in the constructor instead.
|
|
80
|
+
let ctor = classBody.body.find(({ kind }) => kind === 'constructor')
|
|
81
|
+
|
|
82
|
+
transforms.tracingChannelDeclaration(state, program)
|
|
83
|
+
|
|
84
|
+
if (!ctor) {
|
|
85
|
+
ctor = parse(
|
|
86
|
+
node.superClass
|
|
87
|
+
? 'class A { constructor (...args) { super(...args) } }'
|
|
88
|
+
: 'class A { constructor () {} }'
|
|
89
|
+
).body[0].body.body[0] // Extract constructor from dummy class body.
|
|
90
|
+
|
|
91
|
+
classBody.body.unshift(ctor)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const ctorBody = parse(`
|
|
95
|
+
const __apm$${methodName} = this["${methodName}"]
|
|
96
|
+
this["${methodName}"] = function () {}
|
|
97
|
+
`).body
|
|
98
|
+
|
|
99
|
+
// Extract only right-hand side function of line 2.
|
|
100
|
+
const fn = ctorBody[1].expression.right
|
|
101
|
+
|
|
102
|
+
fn.async = operator === 'tracePromise'
|
|
103
|
+
fn.body = wrap(state, { type: 'Identifier', name: `__apm$${methodName}` })
|
|
104
|
+
|
|
105
|
+
ctor.value.body.body.push(...ctorBody)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function wrap (state, node) {
|
|
109
|
+
const { channelName, operator, functionQuery: { index = -1 } } = state
|
|
110
|
+
const async = operator === 'tracePromise' ? 'async' : ''
|
|
111
|
+
const channelVariable = 'tr_ch_apm$' + channelName.replaceAll(':', '_')
|
|
112
|
+
const tracedArgs = operator === 'traceCallback'
|
|
113
|
+
? `__apm$original_args.splice(${index}, 1, arguments[${index >= 0 ? index : `arguments.length + ${index}`}])`
|
|
114
|
+
: '__apm$original_args'
|
|
115
|
+
const traceParams = operator === 'traceCallback'
|
|
116
|
+
? `__apm$traced, ${index}`
|
|
117
|
+
: '__apm$traced'
|
|
118
|
+
const wrapper = parse(`
|
|
119
|
+
function wrapper () {
|
|
120
|
+
const __apm$original_args = arguments;
|
|
121
|
+
const __apm$traced = ${async} function () {
|
|
122
|
+
const __apm$wrapped = () => {};
|
|
123
|
+
const __apm$traced_args = ${tracedArgs};
|
|
124
|
+
return __apm$wrapped.apply(this, __apm$traced_args);
|
|
125
|
+
};
|
|
126
|
+
if (!${channelVariable}.hasSubscribers) return __apm$traced.apply(this, arguments);
|
|
127
|
+
return ${channelVariable}.${operator}(${traceParams}, {
|
|
128
|
+
arguments,
|
|
129
|
+
self: this,
|
|
130
|
+
moduleVersion: "1.0.0"
|
|
131
|
+
}, this, ...arguments);
|
|
132
|
+
}
|
|
133
|
+
`).body[0].body // Extract only block statement of function body.
|
|
134
|
+
|
|
135
|
+
// Replace the right-hand side assignment of `const __apm$wrapped = () => {}`.
|
|
136
|
+
wrapper.body[1].declarations[0].init.body.body[0].declarations[0].init = node
|
|
137
|
+
|
|
138
|
+
return wrapper
|
|
139
|
+
}
|
|
@@ -1110,7 +1110,7 @@ function jestAdapterWrapper (jestAdapter, jestVersion) {
|
|
|
1110
1110
|
* Child processes do not each request ITR configuration, so the jest's parent process
|
|
1111
1111
|
* needs to pass them the configuration. This is done via _ddTestCodeCoverageEnabled, which
|
|
1112
1112
|
* controls whether coverage is reported.
|
|
1113
|
-
|
|
1113
|
+
*/
|
|
1114
1114
|
if (environment.testEnvironmentOptions?._ddTestCodeCoverageEnabled) {
|
|
1115
1115
|
const root = environment.repositoryRoot || environment.rootDir
|
|
1116
1116
|
|
|
@@ -1,113 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
-
const { addHook } = require('./helpers/instrument')
|
|
3
2
|
|
|
4
|
-
const
|
|
3
|
+
const { addHook, getHooks } = require('./helpers/instrument')
|
|
5
4
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
function wrap (obj, name, channelName, namespace) {
|
|
9
|
-
const channel = tracingChannel(channelName)
|
|
10
|
-
shimmer.wrap(obj, name, function (original) {
|
|
11
|
-
return function () {
|
|
12
|
-
if (!channel.start.hasSubscribers) {
|
|
13
|
-
return original.apply(this, arguments)
|
|
14
|
-
}
|
|
15
|
-
const ctx = { self: this, arguments }
|
|
16
|
-
if (namespace) {
|
|
17
|
-
ctx.namespace = namespace
|
|
18
|
-
}
|
|
19
|
-
return channel.tracePromise(original, ctx, this, ...arguments)
|
|
20
|
-
}
|
|
21
|
-
})
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// langchain compiles into ESM and CommonJS, with ESM being the default and landing in the `.js` files
|
|
25
|
-
// however, CommonJS ends up in `cjs` files, and are required under the hood with `.cjs` files
|
|
26
|
-
// we patch each separately and explicitly to match against exports only once, and not rely on file regex matching
|
|
27
|
-
const extensions = ['js', 'cjs']
|
|
28
|
-
|
|
29
|
-
for (const extension of extensions) {
|
|
30
|
-
addHook({ name: '@langchain/core', file: `dist/runnables/base.${extension}`, versions: ['>=0.1'] }, exports => {
|
|
31
|
-
if (extension === 'cjs') {
|
|
32
|
-
wrap(exports.RunnableSequence.prototype, 'invoke', 'orchestrion:@langchain/core:RunnableSequence_invoke')
|
|
33
|
-
wrap(exports.RunnableSequence.prototype, 'batch', 'orchestrion:@langchain/core:RunnableSequence_batch')
|
|
34
|
-
}
|
|
35
|
-
return exports
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
addHook({
|
|
39
|
-
name: '@langchain/core',
|
|
40
|
-
file: `dist/language_models/chat_models.${extension}`,
|
|
41
|
-
versions: ['>=0.1']
|
|
42
|
-
}, exports => {
|
|
43
|
-
if (extension === 'cjs') {
|
|
44
|
-
wrap(exports.BaseChatModel.prototype, 'generate', 'orchestrion:@langchain/core:BaseChatModel_generate')
|
|
45
|
-
}
|
|
46
|
-
return exports
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
addHook({ name: '@langchain/core', file: `dist/language_models/llms.${extension}`, versions: ['>=0.1'] }, exports => {
|
|
50
|
-
if (extension === 'cjs') {
|
|
51
|
-
wrap(exports.BaseLLM.prototype, 'generate', 'orchestrion:@langchain/core:BaseLLM_generate')
|
|
52
|
-
}
|
|
53
|
-
return exports
|
|
54
|
-
})
|
|
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
|
-
|
|
77
|
-
addHook({ name: '@langchain/core', file: `dist/embeddings.${extension}`, versions: ['>=0.1'] }, exports => {
|
|
78
|
-
if (extension === 'cjs') {
|
|
79
|
-
shimmer.wrap(exports, 'Embeddings', Embeddings => {
|
|
80
|
-
return class extends Embeddings {
|
|
81
|
-
constructor (...args) {
|
|
82
|
-
super(...args)
|
|
83
|
-
|
|
84
|
-
const namespace = ['langchain', 'embeddings']
|
|
85
|
-
|
|
86
|
-
if (this.constructor.name === 'OpenAIEmbeddings') {
|
|
87
|
-
namespace.push('openai')
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
wrap(this, 'embedQuery', 'apm:@langchain/core:Embeddings_embedQuery', namespace)
|
|
91
|
-
wrap(this, 'embedDocuments', 'apm:@langchain/core:Embeddings_embedDocuments', namespace)
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
})
|
|
95
|
-
} else {
|
|
96
|
-
const channel = tracingChannel('orchestrion:@langchain/core:Embeddings_constructor')
|
|
97
|
-
channel.subscribe({
|
|
98
|
-
end (ctx) {
|
|
99
|
-
const { self } = ctx
|
|
100
|
-
const namespace = ['langchain', 'embeddings']
|
|
101
|
-
|
|
102
|
-
if (self.constructor.name === 'OpenAIEmbeddings') {
|
|
103
|
-
namespace.push('openai')
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
wrap(self, 'embedQuery', 'apm:@langchain/core:Embeddings_embedQuery', namespace)
|
|
107
|
-
wrap(self, 'embedDocuments', 'apm:@langchain/core:Embeddings_embedDocuments', namespace)
|
|
108
|
-
}
|
|
109
|
-
})
|
|
110
|
-
}
|
|
111
|
-
return exports
|
|
112
|
-
})
|
|
5
|
+
for (const hook of getHooks('@langchain/core')) {
|
|
6
|
+
addHook(hook, exports => exports)
|
|
113
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { createCoverageMap } = require('istanbul-lib-coverage')
|
|
3
|
+
const { createCoverageMap } = require('../../../../vendor/dist/istanbul-lib-coverage')
|
|
4
4
|
const { addHook, channel } = require('../helpers/instrument')
|
|
5
5
|
const shimmer = require('../../../datadog-shimmer')
|
|
6
6
|
const { isMarkedAsUnskippable } = require('../../../datadog-plugin-jest/src/util')
|