@bsb/base 9.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.
Files changed (182) hide show
  1. package/LICENSE +665 -0
  2. package/LICENSE.commercial +32 -0
  3. package/README.md +263 -0
  4. package/bsb-plugin.json +62 -0
  5. package/lib/base/BSBConfig.d.ts +130 -0
  6. package/lib/base/BSBConfig.js +95 -0
  7. package/lib/base/BSBConfig.js.map +1 -0
  8. package/lib/base/BSBEvents.d.ts +207 -0
  9. package/lib/base/BSBEvents.js +101 -0
  10. package/lib/base/BSBEvents.js.map +1 -0
  11. package/lib/base/BSBObservable.d.ts +178 -0
  12. package/lib/base/BSBObservable.js +91 -0
  13. package/lib/base/BSBObservable.js.map +1 -0
  14. package/lib/base/BSBService.d.ts +277 -0
  15. package/lib/base/BSBService.js +366 -0
  16. package/lib/base/BSBService.js.map +1 -0
  17. package/lib/base/BSBServiceClient.d.ts +135 -0
  18. package/lib/base/BSBServiceClient.js +130 -0
  19. package/lib/base/BSBServiceClient.js.map +1 -0
  20. package/lib/base/EventValidator.d.ts +137 -0
  21. package/lib/base/EventValidator.js +210 -0
  22. package/lib/base/EventValidator.js.map +1 -0
  23. package/lib/base/ObservableBackend.d.ts +281 -0
  24. package/lib/base/ObservableBackend.js +515 -0
  25. package/lib/base/ObservableBackend.js.map +1 -0
  26. package/lib/base/PluginConfig.d.ts +196 -0
  27. package/lib/base/PluginConfig.js +96 -0
  28. package/lib/base/PluginConfig.js.map +1 -0
  29. package/lib/base/PluginEvents.d.ts +140 -0
  30. package/lib/base/PluginEvents.js +268 -0
  31. package/lib/base/PluginEvents.js.map +1 -0
  32. package/lib/base/PluginObservable.d.ts +196 -0
  33. package/lib/base/PluginObservable.js +250 -0
  34. package/lib/base/PluginObservable.js.map +1 -0
  35. package/lib/base/ResourceContext.d.ts +70 -0
  36. package/lib/base/ResourceContext.js +54 -0
  37. package/lib/base/ResourceContext.js.map +1 -0
  38. package/lib/base/base.d.ts +264 -0
  39. package/lib/base/base.js +182 -0
  40. package/lib/base/base.js.map +1 -0
  41. package/lib/base/errorMessages.d.ts +56 -0
  42. package/lib/base/errorMessages.js +70 -0
  43. package/lib/base/errorMessages.js.map +1 -0
  44. package/lib/base/factory.d.ts +58 -0
  45. package/lib/base/factory.js +167 -0
  46. package/lib/base/factory.js.map +1 -0
  47. package/lib/base/functions.d.ts +117 -0
  48. package/lib/base/functions.js +152 -0
  49. package/lib/base/functions.js.map +1 -0
  50. package/lib/base/index.d.ts +44 -0
  51. package/lib/base/index.js +64 -0
  52. package/lib/base/index.js.map +1 -0
  53. package/lib/base/logFormatter.d.ts +50 -0
  54. package/lib/base/logFormatter.js +105 -0
  55. package/lib/base/logFormatter.js.map +1 -0
  56. package/lib/base/tools.d.ts +316 -0
  57. package/lib/base/tools.js +666 -0
  58. package/lib/base/tools.js.map +1 -0
  59. package/lib/cli.d.ts +28 -0
  60. package/lib/cli.js +254 -0
  61. package/lib/cli.js.map +1 -0
  62. package/lib/dev.d.ts +27 -0
  63. package/lib/dev.js +200 -0
  64. package/lib/dev.js.map +1 -0
  65. package/lib/index.d.ts +32 -0
  66. package/lib/index.js +49 -0
  67. package/lib/index.js.map +1 -0
  68. package/lib/interfaces/events.d.ts +67 -0
  69. package/lib/interfaces/events.js +44 -0
  70. package/lib/interfaces/events.js.map +1 -0
  71. package/lib/interfaces/index.d.ts +38 -0
  72. package/lib/interfaces/index.js +59 -0
  73. package/lib/interfaces/index.js.map +1 -0
  74. package/lib/interfaces/logging.d.ts +106 -0
  75. package/lib/interfaces/logging.js +39 -0
  76. package/lib/interfaces/logging.js.map +1 -0
  77. package/lib/interfaces/metrics.d.ts +365 -0
  78. package/lib/interfaces/metrics.js +46 -0
  79. package/lib/interfaces/metrics.js.map +1 -0
  80. package/lib/interfaces/observable-types.d.ts +63 -0
  81. package/lib/interfaces/observable-types.js +49 -0
  82. package/lib/interfaces/observable-types.js.map +1 -0
  83. package/lib/interfaces/observable.d.ts +297 -0
  84. package/lib/interfaces/observable.js +29 -0
  85. package/lib/interfaces/observable.js.map +1 -0
  86. package/lib/interfaces/options.d.ts +164 -0
  87. package/lib/interfaces/options.js +56 -0
  88. package/lib/interfaces/options.js.map +1 -0
  89. package/lib/interfaces/plugins.d.ts +143 -0
  90. package/lib/interfaces/plugins.js +45 -0
  91. package/lib/interfaces/plugins.js.map +1 -0
  92. package/lib/interfaces/result.d.ts +129 -0
  93. package/lib/interfaces/result.js +162 -0
  94. package/lib/interfaces/result.js.map +1 -0
  95. package/lib/interfaces/schema-events.d.ts +378 -0
  96. package/lib/interfaces/schema-events.js +247 -0
  97. package/lib/interfaces/schema-events.js.map +1 -0
  98. package/lib/interfaces/schema-types.d.ts +407 -0
  99. package/lib/interfaces/schema-types.js +581 -0
  100. package/lib/interfaces/schema-types.js.map +1 -0
  101. package/lib/interfaces/service.d.ts +48 -0
  102. package/lib/interfaces/service.js +29 -0
  103. package/lib/interfaces/service.js.map +1 -0
  104. package/lib/interfaces/tools.d.ts +65 -0
  105. package/lib/interfaces/tools.js +50 -0
  106. package/lib/interfaces/tools.js.map +1 -0
  107. package/lib/plugins/config-default/index.d.ts +59 -0
  108. package/lib/plugins/config-default/index.js +197 -0
  109. package/lib/plugins/config-default/index.js.map +1 -0
  110. package/lib/plugins/config-default/interfaces.d.ts +92 -0
  111. package/lib/plugins/config-default/interfaces.js +36 -0
  112. package/lib/plugins/config-default/interfaces.js.map +1 -0
  113. package/lib/plugins/events-default/events/broadcast.d.ts +36 -0
  114. package/lib/plugins/events-default/events/broadcast.js +85 -0
  115. package/lib/plugins/events-default/events/broadcast.js.map +1 -0
  116. package/lib/plugins/events-default/events/emit.d.ts +38 -0
  117. package/lib/plugins/events-default/events/emit.js +104 -0
  118. package/lib/plugins/events-default/events/emit.js.map +1 -0
  119. package/lib/plugins/events-default/events/emitAndReturn.d.ts +36 -0
  120. package/lib/plugins/events-default/events/emitAndReturn.js +100 -0
  121. package/lib/plugins/events-default/events/emitAndReturn.js.map +1 -0
  122. package/lib/plugins/events-default/events/emitStreamAndReceiveStream.d.ts +38 -0
  123. package/lib/plugins/events-default/events/emitStreamAndReceiveStream.js +134 -0
  124. package/lib/plugins/events-default/events/emitStreamAndReceiveStream.js.map +1 -0
  125. package/lib/plugins/events-default/events/index.d.ts +30 -0
  126. package/lib/plugins/events-default/events/index.js +38 -0
  127. package/lib/plugins/events-default/events/index.js.map +1 -0
  128. package/lib/plugins/events-default/index.d.ts +57 -0
  129. package/lib/plugins/events-default/index.js +86 -0
  130. package/lib/plugins/events-default/index.js.map +1 -0
  131. package/lib/plugins/observable-default/index.d.ts +43 -0
  132. package/lib/plugins/observable-default/index.js +151 -0
  133. package/lib/plugins/observable-default/index.js.map +1 -0
  134. package/lib/schemas/config-default.json +34 -0
  135. package/lib/schemas/config-default.plugin.json +36 -0
  136. package/lib/schemas/events-default.json +18 -0
  137. package/lib/schemas/events-default.plugin.json +17 -0
  138. package/lib/schemas/observable-default.json +33 -0
  139. package/lib/schemas/observable-default.plugin.json +24 -0
  140. package/lib/scripts/bsb-client-cli.d.ts +21 -0
  141. package/lib/scripts/bsb-client-cli.js +701 -0
  142. package/lib/scripts/bsb-client-cli.js.map +1 -0
  143. package/lib/scripts/bsb-plugin-cli.d.ts +15 -0
  144. package/lib/scripts/bsb-plugin-cli.js +547 -0
  145. package/lib/scripts/bsb-plugin-cli.js.map +1 -0
  146. package/lib/scripts/export-schemas.d.ts +17 -0
  147. package/lib/scripts/export-schemas.js +205 -0
  148. package/lib/scripts/export-schemas.js.map +1 -0
  149. package/lib/scripts/extract-schemas-from-source.d.ts +23 -0
  150. package/lib/scripts/extract-schemas-from-source.js +604 -0
  151. package/lib/scripts/extract-schemas-from-source.js.map +1 -0
  152. package/lib/scripts/generate-client-types.d.ts +22 -0
  153. package/lib/scripts/generate-client-types.js +537 -0
  154. package/lib/scripts/generate-client-types.js.map +1 -0
  155. package/lib/scripts/generate-plugin-json.d.ts +17 -0
  156. package/lib/scripts/generate-plugin-json.js +219 -0
  157. package/lib/scripts/generate-plugin-json.js.map +1 -0
  158. package/lib/serviceBase/config.d.ts +83 -0
  159. package/lib/serviceBase/config.js +236 -0
  160. package/lib/serviceBase/config.js.map +1 -0
  161. package/lib/serviceBase/events.d.ts +91 -0
  162. package/lib/serviceBase/events.js +519 -0
  163. package/lib/serviceBase/events.js.map +1 -0
  164. package/lib/serviceBase/index.d.ts +33 -0
  165. package/lib/serviceBase/index.js +50 -0
  166. package/lib/serviceBase/index.js.map +1 -0
  167. package/lib/serviceBase/observable.d.ts +249 -0
  168. package/lib/serviceBase/observable.js +551 -0
  169. package/lib/serviceBase/observable.js.map +1 -0
  170. package/lib/serviceBase/plugins.d.ts +48 -0
  171. package/lib/serviceBase/plugins.js +184 -0
  172. package/lib/serviceBase/plugins.js.map +1 -0
  173. package/lib/serviceBase/serviceBase.d.ts +228 -0
  174. package/lib/serviceBase/serviceBase.js +420 -0
  175. package/lib/serviceBase/serviceBase.js.map +1 -0
  176. package/lib/serviceBase/services.d.ts +63 -0
  177. package/lib/serviceBase/services.js +346 -0
  178. package/lib/serviceBase/services.js.map +1 -0
  179. package/lib/tests.d.ts +27 -0
  180. package/lib/tests.js +44 -0
  181. package/lib/tests.js.map +1 -0
  182. package/package.json +91 -0
