@alwaysmeticulous/backend-recorder-launcher 2.277.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 +78 -0
- package/dist/auto-init.d.ts +1 -0
- package/dist/auto-init.js +14 -0
- package/dist/auto-init.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Backend Recorder Launcher
|
|
2
|
+
|
|
3
|
+
Downloads the backend-recorder bundle script and executes it. The backend recorder intercepts HTTP requests/responses in Node.js apps using OpenTelemetry and exports spans to Meticulous.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @alwaysmeticulous/backend-recorder-launcher
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Option 1: Using `instrumentation.js` (recommended)
|
|
12
|
+
|
|
13
|
+
Create or update your `instrumentation.js` (or `instrumentation.ts`) file at the root of your project:
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
const { initBackendRecorder } = require("@alwaysmeticulous/backend-recorder-launcher");
|
|
17
|
+
|
|
18
|
+
initBackendRecorder({
|
|
19
|
+
recordingToken: process.env.METICULOUS_RECORDING_TOKEN,
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Then start your app with the `--require` flag so the recorder is loaded before your application code:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
node --require ./instrumentation.js app.js
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
If you are using Next.js, add the instrumentation hook in `instrumentation.ts`:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
export async function register() {
|
|
33
|
+
if (process.env.NEXT_RUNTIME === "nodejs") {
|
|
34
|
+
const { initBackendRecorder } = await import(
|
|
35
|
+
"@alwaysmeticulous/backend-recorder-launcher"
|
|
36
|
+
);
|
|
37
|
+
await initBackendRecorder({
|
|
38
|
+
recordingToken: process.env.METICULOUS_RECORDING_TOKEN,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Option 2: Auto-init (zero-code)
|
|
45
|
+
|
|
46
|
+
Use the `auto-init` entry point which initializes the recorder as a side effect. No code changes needed — just add the `--require` flag:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
node --require @alwaysmeticulous/backend-recorder-launcher/auto-init app.js
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The auto-init entry point reads configuration from environment variables.
|
|
53
|
+
|
|
54
|
+
## Configuration
|
|
55
|
+
|
|
56
|
+
`initBackendRecorder` accepts an optional `BackendRecorderConfig` object:
|
|
57
|
+
|
|
58
|
+
| Option | Type | Description |
|
|
59
|
+
|------------------------|-----------------------|--------------------------------------------------|
|
|
60
|
+
| `enabled` | `boolean` | Enable/disable the recorder (default: `true`) |
|
|
61
|
+
| `meticulousProjectName`| `string` | The name of the Meticulous project |
|
|
62
|
+
| `recordingToken` | `string` | Token used to authenticate span uploads |
|
|
63
|
+
| `exportMode` | `"local" \| "s3"` | Where to export spans (default: `"local"`) |
|
|
64
|
+
| `localOutputDir` | `string` | Directory for local exports |
|
|
65
|
+
| `flushIntervalMs` | `number` | How often to flush spans (ms) |
|
|
66
|
+
|
|
67
|
+
## Graceful shutdown
|
|
68
|
+
|
|
69
|
+
`initBackendRecorder` returns a `BackendRecorderHandle` with a `stopRecording()` method. Call it before your process exits to flush any pending spans:
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
const handle = await initBackendRecorder({ /* ... */ });
|
|
73
|
+
|
|
74
|
+
process.on("SIGTERM", async () => {
|
|
75
|
+
await handle?.stopRecording();
|
|
76
|
+
process.exit(0);
|
|
77
|
+
});
|
|
78
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const downloading_helpers_1 = require("@alwaysmeticulous/downloading-helpers");
|
|
4
|
+
const AUTO_INIT_BUNDLE_PATH = "backend-record-js/v1/auto-init.bundle.js";
|
|
5
|
+
const autoInit = async () => {
|
|
6
|
+
const bundleLocation = await (0, downloading_helpers_1.fetchAsset)(AUTO_INIT_BUNDLE_PATH);
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
8
|
+
require(bundleLocation);
|
|
9
|
+
};
|
|
10
|
+
autoInit().catch((error) => {
|
|
11
|
+
console.error("[meticulous] Error while bootstrapping backend recorder!");
|
|
12
|
+
console.error(error);
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=auto-init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-init.js","sourceRoot":"","sources":["../src/auto-init.ts"],"names":[],"mappings":";;AAAA,+EAAmE;AAEnE,MAAM,qBAAqB,GACzB,0CAA0C,CAAC;AAE7C,MAAM,QAAQ,GAAG,KAAK,IAAI,EAAE;IAC1B,MAAM,cAAc,GAAG,MAAM,IAAA,gCAAU,EAAC,qBAAqB,CAAC,CAAC;IAC/D,iEAAiE;IACjE,OAAO,CAAC,cAAc,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACzB,OAAO,CAAC,KAAK,CACX,0DAA0D,CAC3D,CAAC;IACF,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { BackendRecorderConfig, BackendRecorderHandle } from "@alwaysmeticulous/sdk-bundles-api";
|
|
2
|
+
export declare const initBackendRecorder: (config?: BackendRecorderConfig) => Promise<BackendRecorderHandle | undefined>;
|
|
3
|
+
export declare const getBackendRecorderBundlePath: (version?: string | null) => string;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBackendRecorderBundlePath = exports.initBackendRecorder = void 0;
|
|
4
|
+
const common_1 = require("@alwaysmeticulous/common");
|
|
5
|
+
const downloading_helpers_1 = require("@alwaysmeticulous/downloading-helpers");
|
|
6
|
+
const MANUAL_INIT_BUNDLE_PATH = "backend-record-js/v1/manual-init.bundle.js";
|
|
7
|
+
const initBackendRecorder = async (config) => {
|
|
8
|
+
const logger = (0, common_1.initLogger)();
|
|
9
|
+
logger.debug("Downloading backend recorder bundle...");
|
|
10
|
+
const bundleLocation = await (0, downloading_helpers_1.fetchAsset)(MANUAL_INIT_BUNDLE_PATH);
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
12
|
+
return (await require(bundleLocation)).initBackendRecorder(config);
|
|
13
|
+
};
|
|
14
|
+
exports.initBackendRecorder = initBackendRecorder;
|
|
15
|
+
const getBackendRecorderBundlePath = (version) => {
|
|
16
|
+
const versionFolder = version == null ? "v1" : `v/${version}`;
|
|
17
|
+
return `backend-record-js/${versionFolder}/manual-init.bundle.js`;
|
|
18
|
+
};
|
|
19
|
+
exports.getBackendRecorderBundlePath = getBackendRecorderBundlePath;
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAAsD;AACtD,+EAAmE;AAMnE,MAAM,uBAAuB,GAC3B,4CAA4C,CAAC;AAExC,MAAM,mBAAmB,GAAG,KAAK,EACtC,MAA8B,EACc,EAAE;IAC9C,MAAM,MAAM,GAAG,IAAA,mBAAU,GAAE,CAAC;IAC5B,MAAM,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;IACvD,MAAM,cAAc,GAAG,MAAM,IAAA,gCAAU,EAAC,uBAAuB,CAAC,CAAC;IAEjE,iEAAiE;IACjE,OAAO,CAAC,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;AACrE,CAAC,CAAC;AATW,QAAA,mBAAmB,uBAS9B;AAEK,MAAM,4BAA4B,GAAG,CAC1C,OAAuB,EACf,EAAE;IACV,MAAM,aAAa,GACjB,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC;IAC1C,OAAO,qBAAqB,aAAa,wBAAwB,CAAC;AACpE,CAAC,CAAC;AANW,QAAA,4BAA4B,gCAMvC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alwaysmeticulous/backend-recorder-launcher",
|
|
3
|
+
"version": "2.277.0",
|
|
4
|
+
"description": "Downloads the backend-recorder bundle script and executes it",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./auto-init": {
|
|
14
|
+
"types": "./dist/auto-init.d.ts",
|
|
15
|
+
"default": "./dist/auto-init.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
23
|
+
"build": "tsc --build tsconfig.json",
|
|
24
|
+
"dev": "tsc --build tsconfig.json --watch",
|
|
25
|
+
"format": "prettier --write src",
|
|
26
|
+
"lint": "eslint \"src/**/*.{js,ts,tsx}\" --cache",
|
|
27
|
+
"lint:commit": "eslint --cache $(git diff --relative --name-only --diff-filter=ACMRTUXB master | grep -E \"(.js$|.ts$|.tsx$)\")",
|
|
28
|
+
"lint:fix": "eslint \"src/**/*.{js,ts,tsx}\" --cache --fix",
|
|
29
|
+
"depcheck": "depcheck --ignore-patterns=dist"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@alwaysmeticulous/common": "workspace:*",
|
|
33
|
+
"@alwaysmeticulous/downloading-helpers": "workspace:*",
|
|
34
|
+
"@alwaysmeticulous/sdk-bundles-api": "workspace:*"
|
|
35
|
+
},
|
|
36
|
+
"author": {
|
|
37
|
+
"name": "The Meticulous Team",
|
|
38
|
+
"email": "eng@meticulous.ai",
|
|
39
|
+
"url": "https://meticulous.ai"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">= 18"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/alwaysmeticulous/meticulous-sdk",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "https://github.com/alwaysmeticulous/meticulous-sdk.git",
|
|
48
|
+
"directory": "packages/backend-recorder-launcher"
|
|
49
|
+
},
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "https://github.com/alwaysmeticulous/meticulous-sdk/issues"
|
|
52
|
+
}
|
|
53
|
+
}
|