braintrust 3.7.0 → 3.8.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 +201 -0
- package/dev/dist/index.d.mts +144 -2
- package/dev/dist/index.d.ts +144 -2
- package/dev/dist/index.js +3322 -799
- package/dev/dist/index.mjs +3214 -691
- package/dist/auto-instrumentations/bundler/esbuild.cjs +377 -13
- package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
- package/dist/auto-instrumentations/bundler/rollup.cjs +377 -13
- package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
- package/dist/auto-instrumentations/bundler/vite.cjs +377 -13
- package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +377 -13
- package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +11 -9
- package/dist/auto-instrumentations/bundler/webpack.cjs +377 -13
- package/dist/auto-instrumentations/bundler/webpack.mjs +2 -2
- package/dist/auto-instrumentations/{chunk-EVUKFMHG.mjs → chunk-ITP7RAUY.mjs} +21 -3
- package/dist/auto-instrumentations/{chunk-ZK2IYER2.mjs → chunk-MD7W27YH.mjs} +5 -1
- package/dist/auto-instrumentations/{chunk-AKEXR4AL.mjs → chunk-OLBMPZXE.mjs} +378 -14
- package/dist/auto-instrumentations/{chunk-VLEJ5AEK.mjs → chunk-P5YLNB2A.mjs} +21 -3
- package/dist/auto-instrumentations/hook.mjs +393 -19
- package/dist/auto-instrumentations/index.cjs +379 -13
- package/dist/auto-instrumentations/index.d.mts +5 -1
- package/dist/auto-instrumentations/index.d.ts +5 -1
- package/dist/auto-instrumentations/index.mjs +5 -1
- package/dist/auto-instrumentations/loader/cjs-patch.cjs +34 -6
- package/dist/auto-instrumentations/loader/cjs-patch.d.mts +1 -0
- package/dist/auto-instrumentations/loader/cjs-patch.d.ts +1 -0
- package/dist/auto-instrumentations/loader/cjs-patch.mjs +15 -5
- package/dist/auto-instrumentations/loader/esm-hook.mjs +8 -3
- package/dist/auto-instrumentations/loader/get-package-version.cjs +20 -2
- package/dist/auto-instrumentations/loader/get-package-version.mjs +1 -1
- package/dist/browser.d.mts +199 -44
- package/dist/browser.d.ts +199 -44
- package/dist/browser.js +7086 -6747
- package/dist/browser.mjs +7086 -6747
- package/dist/cli.js +3200 -677
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +12645 -12215
- package/dist/edge-light.mjs +12645 -12215
- package/dist/index.d.mts +199 -44
- package/dist/index.d.ts +199 -44
- package/dist/index.js +7173 -6834
- package/dist/index.mjs +7022 -6683
- package/dist/instrumentation/index.d.mts +7 -0
- package/dist/instrumentation/index.d.ts +7 -0
- package/dist/instrumentation/index.js +3170 -669
- package/dist/instrumentation/index.mjs +3170 -669
- package/dist/workerd.d.mts +1 -1
- package/dist/workerd.d.ts +1 -1
- package/dist/workerd.js +12645 -12215
- package/dist/workerd.mjs +12645 -12215
- package/package.json +45 -45
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getPackageName,
|
|
3
3
|
getPackageVersion
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-P5YLNB2A.mjs";
|
|
5
5
|
|
|
6
6
|
// src/auto-instrumentations/loader/cjs-patch.ts
|
|
7
7
|
import {
|
|
8
8
|
create
|
|
9
9
|
} from "@apm-js-collab/code-transformer";
|
|
10
|
-
import * as
|
|
10
|
+
import * as NodeModule from "module";
|
|
11
11
|
import { sep } from "path";
|
|
12
12
|
import moduleDetailsFromPath from "module-details-from-path";
|
|
13
13
|
var ModulePatch = class {
|
|
14
14
|
packages;
|
|
15
15
|
instrumentator;
|
|
16
|
+
modulePrototype;
|
|
16
17
|
originalCompile;
|
|
17
18
|
constructor({
|
|
18
19
|
instrumentations = []
|
|
19
20
|
} = {}) {
|
|
21
|
+
const modulePrototype = resolveModulePrototype();
|
|
20
22
|
this.packages = new Set(instrumentations.map((i) => i.module.name));
|
|
21
23
|
this.instrumentator = create(instrumentations);
|
|
22
|
-
this.
|
|
24
|
+
this.modulePrototype = modulePrototype;
|
|
25
|
+
this.originalCompile = modulePrototype._compile;
|
|
23
26
|
}
|
|
24
27
|
/**
|
|
25
28
|
* Patches the Node.js module class method that is responsible for compiling code.
|
|
@@ -28,7 +31,7 @@ var ModulePatch = class {
|
|
|
28
31
|
*/
|
|
29
32
|
patch() {
|
|
30
33
|
const self = this;
|
|
31
|
-
|
|
34
|
+
this.modulePrototype._compile = function wrappedCompile(...args) {
|
|
32
35
|
const [content, filename] = args;
|
|
33
36
|
const normalizedForPlatform = filename.split("/").join(sep);
|
|
34
37
|
const resolvedModule = moduleDetailsFromPath(normalizedForPlatform);
|
|
@@ -63,9 +66,16 @@ var ModulePatch = class {
|
|
|
63
66
|
* **Note**: This is intended to be used in testing only.
|
|
64
67
|
*/
|
|
65
68
|
unpatch() {
|
|
66
|
-
|
|
69
|
+
this.modulePrototype._compile = this.originalCompile;
|
|
67
70
|
}
|
|
68
71
|
};
|
|
72
|
+
function resolveModulePrototype() {
|
|
73
|
+
const moduleCtor = NodeModule.Module;
|
|
74
|
+
if (moduleCtor && typeof moduleCtor === "function") {
|
|
75
|
+
return moduleCtor.prototype;
|
|
76
|
+
}
|
|
77
|
+
return NodeModule.prototype;
|
|
78
|
+
}
|
|
69
79
|
export {
|
|
70
80
|
ModulePatch
|
|
71
81
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
getPackageName,
|
|
2
3
|
getPackageVersion
|
|
3
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-ITP7RAUY.mjs";
|
|
4
5
|
|
|
5
6
|
// src/auto-instrumentations/loader/esm-hook.mts
|
|
6
7
|
import { readFile } from "fs/promises";
|
|
@@ -23,11 +24,15 @@ async function resolve(specifier, context, nextResolve) {
|
|
|
23
24
|
const filePath = url.url.startsWith("file:") ? fileURLToPath(url.url) : url.url;
|
|
24
25
|
const normalizedForPlatform = filePath.split("/").join(sep);
|
|
25
26
|
const resolvedModule = moduleDetailsFromPath(normalizedForPlatform);
|
|
26
|
-
if (resolvedModule
|
|
27
|
+
if (resolvedModule) {
|
|
28
|
+
const packageName = getPackageName(resolvedModule.basedir) ?? resolvedModule.name;
|
|
29
|
+
if (!packages?.has(packageName)) {
|
|
30
|
+
return url;
|
|
31
|
+
}
|
|
27
32
|
const version = getPackageVersion(resolvedModule.basedir);
|
|
28
33
|
const normalizedModulePath = resolvedModule.path.replace(/\\/g, "/");
|
|
29
34
|
const transformer = instrumentator.getTransformer(
|
|
30
|
-
|
|
35
|
+
packageName,
|
|
31
36
|
version,
|
|
32
37
|
normalizedModulePath
|
|
33
38
|
);
|
|
@@ -37,11 +37,29 @@ function readPackageJson(baseDir) {
|
|
|
37
37
|
return void 0;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
function resolvePackageBaseDir(baseDir) {
|
|
41
|
+
try {
|
|
42
|
+
return (0, import_node_fs.realpathSync)(baseDir);
|
|
43
|
+
} catch {
|
|
44
|
+
return baseDir;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function readPackageJsonWithFallback(baseDir) {
|
|
48
|
+
const packageJson = readPackageJson(baseDir);
|
|
49
|
+
if (packageJson) {
|
|
50
|
+
return packageJson;
|
|
51
|
+
}
|
|
52
|
+
const resolvedBaseDir = resolvePackageBaseDir(baseDir);
|
|
53
|
+
if (resolvedBaseDir === baseDir) {
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
return readPackageJson(resolvedBaseDir);
|
|
57
|
+
}
|
|
40
58
|
function getPackageVersion(baseDir) {
|
|
41
59
|
if (packageVersions.has(baseDir)) {
|
|
42
60
|
return packageVersions.get(baseDir);
|
|
43
61
|
}
|
|
44
|
-
const packageJson =
|
|
62
|
+
const packageJson = readPackageJsonWithFallback(baseDir);
|
|
45
63
|
if (typeof packageJson?.version === "string") {
|
|
46
64
|
packageVersions.set(baseDir, packageJson.version);
|
|
47
65
|
return packageJson.version;
|
|
@@ -52,7 +70,7 @@ function getPackageName(baseDir) {
|
|
|
52
70
|
if (packageNames.has(baseDir)) {
|
|
53
71
|
return packageNames.get(baseDir);
|
|
54
72
|
}
|
|
55
|
-
const packageJson =
|
|
73
|
+
const packageJson = readPackageJsonWithFallback(baseDir);
|
|
56
74
|
if (typeof packageJson?.name === "string") {
|
|
57
75
|
packageNames.set(baseDir, packageJson.name);
|
|
58
76
|
return packageJson.name;
|