@@ -0,0 +1,515 @@
1
+ "use strict";
2
+ /**
3
+ * BSB (Better-Service-Base) is an event-bus based microservice framework.
4
+ * Copyright (C) 2016 - 2025 BetterCorp (PTY) Ltd
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * Alternatively, you may obtain a commercial license for this program.
12
+ * The commercial license allows you to use the Program in a closed-source manner,
13
+ * including the right to create derivative works that are not subject to the terms
14
+ * of the AGPL.
15
+ *
16
+ * To obtain a commercial license, please contact the copyright holders at
17
+ * https://www.bettercorp.dev. The terms and conditions of the commercial license
18
+ * will be provided upon request.
19
+ *
20
+ * This program is distributed in the hope that it will be useful,
21
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ * GNU Affero General Public License for more details.
24
+ *
25
+ * You should have received a copy of the GNU Affero General Public License
26
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
27
+ */
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.ObservableBackend = void 0;
30
+ const uuid_1 = require("uuid");
31
+ const tools_1 = require("./tools");
32
+ const interfaces_1 = require("../interfaces");
33
+ const errorMessages_1 = require("./errorMessages");
34
+ const base_1 = require("./base");
35
+ /**
36
+ * Generate OpenTelemetry-compliant trace ID (32 hex chars lowercase)
37
+ * @returns 32-character hexadecimal trace ID
38
+ */
39
+ function generateTraceId() {
40
+ return (0, uuid_1.v7)().replace(/-/g, '').toLowerCase();
41
+ }
42
+ /**
43
+ * Generate OpenTelemetry-compliant span ID (16 hex chars lowercase)
44
+ * Uses random bytes to ensure uniqueness even for spans created at the same millisecond
45
+ * @returns 16-character hexadecimal span ID
46
+ */
47
+ function generateSpanId() {
48
+ // Generate 8 random bytes (64 bits) = 16 hex characters
49
+ const bytes = new Uint8Array(8);
50
+ if (typeof crypto !== 'undefined' && crypto.getRandomValues) {
51
+ crypto.getRandomValues(bytes);
52
+ }
53
+ else {
54
+ // Fallback for environments without crypto.getRandomValues
55
+ const nodeCrypto = require('crypto');
56
+ nodeCrypto.randomFillSync(bytes);
57
+ }
58
+ return Array.from(bytes)
59
+ .map(b => b.toString(16).padStart(2, '0'))
60
+ .join('')
61
+ .toLowerCase();
62
+ }
63
+ /**
64
+ * Normalize attribute keys by replacing symbols with underscores
65
+ * OpenTelemetry and many backends prefer snake_case attribute names
66
+ * @param attributes - Original attributes
67
+ * @returns Normalized attributes with safe key names
68
+ */
69
+ function normalizeAttributes(attributes) {
70
+ if (!attributes)
71
+ return attributes;
72
+ const normalized = {};
73
+ for (const [key, value] of Object.entries(attributes)) {
74
+ // Replace periods, colons, slashes, and spaces with underscores
75
+ const normalizedKey = key.replace(/[.:/\s-]/g, '_');
76
+ normalized[normalizedKey] = value;
77
+ }
78
+ return normalized;
79
+ }
80
+ /**
81
+ * @hidden
82
+ */
83
+ function internalTrace(span) {
84
+ return (0, interfaces_1.createFakeDTrace)("base/ObservableBackend", span);
85
+ }
86
+ /**
87
+ * Represents a single span in a distributed trace
88
+ *
89
+ * A span tracks a specific operation within a trace, with a unique span ID.
90
+ * Spans form parent-child relationships to represent the call hierarchy.
91
+ *
92
+ * @internal
93
+ * @hidden
94
+ */
95
+ class ObservableBackendSpan {
96
+ _traceId;
97
+ _spanId;
98
+ pluginName;
99
+ backend;
100
+ appId;
101
+ /**
102
+ * Create a new span
103
+ * @param backend - Observable backend for emitting span events
104
+ * @param appId - Application ID
105
+ * @param pluginName - Name of the plugin creating the span
106
+ * @param traceId - Trace ID (unique for the entire trace)
107
+ * @param parentSpanId - Parent span ID (null for root spans)
108
+ * @param spanId - This span's unique ID
109
+ * @param name - Name of the span (e.g., "database-query")
110
+ * @param attributes - Optional attributes to attach to the span
111
+ */
112
+ constructor(backend, appId, pluginName, traceId, parentSpanId, spanId, name, attributes) {
113
+ this.backend = backend;
114
+ this.appId = appId;
115
+ this.pluginName = pluginName;
116
+ this._traceId = traceId;
117
+ this._spanId = spanId;
118
+ // Normalize attribute keys for compatibility with observability backends
119
+ const normalizedAttrs = normalizeAttributes(attributes);
120
+ this.backend.startSpan(Date.now(), this.appId, this.pluginName, traceId, parentSpanId, spanId, name, normalizedAttrs);
121
+ }
122
+ /**
123
+ * Get the span ID
124
+ * @returns The unique span ID
125
+ */
126
+ get id() {
127
+ return this._spanId;
128
+ }
129
+ /**
130
+ * Get the DTrace object (trace ID + span ID)
131
+ * @returns DTrace object containing trace ID and span ID
132
+ */
133
+ get trace() {
134
+ return {
135
+ t: this._traceId,
136
+ s: this._spanId,
137
+ };
138
+ }
139
+ /**
140
+ * End the span
141
+ * @param attributes - Final attributes to attach before ending
142
+ */
143
+ end(attributes) {
144
+ const normalizedAttrs = normalizeAttributes(attributes);
145
+ this.backend.endSpan(Date.now(), this.appId, this.pluginName, this._traceId, this._spanId, normalizedAttrs);
146
+ }
147
+ /**
148
+ * Record an error on the span
149
+ * @param error - Error or BSBError to record
150
+ * @param attributes - Additional attributes to attach to the error
151
+ */
152
+ error(error, attributes) {
153
+ const normalizedAttrs = normalizeAttributes(attributes);
154
+ this.backend.errorSpan(Date.now(), this.appId, this.pluginName, this._traceId, this._spanId, error, normalizedAttrs);
155
+ }
156
+ }
157
+ /**
158
+ * Represents a complete trace with an associated span
159
+ *
160
+ * A trace represents the entire journey of a request through the system.
161
+ * Each trace contains one or more spans representing individual operations.
162
+ *
163
+ * @internal
164
+ * @hidden
165
+ */
166
+ class ObservableBackendTrace {
167
+ _traceId;
168
+ _span;
169
+ backend;
170
+ appId;
171
+ pluginName;
172
+ constructor(backend, appId, pluginName, trace, opts) {
173
+ this.backend = backend;
174
+ this.appId = appId;
175
+ this.pluginName = pluginName;
176
+ // Use OpenTelemetry-compliant IDs: trace ID (32 hex chars), span ID (16 hex chars)
177
+ this._traceId = trace?.t ?? generateTraceId();
178
+ const spanId = generateSpanId();
179
+ this._span = new ObservableBackendSpan(this.backend, this.appId, this.pluginName, this._traceId, trace?.s ?? null, spanId, opts.name, opts?.attributes);
180
+ }
181
+ /**
182
+ * Get the trace ID
183
+ * @returns The unique trace ID
184
+ */
185
+ get id() {
186
+ return this._traceId;
187
+ }
188
+ /**
189
+ * Record an error on the trace's span
190
+ * @param error - Error or BSBError to record
191
+ * @param attributes - Additional attributes to attach to the error
192
+ */
193
+ error(error, attributes) {
194
+ this._span.error(error, attributes);
195
+ }
196
+ /**
197
+ * Get the DTrace object (trace ID + current span ID)
198
+ * @returns DTrace object containing trace ID and current span ID
199
+ */
200
+ get trace() {
201
+ return { t: this._traceId, s: this._span.id };
202
+ }
203
+ /**
204
+ * End the trace by ending its associated span
205
+ * @param attributes - Final attributes to attach before ending
206
+ */
207
+ end(attributes) {
208
+ this._span.end(attributes);
209
+ }
210
+ }
211
+ /**
212
+ * Observable Backend - Unified backend for logging and metrics
213
+ *
214
+ * This is the internal backend that handles both logging and metrics operations.
215
+ * It replaces the separate PluginLogging and PluginMetrics classes with a single
216
+ * unified implementation.
217
+ *
218
+ * @group Observable
219
+ * @category Plugin Development Tools
220
+ * @internal
221
+ *
222
+ * @example
223
+ * ```typescript
224
+ * // Internal use only - plugins use Observable interface
225
+ * const backend = new ObservableBackend(
226
+ * 'development',
227
+ * 'my-app',
228
+ * 'my-plugin',
229
+ * sbObservable
230
+ * );
231
+ * ```
232
+ */
233
+ class ObservableBackend {
234
+ bus;
235
+ pluginName;
236
+ appId;
237
+ canDebug = false;
238
+ /**
239
+ * Create an ObservableBackend instance
240
+ * @param mode - Debug mode setting
241
+ * @param appId - Application ID
242
+ * @param pluginName - Plugin name
243
+ * @param bus - Observable bus for emitting events
244
+ */
245
+ constructor(mode, appId, pluginName, bus) {
246
+ this.bus = bus;
247
+ this.pluginName = pluginName;
248
+ this.appId = appId;
249
+ if (mode !== "production") {
250
+ this.canDebug = true;
251
+ }
252
+ }
253
+ // ==================== LOGGING METHODS ====================
254
+ /**
255
+ * Logs a debug message
256
+ *
257
+ * @param trace - The trace to associate with the log
258
+ * @param message - The message to log
259
+ * @param meta - Additional information to log with the message
260
+ * @returns nothing
261
+ *
262
+ * @example
263
+ * ```ts
264
+ * backend.debug(trace, "This is a debug log");
265
+ * backend.debug(trace, "This is a debug {key}", {"key": "log"});
266
+ * ```
267
+ */
268
+ debug(trace, message, ...meta) {
269
+ if (!this.canDebug)
270
+ return; // Early return for performance
271
+ this.bus.debug(this.pluginName, trace, message, ...meta);
272
+ }
273
+ /**
274
+ * Logs an info message
275
+ *
276
+ * @param trace - The trace to associate with the log
277
+ * @param message - The message to log
278
+ * @param meta - Additional information to log with the message
279
+ * @returns nothing
280
+ *
281
+ * @example
282
+ * ```ts
283
+ * backend.info(trace, "This is an info log");
284
+ * backend.info(trace, "This is an info {key}", {"key": "log"});
285
+ * ```
286
+ */
287
+ info(trace, message, ...meta) {
288
+ this.bus.info(this.pluginName, trace, message, ...meta);
289
+ }
290
+ /**
291
+ * Logs a warn message
292
+ *
293
+ * @param trace - The trace to associate with the log
294
+ * @param message - The message to log
295
+ * @param meta - Additional information to log with the message
296
+ * @returns nothing
297
+ *
298
+ * @example
299
+ * ```ts
300
+ * backend.warn(trace, "This is a warn log");
301
+ * backend.warn(trace, "This is a warn {key}", {"key": "log"});
302
+ * ```
303
+ */
304
+ warn(trace, message, ...meta) {
305
+ this.bus.warn(this.pluginName, trace, message, ...meta);
306
+ }
307
+ error(traceOrError, message, ...meta) {
308
+ if (traceOrError instanceof errorMessages_1.BSBError) {
309
+ if (traceOrError.raw !== null) {
310
+ this.bus.error(this.pluginName, traceOrError.raw.trace, traceOrError.raw.message, traceOrError.raw.meta);
311
+ return;
312
+ }
313
+ this.error((0, interfaces_1.createFakeDTrace)('base/ObservableBackend', 'error'), traceOrError.message + ' - error ');
314
+ return;
315
+ }
316
+ if (!tools_1.Tools.isObject(traceOrError) || !tools_1.Tools.isString(traceOrError.t) || !tools_1.Tools.isString(traceOrError.s)) {
317
+ this.error((0, interfaces_1.createFakeDTrace)('base/ObservableBackend', 'errorType'), JSON.stringify(traceOrError));
318
+ return;
319
+ }
320
+ this.bus.error(this.pluginName, traceOrError, message, ...meta);
321
+ }
322
+ // ==================== METRICS METHODS ====================
323
+ /**
324
+ * Create a counter metric
325
+ *
326
+ * Counters are monotonically increasing values used to track cumulative totals.
327
+ * Common uses: request counts, error counts, bytes processed.
328
+ *
329
+ * @param name - Metric name (e.g., "requests_total")
330
+ * @param description - Short description
331
+ * @param help - Detailed help text
332
+ * @param labels - Optional label names for dimensional metrics
333
+ * @returns Counter instance with increment method
334
+ *
335
+ * @example
336
+ * ```typescript
337
+ * const requests = backend.createCounter(
338
+ * "http_requests_total",
339
+ * "Total HTTP requests",
340
+ * "Count of all HTTP requests received",
341
+ * ["method", "status"]
342
+ * );
343
+ * requests.increment(1, { method: "GET", status: "200" });
344
+ * ```
345
+ */
346
+ createCounter(name, description, help, labels) {
347
+ if (!this.bus.isReady) {
348
+ throw new errorMessages_1.BSBError(internalTrace("createCounter"), "Metrics not ready!");
349
+ }
350
+ this.bus.createCounter(Date.now(), this.pluginName, name, description, help, labels);
351
+ return {
352
+ increment: (value = 1, labels) => {
353
+ this.bus.incrementCounter(Date.now(), this.pluginName, name, value, labels);
354
+ },
355
+ };
356
+ }
357
+ /**
358
+ * Create a gauge metric
359
+ *
360
+ * Gauges represent point-in-time values that can go up or down.
361
+ * Common uses: memory usage, active connections, queue depth, temperature.
362
+ *
363
+ * @param name - Metric name (e.g., "active_connections")
364
+ * @param description - Short description
365
+ * @param help - Detailed help text
366
+ * @param labels - Optional label names for dimensional metrics
367
+ * @returns Gauge instance with set, increment, and decrement methods
368
+ *
369
+ * @example
370
+ * ```typescript
371
+ * const activeConns = backend.createGauge(
372
+ * "active_connections",
373
+ * "Active connections",
374
+ * "Number of currently active connections"
375
+ * );
376
+ * activeConns.set(42);
377
+ * activeConns.increment(1);
378
+ * activeConns.decrement(1);
379
+ * ```
380
+ */
381
+ createGauge(name, description, help, labels) {
382
+ if (!this.bus.isReady) {
383
+ throw new errorMessages_1.BSBError(internalTrace("createGauge"), "Metrics not ready!");
384
+ }
385
+ this.bus.createGauge(Date.now(), this.pluginName, name, description, help, labels);
386
+ return {
387
+ set: (value, labels) => {
388
+ this.bus.setGauge(Date.now(), this.pluginName, name, value, labels);
389
+ },
390
+ increment: (value = 1, labels) => {
391
+ // Note: Observable plugins should track current value and add internally
392
+ this.bus.setGauge(Date.now(), this.pluginName, name, value, labels);
393
+ },
394
+ decrement: (value = 1, labels) => {
395
+ // Note: Observable plugins should track current value and subtract internally
396
+ this.bus.setGauge(Date.now(), this.pluginName, name, -value, labels);
397
+ },
398
+ };
399
+ }
400
+ /**
401
+ * Create a histogram metric
402
+ *
403
+ * Histograms track the distribution of values over time.
404
+ * Common uses: request duration, response size, batch size.
405
+ *
406
+ * @param name - Metric name (e.g., "request_duration_ms")
407
+ * @param description - Short description
408
+ * @param help - Detailed help text
409
+ * @param boundaries - Optional bucket boundaries (default: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10])
410
+ * @param labels - Optional label names for dimensional metrics
411
+ * @returns Histogram instance with record method
412
+ *
413
+ * @example
414
+ * ```typescript
415
+ * const duration = backend.createHistogram(
416
+ * "request_duration_ms",
417
+ * "Request duration",
418
+ * "Duration of HTTP requests in milliseconds",
419
+ * [10, 50, 100, 500, 1000, 5000],
420
+ * ["method"]
421
+ * );
422
+ * duration.record(125, { method: "GET" });
423
+ * ```
424
+ */
425
+ createHistogram(name, description, help, boundaries, labels) {
426
+ if (!this.bus.isReady) {
427
+ throw new errorMessages_1.BSBError(internalTrace("createHistogram"), "Metrics not ready!");
428
+ }
429
+ this.bus.createHistogram(Date.now(), this.pluginName, name, description, help, boundaries, labels);
430
+ return {
431
+ record: (value, labels) => {
432
+ this.bus.observeHistogram(Date.now(), this.pluginName, name, value, labels);
433
+ },
434
+ };
435
+ }
436
+ /**
437
+ * Create a new distributed trace
438
+ *
439
+ * Creates a root trace with no parent. Use this when starting a new
440
+ * request or operation that should be tracked independently.
441
+ *
442
+ * @param name - Name of the trace/span (e.g., "http-request")
443
+ * @param attributes - Optional attributes to attach to the trace
444
+ * @returns Trace instance
445
+ *
446
+ * @example
447
+ * ```typescript
448
+ * const trace = backend.createTrace("process-batch", {
449
+ * "batch.size": 100
450
+ * });
451
+ * // ... do work ...
452
+ * trace.end({ "batch.processed": 100 });
453
+ * ```
454
+ */
455
+ createTrace(name, attributes) {
456
+ if (!this.bus.isReady) {
457
+ throw new errorMessages_1.BSBError(internalTrace("createTrace"), "Metrics not ready!");
458
+ }
459
+ return new ObservableBackendTrace(this.bus, this.appId, this.pluginName, null, { name, attributes });
460
+ }
461
+ /**
462
+ * Create a child span within an existing trace
463
+ *
464
+ * Creates a child span that inherits the trace ID from the parent.
465
+ * This is used internally by Observable.startSpan().
466
+ *
467
+ * @param trace - Parent DTrace object
468
+ * @param name - Name of the span (e.g., "database-query")
469
+ * @param attributes - Optional attributes to attach to the span
470
+ * @returns Trace instance representing the child span
471
+ *
472
+ * @example
473
+ * ```typescript
474
+ * // Usually accessed via Observable
475
+ * const childSpan = backend.createSpan(trace, "database-query");
476
+ * // ... do work ...
477
+ * childSpan.end();
478
+ * ```
479
+ */
480
+ createSpan(trace, name, attributes) {
481
+ if (!this.bus.isReady) {
482
+ throw new errorMessages_1.BSBError(internalTrace("createSpan"), "Metrics not ready!");
483
+ }
484
+ return new ObservableBackendTrace(this.bus, this.appId, this.pluginName, trace, { name, attributes });
485
+ }
486
+ /**
487
+ * Create a high-resolution timer
488
+ *
489
+ * Returns a timer that can measure elapsed time in milliseconds with
490
+ * sub-millisecond precision using Node.js hrtime.
491
+ *
492
+ * @returns Timer instance with stop method
493
+ *
494
+ * @example
495
+ * ```typescript
496
+ * const timer = backend.createTimer();
497
+ * await performOperation();
498
+ * const elapsed = timer.stop();
499
+ * ```
500
+ */
501
+ createTimer() {
502
+ if (!this.bus.isReady) {
503
+ throw new errorMessages_1.BSBError(internalTrace("createTimer"), "Metrics not ready!");
504
+ }
505
+ const start = process.hrtime();
506
+ return {
507
+ stop: () => {
508
+ const diff = process.hrtime(start);
509
+ return (diff[0] * base_1.NS_PER_SEC + diff[1]) * base_1.MS_PER_NS;
510
+ }
511
+ };
512
+ }
513
+ }
514
+ exports.ObservableBackend = ObservableBackend;
515
+ //# sourceMappingURL=ObservableBackend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObservableBackend.js","sourceRoot":"","sources":["../../src/base/ObservableBackend.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AAEH,+BAAoC;AACpC,mCAAgC;AAChC,8CAWuB;AACvB,mDAA2C;AAC3C,iCAA+C;AAE/C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