@revenexx/app-sdk 0.9.0 → 1.0.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 +141 -35
- package/dist/{chunk-2BOFXTTC.js → chunk-73D37ZGB.js} +96 -6
- package/dist/chunk-73D37ZGB.js.map +1 -0
- package/dist/{errors-D7FGkghT.d.cts → errors-BPYDadk4.d.cts} +18 -6
- package/dist/{errors-D7FGkghT.d.ts → errors-BPYDadk4.d.ts} +18 -6
- package/dist/index.cjs +86 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +71 -81
- package/dist/index.js.map +1 -1
- package/dist/router/index.cjs +47 -17
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +27 -4
- package/dist/router/index.d.ts +27 -4
- package/dist/router/index.js +78 -15
- package/dist/router/index.js.map +1 -1
- package/package.json +1 -6
- package/dist/chunk-2BOFXTTC.js.map +0 -1
- package/dist/chunk-TUTGCI5D.js +0 -41
- package/dist/chunk-TUTGCI5D.js.map +0 -1
- package/dist/instrument.cjs +0 -75
- package/dist/instrument.cjs.map +0 -1
- package/dist/instrument.d.cts +0 -26
- package/dist/instrument.d.ts +0 -26
- package/dist/instrument.js +0 -7
- package/dist/instrument.js.map +0 -1
package/dist/chunk-TUTGCI5D.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// src/instrument.ts
|
|
2
|
-
var started = false;
|
|
3
|
-
async function startTelemetry() {
|
|
4
|
-
if (started) {
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
started = true;
|
|
8
|
-
const endpoint = process.env["OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"] ?? process.env["OTEL_EXPORTER_OTLP_ENDPOINT"] ?? "";
|
|
9
|
-
if (!endpoint) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
try {
|
|
13
|
-
const [{ NodeSDK }, { OTLPTraceExporter }, { UndiciInstrumentation }] = await Promise.all([
|
|
14
|
-
import("@opentelemetry/sdk-node"),
|
|
15
|
-
import("@opentelemetry/exporter-trace-otlp-proto"),
|
|
16
|
-
import("@opentelemetry/instrumentation-undici")
|
|
17
|
-
]);
|
|
18
|
-
const sdk = new NodeSDK({
|
|
19
|
-
traceExporter: new OTLPTraceExporter(),
|
|
20
|
-
instrumentations: [new UndiciInstrumentation()]
|
|
21
|
-
});
|
|
22
|
-
sdk.start();
|
|
23
|
-
const flush = () => {
|
|
24
|
-
void sdk.shutdown().catch(() => {
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
process.once("SIGTERM", flush);
|
|
28
|
-
process.once("SIGINT", flush);
|
|
29
|
-
} catch (err) {
|
|
30
|
-
console.error(
|
|
31
|
-
"[app-sdk] OpenTelemetry init failed, continuing without tracing:",
|
|
32
|
-
err instanceof Error ? err.message : err
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
void startTelemetry();
|
|
37
|
-
|
|
38
|
-
export {
|
|
39
|
-
startTelemetry
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=chunk-TUTGCI5D.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/instrument.ts"],"sourcesContent":["/**\n * OpenTelemetry bootstrap for revenexx App functions.\n *\n * Loaded automatically as a side effect of importing `@revenexx/app-sdk/router`\n * (the app requires the router from its own code dir, so OTel deps resolve).\n * Do NOT preload via `NODE_OPTIONS=--require` in open-runtimes: that runs in the\n * runtime server's node process, which cannot resolve the app's node_modules and\n * crashes the runtime.\n *\n * Configuration is 100% standard `OTEL_*` env; with no OTLP endpoint set it is a\n * cheap no-op (the heavy OTel packages aren't even loaded):\n * OTEL_EXPORTER_OTLP_ENDPOINT https://traces.revenexx.com\n * OTEL_EXPORTER_OTLP_HEADERS Authorization=Basic <base64>\n * OTEL_SERVICE_NAME products\n * OTEL_RESOURCE_ATTRIBUTES service.namespace=revenue-cloud,deployment.environment=prod\n *\n * Lean: only outbound undici/fetch (the PostgREST data plane) is auto-instrumented.\n * The per-invocation SERVER span is added by the router (createApp).\n */\n\nlet started = false;\n\n/**\n * Start OpenTelemetry once. Safe to call repeatedly. NEVER throws — a telemetry\n * failure must not take the function down (a missing trace beats a dead runtime).\n */\nexport async function startTelemetry(): Promise<void> {\n if (started) {\n return;\n }\n started = true;\n\n const endpoint =\n process.env['OTEL_EXPORTER_OTLP_TRACES_ENDPOINT'] ?? process.env['OTEL_EXPORTER_OTLP_ENDPOINT'] ?? '';\n if (!endpoint) {\n return; // tracing disabled — don't even load the OTel packages\n }\n\n try {\n const [{ NodeSDK }, { OTLPTraceExporter }, { UndiciInstrumentation }] = await Promise.all([\n import('@opentelemetry/sdk-node'),\n import('@opentelemetry/exporter-trace-otlp-proto'),\n import('@opentelemetry/instrumentation-undici'),\n ]);\n\n // Exporter + resource (service.name, resource attrs) are read from OTEL_* env.\n const sdk = new NodeSDK({\n traceExporter: new OTLPTraceExporter(),\n instrumentations: [new UndiciInstrumentation()],\n });\n\n sdk.start();\n\n const flush = (): void => {\n void sdk.shutdown().catch(() => {\n /* best effort */\n });\n };\n process.once('SIGTERM', flush);\n process.once('SIGINT', flush);\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error(\n '[app-sdk] OpenTelemetry init failed, continuing without tracing:',\n err instanceof Error ? err.message : err,\n );\n }\n}\n\n// Auto-start on import (side effect). Fire-and-forget; never blocks or throws.\nvoid startTelemetry();\n"],"mappings":";AAoBA,IAAI,UAAU;AAMd,eAAsB,iBAAgC;AACpD,MAAI,SAAS;AACX;AAAA,EACF;AACA,YAAU;AAEV,QAAM,WACJ,QAAQ,IAAI,oCAAoC,KAAK,QAAQ,IAAI,6BAA6B,KAAK;AACrG,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAEA,MAAI;AACF,UAAM,CAAC,EAAE,QAAQ,GAAG,EAAE,kBAAkB,GAAG,EAAE,sBAAsB,CAAC,IAAI,MAAM,QAAQ,IAAI;AAAA,MACxF,OAAO,yBAAyB;AAAA,MAChC,OAAO,0CAA0C;AAAA,MACjD,OAAO,uCAAuC;AAAA,IAChD,CAAC;AAGD,UAAM,MAAM,IAAI,QAAQ;AAAA,MACtB,eAAe,IAAI,kBAAkB;AAAA,MACrC,kBAAkB,CAAC,IAAI,sBAAsB,CAAC;AAAA,IAChD,CAAC;AAED,QAAI,MAAM;AAEV,UAAM,QAAQ,MAAY;AACxB,WAAK,IAAI,SAAS,EAAE,MAAM,MAAM;AAAA,MAEhC,CAAC;AAAA,IACH;AACA,YAAQ,KAAK,WAAW,KAAK;AAC7B,YAAQ,KAAK,UAAU,KAAK;AAAA,EAC9B,SAAS,KAAK;AAEZ,YAAQ;AAAA,MACN;AAAA,MACA,eAAe,QAAQ,IAAI,UAAU;AAAA,IACvC;AAAA,EACF;AACF;AAGA,KAAK,eAAe;","names":[]}
|
package/dist/instrument.cjs
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/instrument.ts
|
|
31
|
-
var instrument_exports = {};
|
|
32
|
-
__export(instrument_exports, {
|
|
33
|
-
startTelemetry: () => startTelemetry
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(instrument_exports);
|
|
36
|
-
var started = false;
|
|
37
|
-
async function startTelemetry() {
|
|
38
|
-
if (started) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
started = true;
|
|
42
|
-
const endpoint = process.env["OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"] ?? process.env["OTEL_EXPORTER_OTLP_ENDPOINT"] ?? "";
|
|
43
|
-
if (!endpoint) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
try {
|
|
47
|
-
const [{ NodeSDK }, { OTLPTraceExporter }, { UndiciInstrumentation }] = await Promise.all([
|
|
48
|
-
import("@opentelemetry/sdk-node"),
|
|
49
|
-
import("@opentelemetry/exporter-trace-otlp-proto"),
|
|
50
|
-
import("@opentelemetry/instrumentation-undici")
|
|
51
|
-
]);
|
|
52
|
-
const sdk = new NodeSDK({
|
|
53
|
-
traceExporter: new OTLPTraceExporter(),
|
|
54
|
-
instrumentations: [new UndiciInstrumentation()]
|
|
55
|
-
});
|
|
56
|
-
sdk.start();
|
|
57
|
-
const flush = () => {
|
|
58
|
-
void sdk.shutdown().catch(() => {
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
process.once("SIGTERM", flush);
|
|
62
|
-
process.once("SIGINT", flush);
|
|
63
|
-
} catch (err) {
|
|
64
|
-
console.error(
|
|
65
|
-
"[app-sdk] OpenTelemetry init failed, continuing without tracing:",
|
|
66
|
-
err instanceof Error ? err.message : err
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
void startTelemetry();
|
|
71
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
-
0 && (module.exports = {
|
|
73
|
-
startTelemetry
|
|
74
|
-
});
|
|
75
|
-
//# sourceMappingURL=instrument.cjs.map
|
package/dist/instrument.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/instrument.ts"],"sourcesContent":["/**\n * OpenTelemetry bootstrap for revenexx App functions.\n *\n * Loaded automatically as a side effect of importing `@revenexx/app-sdk/router`\n * (the app requires the router from its own code dir, so OTel deps resolve).\n * Do NOT preload via `NODE_OPTIONS=--require` in open-runtimes: that runs in the\n * runtime server's node process, which cannot resolve the app's node_modules and\n * crashes the runtime.\n *\n * Configuration is 100% standard `OTEL_*` env; with no OTLP endpoint set it is a\n * cheap no-op (the heavy OTel packages aren't even loaded):\n * OTEL_EXPORTER_OTLP_ENDPOINT https://traces.revenexx.com\n * OTEL_EXPORTER_OTLP_HEADERS Authorization=Basic <base64>\n * OTEL_SERVICE_NAME products\n * OTEL_RESOURCE_ATTRIBUTES service.namespace=revenue-cloud,deployment.environment=prod\n *\n * Lean: only outbound undici/fetch (the PostgREST data plane) is auto-instrumented.\n * The per-invocation SERVER span is added by the router (createApp).\n */\n\nlet started = false;\n\n/**\n * Start OpenTelemetry once. Safe to call repeatedly. NEVER throws — a telemetry\n * failure must not take the function down (a missing trace beats a dead runtime).\n */\nexport async function startTelemetry(): Promise<void> {\n if (started) {\n return;\n }\n started = true;\n\n const endpoint =\n process.env['OTEL_EXPORTER_OTLP_TRACES_ENDPOINT'] ?? process.env['OTEL_EXPORTER_OTLP_ENDPOINT'] ?? '';\n if (!endpoint) {\n return; // tracing disabled — don't even load the OTel packages\n }\n\n try {\n const [{ NodeSDK }, { OTLPTraceExporter }, { UndiciInstrumentation }] = await Promise.all([\n import('@opentelemetry/sdk-node'),\n import('@opentelemetry/exporter-trace-otlp-proto'),\n import('@opentelemetry/instrumentation-undici'),\n ]);\n\n // Exporter + resource (service.name, resource attrs) are read from OTEL_* env.\n const sdk = new NodeSDK({\n traceExporter: new OTLPTraceExporter(),\n instrumentations: [new UndiciInstrumentation()],\n });\n\n sdk.start();\n\n const flush = (): void => {\n void sdk.shutdown().catch(() => {\n /* best effort */\n });\n };\n process.once('SIGTERM', flush);\n process.once('SIGINT', flush);\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error(\n '[app-sdk] OpenTelemetry init failed, continuing without tracing:',\n err instanceof Error ? err.message : err,\n );\n }\n}\n\n// Auto-start on import (side effect). Fire-and-forget; never blocks or throws.\nvoid startTelemetry();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBA,IAAI,UAAU;AAMd,eAAsB,iBAAgC;AACpD,MAAI,SAAS;AACX;AAAA,EACF;AACA,YAAU;AAEV,QAAM,WACJ,QAAQ,IAAI,oCAAoC,KAAK,QAAQ,IAAI,6BAA6B,KAAK;AACrG,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAEA,MAAI;AACF,UAAM,CAAC,EAAE,QAAQ,GAAG,EAAE,kBAAkB,GAAG,EAAE,sBAAsB,CAAC,IAAI,MAAM,QAAQ,IAAI;AAAA,MACxF,OAAO,yBAAyB;AAAA,MAChC,OAAO,0CAA0C;AAAA,MACjD,OAAO,uCAAuC;AAAA,IAChD,CAAC;AAGD,UAAM,MAAM,IAAI,QAAQ;AAAA,MACtB,eAAe,IAAI,kBAAkB;AAAA,MACrC,kBAAkB,CAAC,IAAI,sBAAsB,CAAC;AAAA,IAChD,CAAC;AAED,QAAI,MAAM;AAEV,UAAM,QAAQ,MAAY;AACxB,WAAK,IAAI,SAAS,EAAE,MAAM,MAAM;AAAA,MAEhC,CAAC;AAAA,IACH;AACA,YAAQ,KAAK,WAAW,KAAK;AAC7B,YAAQ,KAAK,UAAU,KAAK;AAAA,EAC9B,SAAS,KAAK;AAEZ,YAAQ;AAAA,MACN;AAAA,MACA,eAAe,QAAQ,IAAI,UAAU;AAAA,IACvC;AAAA,EACF;AACF;AAGA,KAAK,eAAe;","names":[]}
|
package/dist/instrument.d.cts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenTelemetry bootstrap for revenexx App functions.
|
|
3
|
-
*
|
|
4
|
-
* Loaded automatically as a side effect of importing `@revenexx/app-sdk/router`
|
|
5
|
-
* (the app requires the router from its own code dir, so OTel deps resolve).
|
|
6
|
-
* Do NOT preload via `NODE_OPTIONS=--require` in open-runtimes: that runs in the
|
|
7
|
-
* runtime server's node process, which cannot resolve the app's node_modules and
|
|
8
|
-
* crashes the runtime.
|
|
9
|
-
*
|
|
10
|
-
* Configuration is 100% standard `OTEL_*` env; with no OTLP endpoint set it is a
|
|
11
|
-
* cheap no-op (the heavy OTel packages aren't even loaded):
|
|
12
|
-
* OTEL_EXPORTER_OTLP_ENDPOINT https://traces.revenexx.com
|
|
13
|
-
* OTEL_EXPORTER_OTLP_HEADERS Authorization=Basic <base64>
|
|
14
|
-
* OTEL_SERVICE_NAME products
|
|
15
|
-
* OTEL_RESOURCE_ATTRIBUTES service.namespace=revenue-cloud,deployment.environment=prod
|
|
16
|
-
*
|
|
17
|
-
* Lean: only outbound undici/fetch (the PostgREST data plane) is auto-instrumented.
|
|
18
|
-
* The per-invocation SERVER span is added by the router (createApp).
|
|
19
|
-
*/
|
|
20
|
-
/**
|
|
21
|
-
* Start OpenTelemetry once. Safe to call repeatedly. NEVER throws — a telemetry
|
|
22
|
-
* failure must not take the function down (a missing trace beats a dead runtime).
|
|
23
|
-
*/
|
|
24
|
-
declare function startTelemetry(): Promise<void>;
|
|
25
|
-
|
|
26
|
-
export { startTelemetry };
|
package/dist/instrument.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenTelemetry bootstrap for revenexx App functions.
|
|
3
|
-
*
|
|
4
|
-
* Loaded automatically as a side effect of importing `@revenexx/app-sdk/router`
|
|
5
|
-
* (the app requires the router from its own code dir, so OTel deps resolve).
|
|
6
|
-
* Do NOT preload via `NODE_OPTIONS=--require` in open-runtimes: that runs in the
|
|
7
|
-
* runtime server's node process, which cannot resolve the app's node_modules and
|
|
8
|
-
* crashes the runtime.
|
|
9
|
-
*
|
|
10
|
-
* Configuration is 100% standard `OTEL_*` env; with no OTLP endpoint set it is a
|
|
11
|
-
* cheap no-op (the heavy OTel packages aren't even loaded):
|
|
12
|
-
* OTEL_EXPORTER_OTLP_ENDPOINT https://traces.revenexx.com
|
|
13
|
-
* OTEL_EXPORTER_OTLP_HEADERS Authorization=Basic <base64>
|
|
14
|
-
* OTEL_SERVICE_NAME products
|
|
15
|
-
* OTEL_RESOURCE_ATTRIBUTES service.namespace=revenue-cloud,deployment.environment=prod
|
|
16
|
-
*
|
|
17
|
-
* Lean: only outbound undici/fetch (the PostgREST data plane) is auto-instrumented.
|
|
18
|
-
* The per-invocation SERVER span is added by the router (createApp).
|
|
19
|
-
*/
|
|
20
|
-
/**
|
|
21
|
-
* Start OpenTelemetry once. Safe to call repeatedly. NEVER throws — a telemetry
|
|
22
|
-
* failure must not take the function down (a missing trace beats a dead runtime).
|
|
23
|
-
*/
|
|
24
|
-
declare function startTelemetry(): Promise<void>;
|
|
25
|
-
|
|
26
|
-
export { startTelemetry };
|
package/dist/instrument.js
DELETED
package/dist/instrument.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|