@gobing-ai/ts-infra 0.2.7 → 0.2.9
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 +111 -20
- package/dist/event-bus/event-bus.d.ts.map +1 -1
- package/dist/event-bus/event-bus.js +4 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/job-queue/db-job-queue.d.ts +40 -0
- package/dist/job-queue/db-job-queue.d.ts.map +1 -0
- package/dist/job-queue/db-job-queue.js +154 -0
- package/dist/job-queue/index.d.ts +1 -0
- package/dist/job-queue/index.d.ts.map +1 -1
- package/dist/job-queue/index.js +1 -0
- package/dist/job-queue/types.d.ts +3 -5
- package/dist/job-queue/types.d.ts.map +1 -1
- package/dist/job-queue/types.js +2 -4
- package/dist/logger.js +5 -6
- package/dist/scheduler/cloudflare.d.ts +0 -4
- package/dist/scheduler/cloudflare.d.ts.map +1 -1
- package/dist/scheduler/cloudflare.js +10 -1
- package/dist/scheduler/factory.d.ts +0 -3
- package/dist/scheduler/factory.d.ts.map +1 -1
- package/dist/scheduler/factory.js +5 -14
- package/dist/scheduler/node.d.ts +0 -4
- package/dist/scheduler/node.d.ts.map +1 -1
- package/dist/scheduler/node.js +11 -0
- package/dist/telemetry/config.d.ts +0 -5
- package/dist/telemetry/config.d.ts.map +1 -1
- package/dist/telemetry/config.js +0 -3
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +1 -1
- package/dist/telemetry/metrics.d.ts +1 -10
- package/dist/telemetry/metrics.d.ts.map +1 -1
- package/dist/telemetry/metrics.js +9 -26
- package/dist/telemetry/otel-node.d.ts +37 -0
- package/dist/telemetry/otel-node.d.ts.map +1 -0
- package/dist/telemetry/otel-node.js +85 -0
- package/dist/telemetry/sdk.d.ts +12 -1
- package/dist/telemetry/sdk.d.ts.map +1 -1
- package/dist/telemetry/sdk.js +17 -27
- package/package.json +36 -7
- package/src/event-bus/event-bus.ts +4 -0
- package/src/index.ts +2 -11
- package/src/job-queue/db-job-queue.ts +178 -0
- package/src/job-queue/index.ts +1 -0
- package/src/job-queue/types.ts +3 -5
- package/src/logger.ts +4 -4
- package/src/scheduler/cloudflare.ts +8 -1
- package/src/scheduler/factory.ts +2 -15
- package/src/scheduler/node.ts +10 -0
- package/src/telemetry/config.ts +0 -8
- package/src/telemetry/index.ts +0 -6
- package/src/telemetry/metrics.ts +9 -38
- package/src/telemetry/otel-node.ts +116 -0
- package/src/telemetry/sdk.ts +18 -30
- package/dist/events/app-events.d.ts +0 -7
- package/dist/events/app-events.d.ts.map +0 -1
- package/dist/events/app-events.js +0 -4
- package/dist/events/create-system-bus.d.ts +0 -6
- package/dist/events/create-system-bus.d.ts.map +0 -1
- package/dist/events/create-system-bus.js +0 -7
- package/dist/events/index.d.ts +0 -3
- package/dist/events/index.d.ts.map +0 -1
- package/dist/events/index.js +0 -1
- package/src/events/app-events.ts +0 -8
- package/src/events/create-system-bus.ts +0 -8
- package/src/events/index.ts +0 -2
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scheduler factory — selects adapter based on runtime.
|
|
3
|
+
*/
|
|
4
|
+
import { NoopSchedulerAdapter } from './noop.js';
|
|
1
5
|
let runtimeAdapter;
|
|
2
6
|
export function setSchedulerAdapter(adapter) {
|
|
3
7
|
runtimeAdapter = adapter;
|
|
@@ -21,7 +25,7 @@ export function getSchedulerAdapter() {
|
|
|
21
25
|
export function initScheduler(cronEntries) {
|
|
22
26
|
// Default: create a noop adapter. Apps inject their own via setSchedulerAdapter.
|
|
23
27
|
if (!runtimeAdapter) {
|
|
24
|
-
runtimeAdapter =
|
|
28
|
+
runtimeAdapter = new NoopSchedulerAdapter();
|
|
25
29
|
}
|
|
26
30
|
if (cronEntries) {
|
|
27
31
|
for (const [cron, action] of cronEntries) {
|
|
@@ -30,16 +34,3 @@ export function initScheduler(cronEntries) {
|
|
|
30
34
|
}
|
|
31
35
|
return runtimeAdapter;
|
|
32
36
|
}
|
|
33
|
-
function createNoopScheduler() {
|
|
34
|
-
return {
|
|
35
|
-
register() {
|
|
36
|
-
/* noop */
|
|
37
|
-
},
|
|
38
|
-
start() {
|
|
39
|
-
return Promise.resolve();
|
|
40
|
-
},
|
|
41
|
-
stop() {
|
|
42
|
-
return Promise.resolve();
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
}
|
package/dist/scheduler/node.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Node.js scheduler adapter using a simple setInterval-based approach.
|
|
3
|
-
* No external cron library dependency — cron expressions are parsed minimally.
|
|
4
|
-
*/
|
|
5
1
|
import type { ScheduledAction, SchedulerAdapter } from './types';
|
|
6
2
|
export declare class NodeSchedulerAdapter implements SchedulerAdapter {
|
|
7
3
|
private readonly entries;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/scheduler/node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/scheduler/node.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AA6BjE,qBAAa,oBAAqB,YAAW,gBAAgB;IACzD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwB;IAChD,OAAO,CAAC,OAAO,CAAS;;IAIxB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,IAAI;IAU/C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAStB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAU3B,OAAO,CAAC,UAAU;YAOJ,gBAAgB;CAYjC"}
|
package/dist/scheduler/node.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js scheduler adapter using a simple setInterval-based approach.
|
|
3
|
+
* No external cron library dependency — cron expressions are parsed minimally.
|
|
4
|
+
*/
|
|
5
|
+
import { getSchedulerJobDuration, getSchedulerJobExecutedTotal, getSchedulerJobFailedTotal, } from '../telemetry/metrics.js';
|
|
1
6
|
/** Simple helper to parse cron-like interval strings into milliseconds. */
|
|
2
7
|
function parseInterval(cron) {
|
|
3
8
|
// Support simple patterns: "* * * * *" (every minute), "*/5 * * * *" (every 5 min)
|
|
@@ -53,11 +58,17 @@ export class NodeSchedulerAdapter {
|
|
|
53
58
|
entry.timer = setInterval(this._onScheduledTick.bind(this, entry), interval);
|
|
54
59
|
}
|
|
55
60
|
async _onScheduledTick(entry) {
|
|
61
|
+
const startMs = performance.now();
|
|
62
|
+
getSchedulerJobExecutedTotal().add(1, { cron: entry.cron });
|
|
56
63
|
try {
|
|
57
64
|
await entry.action();
|
|
58
65
|
}
|
|
59
66
|
catch {
|
|
60
67
|
// Swallow — scheduler errors should not crash the process
|
|
68
|
+
getSchedulerJobFailedTotal().add(1, { cron: entry.cron });
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
getSchedulerJobDuration().record(performance.now() - startMs, { cron: entry.cron });
|
|
61
72
|
}
|
|
62
73
|
}
|
|
63
74
|
}
|
|
@@ -8,10 +8,6 @@ export interface TelemetryConfig {
|
|
|
8
8
|
serviceName: string;
|
|
9
9
|
/** Deployment environment (development, staging, production). */
|
|
10
10
|
environment: string;
|
|
11
|
-
/** OTLP exporter endpoint (e.g. `http://localhost:4318/v1/traces`). */
|
|
12
|
-
exporterEndpoint?: string | undefined;
|
|
13
|
-
/** Export protocol — only `http` is supported in v1. */
|
|
14
|
-
exporterProtocol: 'http';
|
|
15
11
|
/**
|
|
16
12
|
* Debug-only DB statement capture.
|
|
17
13
|
*
|
|
@@ -30,7 +26,6 @@ export interface TelemetryConfigPartial {
|
|
|
30
26
|
enabled?: boolean | undefined;
|
|
31
27
|
serviceName?: string | undefined;
|
|
32
28
|
environment?: string | undefined;
|
|
33
|
-
exporterEndpoint?: string | undefined;
|
|
34
29
|
dbStatementDebug?: boolean | undefined;
|
|
35
30
|
/** Deployment environment fallback (from app.env). */
|
|
36
31
|
appEnv?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/telemetry/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,eAAe;IAC5B,kEAAkE;IAClE,OAAO,EAAE,OAAO,CAAC;IACjB,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,iEAAiE;IACjE,WAAW,EAAE,MAAM,CAAC;IACpB
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/telemetry/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,eAAe;IAC5B,kEAAkE;IAClE,OAAO,EAAE,OAAO,CAAC;IACjB,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,iEAAiE;IACjE,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;;;;OAQG;IACH,gBAAgB,EAAE,OAAO,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACnC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAQD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,GAAE,sBAA2B,GAAG,eAAe,CAU9F"}
|
package/dist/telemetry/config.js
CHANGED
|
@@ -5,7 +5,6 @@ const DEFAULTS = {
|
|
|
5
5
|
enabled: true,
|
|
6
6
|
serviceName: 'ts-libs',
|
|
7
7
|
environment: 'development',
|
|
8
|
-
exporterProtocol: 'http',
|
|
9
8
|
};
|
|
10
9
|
/**
|
|
11
10
|
* Resolve the full telemetry config by merging a partial override with defaults.
|
|
@@ -17,8 +16,6 @@ export function getTelemetryConfig(configPartial = {}) {
|
|
|
17
16
|
enabled,
|
|
18
17
|
serviceName,
|
|
19
18
|
environment: configPartial.environment ?? configPartial.appEnv ?? DEFAULTS.environment,
|
|
20
|
-
exporterEndpoint: configPartial.exporterEndpoint,
|
|
21
|
-
exporterProtocol: DEFAULTS.exporterProtocol,
|
|
22
19
|
dbStatementDebug: configPartial.dbStatementDebug ?? false,
|
|
23
20
|
};
|
|
24
21
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getTelemetryConfig, type TelemetryConfig, type TelemetryConfigPartial } from './config';
|
|
2
2
|
export { extractSqlOperation, sanitizeSql } from './db-sanitize';
|
|
3
|
-
export { type Counter,
|
|
3
|
+
export { type Counter, getEventbusEmitsTotal, getEventbusErrorsTotal, getHttpClientRequestDuration, getHttpClientRequestErrors, getHttpClientRequestTotal, getQueueJobCompletedTotal, getQueueJobEnqueuedTotal, getQueueJobFailedTotal, getQueueJobProcessingDuration, getSchedulerJobDuration, getSchedulerJobExecutedTotal, getSchedulerJobFailedTotal, type Histogram, initMetrics, shutdownMetrics, } from './metrics';
|
|
4
4
|
export { getTracer, initTelemetry, isTelemetryEnabled, shutdownTelemetry } from './sdk';
|
|
5
5
|
export type { Span, SpanOptions, Tracer } from './tracing';
|
|
6
6
|
export { addSpanAttributes, addSpanEvent, getActiveSpan, traceAsync, traceSync, withSpan } from './tracing';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACjG,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EACH,KAAK,OAAO,EACZ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACjG,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EACH,KAAK,OAAO,EACZ,qBAAqB,EACrB,sBAAsB,EACtB,4BAA4B,EAC5B,0BAA0B,EAC1B,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,EACvB,4BAA4B,EAC5B,0BAA0B,EAC1B,KAAK,SAAS,EACd,WAAW,EACX,eAAe,GAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AACxF,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/telemetry/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { getTelemetryConfig } from './config.js';
|
|
2
2
|
export { extractSqlOperation, sanitizeSql } from './db-sanitize.js';
|
|
3
|
-
export {
|
|
3
|
+
export { getEventbusEmitsTotal, getEventbusErrorsTotal, getHttpClientRequestDuration, getHttpClientRequestErrors, getHttpClientRequestTotal, getQueueJobCompletedTotal, getQueueJobEnqueuedTotal, getQueueJobFailedTotal, getQueueJobProcessingDuration, getSchedulerJobDuration, getSchedulerJobExecutedTotal, getSchedulerJobFailedTotal, initMetrics, shutdownMetrics, } from './metrics.js';
|
|
4
4
|
export { getTracer, initTelemetry, isTelemetryEnabled, shutdownTelemetry } from './sdk.js';
|
|
5
5
|
export { addSpanAttributes, addSpanEvent, getActiveSpan, traceAsync, traceSync, withSpan } from './tracing.js';
|
|
@@ -3,20 +3,11 @@
|
|
|
3
3
|
* All degrade to no-ops when telemetry is disabled.
|
|
4
4
|
*/
|
|
5
5
|
import { type Counter, type Histogram } from '@opentelemetry/api';
|
|
6
|
-
import type { MeterProvider } from '@opentelemetry/sdk-metrics';
|
|
7
6
|
export type { Counter, Histogram } from '@opentelemetry/api';
|
|
8
|
-
import type { TelemetryConfig } from './config';
|
|
9
7
|
export declare function isMetricsInitialized(): boolean;
|
|
10
|
-
export declare function getMeterProvider(): MeterProvider;
|
|
11
|
-
export declare function getHttpServerRequestTotal(): Counter;
|
|
12
|
-
export declare function getHttpServerRequestDuration(): Histogram;
|
|
13
|
-
export declare function getHttpServerRequestErrors(): Counter;
|
|
14
8
|
export declare function getHttpClientRequestTotal(): Counter;
|
|
15
9
|
export declare function getHttpClientRequestDuration(): Histogram;
|
|
16
10
|
export declare function getHttpClientRequestErrors(): Counter;
|
|
17
|
-
export declare function getDbOperationTotal(): Counter;
|
|
18
|
-
export declare function getDbOperationDuration(): Histogram;
|
|
19
|
-
export declare function getDbOperationErrors(): Counter;
|
|
20
11
|
export declare function getEventbusEmitsTotal(): Counter;
|
|
21
12
|
export declare function getEventbusErrorsTotal(): Counter;
|
|
22
13
|
export declare function getQueueJobEnqueuedTotal(): Counter;
|
|
@@ -26,7 +17,7 @@ export declare function getQueueJobProcessingDuration(): Histogram;
|
|
|
26
17
|
export declare function getSchedulerJobExecutedTotal(): Counter;
|
|
27
18
|
export declare function getSchedulerJobDuration(): Histogram;
|
|
28
19
|
export declare function getSchedulerJobFailedTotal(): Counter;
|
|
29
|
-
export declare function initMetrics(
|
|
20
|
+
export declare function initMetrics(): void;
|
|
30
21
|
export declare function shutdownMetrics(): Promise<void>;
|
|
31
22
|
export declare function _resetMetrics(): void;
|
|
32
23
|
//# sourceMappingURL=metrics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/telemetry/metrics.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,SAAS,EAAW,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/telemetry/metrics.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,SAAS,EAAW,MAAM,oBAAoB,CAAC;AAE3E,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI7D,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AA8BD,wBAAgB,yBAAyB,IAAI,OAAO,CAEnD;AAED,wBAAgB,4BAA4B,IAAI,SAAS,CAExD;AAED,wBAAgB,0BAA0B,IAAI,OAAO,CAEpD;AAID,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C;AAED,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD;AAID,wBAAgB,wBAAwB,IAAI,OAAO,CAElD;AAED,wBAAgB,yBAAyB,IAAI,OAAO,CAEnD;AAED,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD;AAED,wBAAgB,6BAA6B,IAAI,SAAS,CAEzD;AAID,wBAAgB,4BAA4B,IAAI,OAAO,CAEtD;AAED,wBAAgB,uBAAuB,IAAI,SAAS,CAEnD;AAED,wBAAgB,0BAA0B,IAAI,OAAO,CAEpD;AAID,wBAAgB,WAAW,IAAI,IAAI,CAGlC;AAED,wBAAgB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAS/C;AAED,wBAAgB,aAAa,IAAI,IAAI,CAMpC"}
|
|
@@ -3,18 +3,15 @@
|
|
|
3
3
|
* All degrade to no-ops when telemetry is disabled.
|
|
4
4
|
*/
|
|
5
5
|
import { metrics } from '@opentelemetry/api';
|
|
6
|
-
let meterProvider;
|
|
7
6
|
let metricsInitialized = false;
|
|
8
7
|
export function isMetricsInitialized() {
|
|
9
8
|
return metricsInitialized;
|
|
10
9
|
}
|
|
11
|
-
export function getMeterProvider() {
|
|
12
|
-
return meterProvider ?? metrics.getMeterProvider();
|
|
13
|
-
}
|
|
14
10
|
const METER_NAME = '@gobing-ai/ts-infra';
|
|
15
11
|
const METER_VERSION = '0.1.0';
|
|
12
|
+
/** Meter from the globally-registered provider (no-op when none registered). */
|
|
16
13
|
function getMeter() {
|
|
17
|
-
return
|
|
14
|
+
return metrics.getMeter(METER_NAME, METER_VERSION);
|
|
18
15
|
}
|
|
19
16
|
// ── Instrument cache ────────────────────────────────────────────────
|
|
20
17
|
const instruments = {};
|
|
@@ -30,16 +27,6 @@ function getOrCreateHistogram(key, name, description, unit = 'ms') {
|
|
|
30
27
|
}
|
|
31
28
|
return instruments[key];
|
|
32
29
|
}
|
|
33
|
-
// ── HTTP server ─────────────────────────────────────────────────────
|
|
34
|
-
export function getHttpServerRequestTotal() {
|
|
35
|
-
return getOrCreateCounter('httpSrvReq', 'http.server.request.total', 'Total inbound HTTP requests', '{request}');
|
|
36
|
-
}
|
|
37
|
-
export function getHttpServerRequestDuration() {
|
|
38
|
-
return getOrCreateHistogram('httpSrvDur', 'http.server.request.duration', 'Inbound HTTP request duration');
|
|
39
|
-
}
|
|
40
|
-
export function getHttpServerRequestErrors() {
|
|
41
|
-
return getOrCreateCounter('httpSrvErr', 'http.server.request.errors', 'Inbound HTTP 5xx errors', '{error}');
|
|
42
|
-
}
|
|
43
30
|
// ── HTTP client ─────────────────────────────────────────────────────
|
|
44
31
|
export function getHttpClientRequestTotal() {
|
|
45
32
|
return getOrCreateCounter('httpCliReq', 'http.client.request.total', 'Total outbound HTTP requests', '{request}');
|
|
@@ -50,16 +37,6 @@ export function getHttpClientRequestDuration() {
|
|
|
50
37
|
export function getHttpClientRequestErrors() {
|
|
51
38
|
return getOrCreateCounter('httpCliErr', 'http.client.request.errors', 'Outbound HTTP errors', '{error}');
|
|
52
39
|
}
|
|
53
|
-
// ── DB ──────────────────────────────────────────────────────────────
|
|
54
|
-
export function getDbOperationTotal() {
|
|
55
|
-
return getOrCreateCounter('dbOpTotal', 'db.client.operation.total', 'Total DB operations', '{operation}');
|
|
56
|
-
}
|
|
57
|
-
export function getDbOperationDuration() {
|
|
58
|
-
return getOrCreateHistogram('dbOpDur', 'db.client.operation.duration', 'DB operation duration');
|
|
59
|
-
}
|
|
60
|
-
export function getDbOperationErrors() {
|
|
61
|
-
return getOrCreateCounter('dbOpErr', 'db.client.operation.errors', 'DB operation errors', '{error}');
|
|
62
|
-
}
|
|
63
40
|
// ── Event bus ───────────────────────────────────────────────────────
|
|
64
41
|
export function getEventbusEmitsTotal() {
|
|
65
42
|
return getOrCreateCounter('ebEmit', 'eventbus.emits.total', 'Total event bus emits', '{emit}');
|
|
@@ -91,12 +68,18 @@ export function getSchedulerJobFailedTotal() {
|
|
|
91
68
|
return getOrCreateCounter('schedFail', 'scheduler.jobs.failed', 'Failed scheduled jobs', '{failure}');
|
|
92
69
|
}
|
|
93
70
|
// ── Lifecycle ───────────────────────────────────────────────────────
|
|
94
|
-
export function initMetrics(
|
|
71
|
+
export function initMetrics() {
|
|
95
72
|
if (metricsInitialized)
|
|
96
73
|
return;
|
|
97
74
|
metricsInitialized = true;
|
|
98
75
|
}
|
|
99
76
|
export function shutdownMetrics() {
|
|
77
|
+
// The meter provider is owned by whoever registered it globally (the host
|
|
78
|
+
// app or `@gobing-ai/ts-infra/otel-node`). Here we only drop the instrument
|
|
79
|
+
// cache so post-shutdown getters rebuild against a fresh meter.
|
|
80
|
+
for (const key of Object.keys(instruments)) {
|
|
81
|
+
instruments[key] = undefined;
|
|
82
|
+
}
|
|
100
83
|
metricsInitialized = false;
|
|
101
84
|
return Promise.resolve();
|
|
102
85
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Options for {@link initNodeTelemetry}. */
|
|
2
|
+
export interface NodeTelemetryOptions {
|
|
3
|
+
/** Logical service name emitted on every span/metric (resource attribute). */
|
|
4
|
+
serviceName: string;
|
|
5
|
+
/** Optional service version (resource attribute). */
|
|
6
|
+
serviceVersion?: string;
|
|
7
|
+
/**
|
|
8
|
+
* OTLP/HTTP collector endpoint base, e.g. `http://localhost:4318`.
|
|
9
|
+
* Signal-specific paths (`/v1/traces`, `/v1/metrics`) are appended by the
|
|
10
|
+
* exporters. When omitted, the OTel SDK default (`http://localhost:4318`)
|
|
11
|
+
* applies, honouring the standard `OTEL_EXPORTER_OTLP_*` env vars.
|
|
12
|
+
*/
|
|
13
|
+
endpoint?: string;
|
|
14
|
+
/** Extra headers sent on every OTLP request (e.g. an auth token). */
|
|
15
|
+
headers?: Record<string, string>;
|
|
16
|
+
/** Metric export interval in ms. Default: 60_000. */
|
|
17
|
+
metricExportIntervalMs?: number;
|
|
18
|
+
/** When false, skip metric export and wire traces only. Default: true. */
|
|
19
|
+
metrics?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Wire Node OTLP/HTTP export for traces and (by default) metrics, registering
|
|
23
|
+
* both providers globally. Idempotent: a second call is a no-op until
|
|
24
|
+
* {@link shutdownNodeTelemetry} runs.
|
|
25
|
+
*
|
|
26
|
+
* Call once at process startup, before the first span/metric is recorded.
|
|
27
|
+
*/
|
|
28
|
+
export declare function initNodeTelemetry(options: NodeTelemetryOptions): void;
|
|
29
|
+
/**
|
|
30
|
+
* Flush and shut down the providers installed by {@link initNodeTelemetry}.
|
|
31
|
+
* Safe to call when nothing was initialised. Wire this to SIGTERM/SIGINT for a
|
|
32
|
+
* clean drain of buffered spans and metrics on shutdown.
|
|
33
|
+
*/
|
|
34
|
+
export declare function shutdownNodeTelemetry(): Promise<void>;
|
|
35
|
+
/** Test-only: reset module state without requiring exporter teardown to resolve. */
|
|
36
|
+
export declare function _resetNodeTelemetry(): void;
|
|
37
|
+
//# sourceMappingURL=otel-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otel-node.d.ts","sourceRoot":"","sources":["../../src/telemetry/otel-node.ts"],"names":[],"mappings":"AAsBA,6CAA6C;AAC7C,MAAM,WAAW,oBAAoB;IACjC,8EAA8E;IAC9E,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,qDAAqD;IACrD,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,0EAA0E;IAC1E,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAKD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAoCrE;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAY3D;AAED,oFAAoF;AACpF,wBAAgB,mBAAmB,IAAI,IAAI,CAI1C"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in Node OTLP wiring for `@gobing-ai/ts-infra`.
|
|
3
|
+
*
|
|
4
|
+
* The core telemetry surface (`initTelemetry`, `getTracer`, the metric getters)
|
|
5
|
+
* only *instruments* — it records spans and metrics against whatever OTel
|
|
6
|
+
* provider is registered globally, and degrades to no-ops when none is. This
|
|
7
|
+
* subpath is the convenience layer that actually *exports*: it builds Node
|
|
8
|
+
* tracer + meter providers wired to OTLP/HTTP and registers them globally, so
|
|
9
|
+
* the already-instrumented call sites start flowing without any core change.
|
|
10
|
+
*
|
|
11
|
+
* Import this only when you want turnkey export. It pulls the OTLP exporter
|
|
12
|
+
* packages (declared as optional peers); the main barrel never imports them, so
|
|
13
|
+
* BYO-collector consumers stay lean and avoid global-provider conflicts.
|
|
14
|
+
*/
|
|
15
|
+
import { metrics } from '@opentelemetry/api';
|
|
16
|
+
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';
|
|
17
|
+
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
18
|
+
import { resourceFromAttributes } from '@opentelemetry/resources';
|
|
19
|
+
import { MeterProvider, PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics';
|
|
20
|
+
import { BatchSpanProcessor, NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
|
|
21
|
+
import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from '@opentelemetry/semantic-conventions';
|
|
22
|
+
let traceProvider;
|
|
23
|
+
let meterProvider;
|
|
24
|
+
/**
|
|
25
|
+
* Wire Node OTLP/HTTP export for traces and (by default) metrics, registering
|
|
26
|
+
* both providers globally. Idempotent: a second call is a no-op until
|
|
27
|
+
* {@link shutdownNodeTelemetry} runs.
|
|
28
|
+
*
|
|
29
|
+
* Call once at process startup, before the first span/metric is recorded.
|
|
30
|
+
*/
|
|
31
|
+
export function initNodeTelemetry(options) {
|
|
32
|
+
if (traceProvider)
|
|
33
|
+
return;
|
|
34
|
+
const { serviceName, serviceVersion, endpoint, headers, metricExportIntervalMs = 60_000 } = options;
|
|
35
|
+
const wireMetrics = options.metrics ?? true;
|
|
36
|
+
const resource = resourceFromAttributes({
|
|
37
|
+
[ATTR_SERVICE_NAME]: serviceName,
|
|
38
|
+
...(serviceVersion ? { [ATTR_SERVICE_VERSION]: serviceVersion } : {}),
|
|
39
|
+
});
|
|
40
|
+
const traceExporter = new OTLPTraceExporter({
|
|
41
|
+
...(endpoint ? { url: `${endpoint.replace(/\/$/, '')}/v1/traces` } : {}),
|
|
42
|
+
...(headers ? { headers } : {}),
|
|
43
|
+
});
|
|
44
|
+
traceProvider = new NodeTracerProvider({
|
|
45
|
+
resource,
|
|
46
|
+
spanProcessors: [new BatchSpanProcessor(traceExporter)],
|
|
47
|
+
});
|
|
48
|
+
traceProvider.register();
|
|
49
|
+
if (wireMetrics) {
|
|
50
|
+
const metricExporter = new OTLPMetricExporter({
|
|
51
|
+
...(endpoint ? { url: `${endpoint.replace(/\/$/, '')}/v1/metrics` } : {}),
|
|
52
|
+
...(headers ? { headers } : {}),
|
|
53
|
+
});
|
|
54
|
+
const reader = new PeriodicExportingMetricReader({
|
|
55
|
+
exporter: metricExporter,
|
|
56
|
+
exportIntervalMillis: metricExportIntervalMs,
|
|
57
|
+
});
|
|
58
|
+
meterProvider = new MeterProvider({ resource, readers: [reader] });
|
|
59
|
+
metrics.setGlobalMeterProvider(meterProvider);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Flush and shut down the providers installed by {@link initNodeTelemetry}.
|
|
64
|
+
* Safe to call when nothing was initialised. Wire this to SIGTERM/SIGINT for a
|
|
65
|
+
* clean drain of buffered spans and metrics on shutdown.
|
|
66
|
+
*/
|
|
67
|
+
export async function shutdownNodeTelemetry() {
|
|
68
|
+
const pending = [];
|
|
69
|
+
if (meterProvider) {
|
|
70
|
+
pending.push(meterProvider.shutdown());
|
|
71
|
+
meterProvider = undefined;
|
|
72
|
+
}
|
|
73
|
+
if (traceProvider) {
|
|
74
|
+
pending.push(traceProvider.shutdown());
|
|
75
|
+
traceProvider = undefined;
|
|
76
|
+
}
|
|
77
|
+
metrics.disable();
|
|
78
|
+
await Promise.all(pending);
|
|
79
|
+
}
|
|
80
|
+
/** Test-only: reset module state without requiring exporter teardown to resolve. */
|
|
81
|
+
export function _resetNodeTelemetry() {
|
|
82
|
+
meterProvider = undefined;
|
|
83
|
+
traceProvider = undefined;
|
|
84
|
+
metrics.disable();
|
|
85
|
+
}
|
package/dist/telemetry/sdk.d.ts
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Telemetry enablement + tracer access.
|
|
3
|
+
*
|
|
4
|
+
* The core only *instruments* against whatever tracer provider is registered
|
|
5
|
+
* globally — it never constructs or owns a provider. Provider + exporter wiring
|
|
6
|
+
* is the consumer's concern: either the host app registers its own OTel SDK, or
|
|
7
|
+
* it opts into `@gobing-ai/ts-infra/otel-node` for turnkey OTLP export. This
|
|
8
|
+
* keeps the main barrel free of any SDK runtime dependency.
|
|
3
9
|
*/
|
|
4
10
|
import { type Tracer } from '@opentelemetry/api';
|
|
5
11
|
import type { TelemetryConfig } from './config';
|
|
6
12
|
export declare function getResolvedConfig(): TelemetryConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Resolve telemetry config and mark telemetry enabled. Does not register any
|
|
15
|
+
* provider — spans flow to the globally-registered provider (none ⇒ no-op).
|
|
16
|
+
*/
|
|
7
17
|
export declare function initTelemetry(config?: Partial<TelemetryConfig>): void;
|
|
8
18
|
export declare function shutdownTelemetry(): Promise<void>;
|
|
19
|
+
/** The infra tracer from the globally-registered provider (no-op when none). */
|
|
9
20
|
export declare function getTracer(): Tracer;
|
|
10
21
|
export declare function isTelemetryEnabled(): boolean;
|
|
11
22
|
export declare function _resetTelemetry(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/telemetry/sdk.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/telemetry/sdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,KAAK,MAAM,EAAS,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAShD,wBAAgB,iBAAiB,IAAI,eAAe,CAEnD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI,CAIrE;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAGjD;AAED,gFAAgF;AAChF,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C;AAED,wBAAgB,eAAe,IAAI,IAAI,CAGtC;AAED,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/telemetry/sdk.js
CHANGED
|
@@ -1,53 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Telemetry enablement + tracer access.
|
|
3
|
+
*
|
|
4
|
+
* The core only *instruments* against whatever tracer provider is registered
|
|
5
|
+
* globally — it never constructs or owns a provider. Provider + exporter wiring
|
|
6
|
+
* is the consumer's concern: either the host app registers its own OTel SDK, or
|
|
7
|
+
* it opts into `@gobing-ai/ts-infra/otel-node` for turnkey OTLP export. This
|
|
8
|
+
* keeps the main barrel free of any SDK runtime dependency.
|
|
3
9
|
*/
|
|
4
10
|
import { trace } from '@opentelemetry/api';
|
|
5
|
-
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
|
|
6
11
|
import { getTelemetryConfig } from './config.js';
|
|
7
|
-
|
|
12
|
+
const TRACER_NAME = '@gobing-ai/ts-infra';
|
|
13
|
+
const TRACER_VERSION = '0.1.0';
|
|
8
14
|
let telemetryInitialized = false;
|
|
9
15
|
let resolvedConfig = getTelemetryConfig();
|
|
10
|
-
const DEFAULT_TRACER = trace.getTracer('@gobing-ai/ts-infra', '0.1.0');
|
|
11
16
|
export function getResolvedConfig() {
|
|
12
17
|
return resolvedConfig;
|
|
13
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Resolve telemetry config and mark telemetry enabled. Does not register any
|
|
21
|
+
* provider — spans flow to the globally-registered provider (none ⇒ no-op).
|
|
22
|
+
*/
|
|
14
23
|
export function initTelemetry(config) {
|
|
15
24
|
if (telemetryInitialized)
|
|
16
25
|
return;
|
|
17
26
|
resolvedConfig = { ...getTelemetryConfig(), ...config };
|
|
18
|
-
if (!resolvedConfig.enabled) {
|
|
19
|
-
telemetryInitialized = true;
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
tracerProvider = new NodeTracerProvider();
|
|
23
|
-
tracerProvider.register();
|
|
24
27
|
telemetryInitialized = true;
|
|
25
28
|
}
|
|
26
|
-
export
|
|
27
|
-
if (!tracerProvider) {
|
|
28
|
-
telemetryInitialized = false;
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
await tracerProvider.shutdown();
|
|
32
|
-
tracerProvider = undefined;
|
|
29
|
+
export function shutdownTelemetry() {
|
|
33
30
|
telemetryInitialized = false;
|
|
31
|
+
return Promise.resolve();
|
|
34
32
|
}
|
|
33
|
+
/** The infra tracer from the globally-registered provider (no-op when none). */
|
|
35
34
|
export function getTracer() {
|
|
36
|
-
return
|
|
35
|
+
return trace.getTracer(TRACER_NAME, TRACER_VERSION);
|
|
37
36
|
}
|
|
38
37
|
export function isTelemetryEnabled() {
|
|
39
38
|
return telemetryInitialized && resolvedConfig.enabled;
|
|
40
39
|
}
|
|
41
40
|
export function _resetTelemetry() {
|
|
42
|
-
if (tracerProvider) {
|
|
43
|
-
try {
|
|
44
|
-
tracerProvider.shutdown();
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
/* swallow */
|
|
48
|
-
}
|
|
49
|
-
tracerProvider = undefined;
|
|
50
|
-
}
|
|
51
41
|
telemetryInitialized = false;
|
|
52
42
|
resolvedConfig = getTelemetryConfig();
|
|
53
43
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gobing-ai/ts-infra",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "@gobing-ai/ts-infra — Infrastructure backbone: event bus, job queue, scheduler, telemetry, API client, and logging.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -31,6 +31,10 @@
|
|
|
31
31
|
".": {
|
|
32
32
|
"types": "./dist/index.d.ts",
|
|
33
33
|
"import": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./otel-node": {
|
|
36
|
+
"types": "./dist/telemetry/otel-node.d.ts",
|
|
37
|
+
"import": "./dist/telemetry/otel-node.js"
|
|
34
38
|
}
|
|
35
39
|
},
|
|
36
40
|
"files": [
|
|
@@ -50,18 +54,43 @@
|
|
|
50
54
|
"release": "echo 'Manual publish is disabled. Releases go through GitHub Actions via Trusted Publishing — push a tag: git tag @gobing-ai/ts-infra-v<version> && git push --tags' && exit 1"
|
|
51
55
|
},
|
|
52
56
|
"dependencies": {
|
|
53
|
-
"@gobing-ai/ts-db": "^0.2.
|
|
54
|
-
"@gobing-ai/ts-runtime": "^0.2.7"
|
|
57
|
+
"@gobing-ai/ts-db": "^0.2.9"
|
|
55
58
|
},
|
|
56
59
|
"peerDependencies": {
|
|
57
|
-
"@opentelemetry/api": "^1.9.0"
|
|
60
|
+
"@opentelemetry/api": "^1.9.0",
|
|
61
|
+
"@opentelemetry/sdk-trace-node": "^2.0.0",
|
|
62
|
+
"@opentelemetry/sdk-metrics": "^2.0.0",
|
|
63
|
+
"@opentelemetry/resources": "^2.0.0",
|
|
64
|
+
"@opentelemetry/semantic-conventions": "^1.30.0",
|
|
65
|
+
"@opentelemetry/exporter-trace-otlp-http": ">=0.200.0",
|
|
66
|
+
"@opentelemetry/exporter-metrics-otlp-http": ">=0.200.0"
|
|
67
|
+
},
|
|
68
|
+
"peerDependenciesMeta": {
|
|
69
|
+
"@opentelemetry/sdk-trace-node": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"@opentelemetry/sdk-metrics": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"@opentelemetry/resources": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"@opentelemetry/exporter-trace-otlp-http": {
|
|
79
|
+
"optional": true
|
|
80
|
+
},
|
|
81
|
+
"@opentelemetry/exporter-metrics-otlp-http": {
|
|
82
|
+
"optional": true
|
|
83
|
+
}
|
|
58
84
|
},
|
|
59
85
|
"devDependencies": {
|
|
60
86
|
"@types/bun": "1.3.14",
|
|
61
87
|
"@opentelemetry/api": "^1.9.0",
|
|
62
|
-
"@opentelemetry/sdk-trace-node": "^
|
|
63
|
-
"@opentelemetry/sdk-metrics": "^
|
|
64
|
-
"@opentelemetry/
|
|
88
|
+
"@opentelemetry/sdk-trace-node": "^2.0.0",
|
|
89
|
+
"@opentelemetry/sdk-metrics": "^2.0.0",
|
|
90
|
+
"@opentelemetry/resources": "^2.0.0",
|
|
91
|
+
"@opentelemetry/semantic-conventions": "^1.30.0",
|
|
92
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.200.0",
|
|
93
|
+
"@opentelemetry/exporter-metrics-otlp-http": "^0.200.0"
|
|
65
94
|
},
|
|
66
95
|
"publishConfig": {
|
|
67
96
|
"access": "public"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { JobQueue } from '../job-queue/types';
|
|
2
2
|
import { getLogger, type Logger } from '../logger';
|
|
3
|
+
import { getEventbusEmitsTotal, getEventbusErrorsTotal } from '../telemetry/metrics';
|
|
3
4
|
import type {
|
|
4
5
|
AsyncEnqueuedDetail,
|
|
5
6
|
BusLifecycleEvents,
|
|
@@ -144,6 +145,9 @@ export class EventBus<TEvents extends EventMap> {
|
|
|
144
145
|
const durationMs = performance.now() - startMs;
|
|
145
146
|
const detail = args.length === 1 ? args[0] : args.length > 1 ? args : undefined;
|
|
146
147
|
|
|
148
|
+
getEventbusEmitsTotal().add(1, { event: eventName });
|
|
149
|
+
if (errors > 0) getEventbusErrorsTotal().add(errors, { event: eventName });
|
|
150
|
+
|
|
147
151
|
this.publishEmitDone({ event: eventName, syncCount, asyncCount, emitDurationMs: durationMs, errors, detail });
|
|
148
152
|
|
|
149
153
|
if (syncCount === 0 && asyncCount === 0) {
|
package/src/index.ts
CHANGED
|
@@ -4,11 +4,6 @@ export { APIClient, type APIClientConfig, APIError, type RequestOptions } from '
|
|
|
4
4
|
// Event Bus
|
|
5
5
|
export { EventBus, type EventMap, type SubscribeOptions } from './event-bus/index';
|
|
6
6
|
|
|
7
|
-
// Events
|
|
8
|
-
export type { AppEvents, AppInternalEvents } from './events/index';
|
|
9
|
-
export { createSystemBus } from './events/index';
|
|
10
|
-
|
|
11
|
-
// Job Queue
|
|
12
7
|
export type {
|
|
13
8
|
EnqueueOptions,
|
|
14
9
|
Job,
|
|
@@ -18,6 +13,8 @@ export type {
|
|
|
18
13
|
QueueConsumerConfig,
|
|
19
14
|
QueueStats,
|
|
20
15
|
} from './job-queue/index';
|
|
16
|
+
// Job Queue
|
|
17
|
+
export { DBJobQueue, DBQueueConsumer } from './job-queue/index';
|
|
21
18
|
|
|
22
19
|
// Logger
|
|
23
20
|
export { getLogger, initializeLogger, type Logger, type LogLevel } from './logger';
|
|
@@ -40,17 +37,11 @@ export {
|
|
|
40
37
|
addSpanEvent,
|
|
41
38
|
extractSqlOperation,
|
|
42
39
|
getActiveSpan,
|
|
43
|
-
getDbOperationDuration,
|
|
44
|
-
getDbOperationErrors,
|
|
45
|
-
getDbOperationTotal,
|
|
46
40
|
getEventbusEmitsTotal,
|
|
47
41
|
getEventbusErrorsTotal,
|
|
48
42
|
getHttpClientRequestDuration,
|
|
49
43
|
getHttpClientRequestErrors,
|
|
50
44
|
getHttpClientRequestTotal,
|
|
51
|
-
getHttpServerRequestDuration,
|
|
52
|
-
getHttpServerRequestErrors,
|
|
53
|
-
getHttpServerRequestTotal,
|
|
54
45
|
getQueueJobCompletedTotal,
|
|
55
46
|
getQueueJobEnqueuedTotal,
|
|
56
47
|
getQueueJobFailedTotal,
|