@revenexx/app-sdk 0.9.0 → 1.1.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.
@@ -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
@@ -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":[]}
@@ -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 };
@@ -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 };
@@ -1,7 +0,0 @@
1
- import {
2
- startTelemetry
3
- } from "./chunk-TUTGCI5D.js";
4
- export {
5
- startTelemetry
6
- };
7
- //# sourceMappingURL=instrument.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}