@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.
- package/LICENSE +665 -0
- package/LICENSE.commercial +32 -0
- package/README.md +263 -0
- package/bsb-plugin.json +62 -0
- package/lib/base/BSBConfig.d.ts +130 -0
- package/lib/base/BSBConfig.js +95 -0
- package/lib/base/BSBConfig.js.map +1 -0
- package/lib/base/BSBEvents.d.ts +207 -0
- package/lib/base/BSBEvents.js +101 -0
- package/lib/base/BSBEvents.js.map +1 -0
- package/lib/base/BSBObservable.d.ts +178 -0
- package/lib/base/BSBObservable.js +91 -0
- package/lib/base/BSBObservable.js.map +1 -0
- package/lib/base/BSBService.d.ts +277 -0
- package/lib/base/BSBService.js +366 -0
- package/lib/base/BSBService.js.map +1 -0
- package/lib/base/BSBServiceClient.d.ts +135 -0
- package/lib/base/BSBServiceClient.js +130 -0
- package/lib/base/BSBServiceClient.js.map +1 -0
- package/lib/base/EventValidator.d.ts +137 -0
- package/lib/base/EventValidator.js +210 -0
- package/lib/base/EventValidator.js.map +1 -0
- package/lib/base/ObservableBackend.d.ts +281 -0
- package/lib/base/ObservableBackend.js +515 -0
- package/lib/base/ObservableBackend.js.map +1 -0
- package/lib/base/PluginConfig.d.ts +196 -0
- package/lib/base/PluginConfig.js +96 -0
- package/lib/base/PluginConfig.js.map +1 -0
- package/lib/base/PluginEvents.d.ts +140 -0
- package/lib/base/PluginEvents.js +268 -0
- package/lib/base/PluginEvents.js.map +1 -0
- package/lib/base/PluginObservable.d.ts +196 -0
- package/lib/base/PluginObservable.js +250 -0
- package/lib/base/PluginObservable.js.map +1 -0
- package/lib/base/ResourceContext.d.ts +70 -0
- package/lib/base/ResourceContext.js +54 -0
- package/lib/base/ResourceContext.js.map +1 -0
- package/lib/base/base.d.ts +264 -0
- package/lib/base/base.js +182 -0
- package/lib/base/base.js.map +1 -0
- package/lib/base/errorMessages.d.ts +56 -0
- package/lib/base/errorMessages.js +70 -0
- package/lib/base/errorMessages.js.map +1 -0
- package/lib/base/factory.d.ts +58 -0
- package/lib/base/factory.js +167 -0
- package/lib/base/factory.js.map +1 -0
- package/lib/base/functions.d.ts +117 -0
- package/lib/base/functions.js +152 -0
- package/lib/base/functions.js.map +1 -0
- package/lib/base/index.d.ts +44 -0
- package/lib/base/index.js +64 -0
- package/lib/base/index.js.map +1 -0
- package/lib/base/logFormatter.d.ts +50 -0
- package/lib/base/logFormatter.js +105 -0
- package/lib/base/logFormatter.js.map +1 -0
- package/lib/base/tools.d.ts +316 -0
- package/lib/base/tools.js +666 -0
- package/lib/base/tools.js.map +1 -0
- package/lib/cli.d.ts +28 -0
- package/lib/cli.js +254 -0
- package/lib/cli.js.map +1 -0
- package/lib/dev.d.ts +27 -0
- package/lib/dev.js +200 -0
- package/lib/dev.js.map +1 -0
- package/lib/index.d.ts +32 -0
- package/lib/index.js +49 -0
- package/lib/index.js.map +1 -0
- package/lib/interfaces/events.d.ts +67 -0
- package/lib/interfaces/events.js +44 -0
- package/lib/interfaces/events.js.map +1 -0
- package/lib/interfaces/index.d.ts +38 -0
- package/lib/interfaces/index.js +59 -0
- package/lib/interfaces/index.js.map +1 -0
- package/lib/interfaces/logging.d.ts +106 -0
- package/lib/interfaces/logging.js +39 -0
- package/lib/interfaces/logging.js.map +1 -0
- package/lib/interfaces/metrics.d.ts +365 -0
- package/lib/interfaces/metrics.js +46 -0
- package/lib/interfaces/metrics.js.map +1 -0
- package/lib/interfaces/observable-types.d.ts +63 -0
- package/lib/interfaces/observable-types.js +49 -0
- package/lib/interfaces/observable-types.js.map +1 -0
- package/lib/interfaces/observable.d.ts +297 -0
- package/lib/interfaces/observable.js +29 -0
- package/lib/interfaces/observable.js.map +1 -0
- package/lib/interfaces/options.d.ts +164 -0
- package/lib/interfaces/options.js +56 -0
- package/lib/interfaces/options.js.map +1 -0
- package/lib/interfaces/plugins.d.ts +143 -0
- package/lib/interfaces/plugins.js +45 -0
- package/lib/interfaces/plugins.js.map +1 -0
- package/lib/interfaces/result.d.ts +129 -0
- package/lib/interfaces/result.js +162 -0
- package/lib/interfaces/result.js.map +1 -0
- package/lib/interfaces/schema-events.d.ts +378 -0
- package/lib/interfaces/schema-events.js +247 -0
- package/lib/interfaces/schema-events.js.map +1 -0
- package/lib/interfaces/schema-types.d.ts +407 -0
- package/lib/interfaces/schema-types.js +581 -0
- package/lib/interfaces/schema-types.js.map +1 -0
- package/lib/interfaces/service.d.ts +48 -0
- package/lib/interfaces/service.js +29 -0
- package/lib/interfaces/service.js.map +1 -0
- package/lib/interfaces/tools.d.ts +65 -0
- package/lib/interfaces/tools.js +50 -0
- package/lib/interfaces/tools.js.map +1 -0
- package/lib/plugins/config-default/index.d.ts +59 -0
- package/lib/plugins/config-default/index.js +197 -0
- package/lib/plugins/config-default/index.js.map +1 -0
- package/lib/plugins/config-default/interfaces.d.ts +92 -0
- package/lib/plugins/config-default/interfaces.js +36 -0
- package/lib/plugins/config-default/interfaces.js.map +1 -0
- package/lib/plugins/events-default/events/broadcast.d.ts +36 -0
- package/lib/plugins/events-default/events/broadcast.js +85 -0
- package/lib/plugins/events-default/events/broadcast.js.map +1 -0
- package/lib/plugins/events-default/events/emit.d.ts +38 -0
- package/lib/plugins/events-default/events/emit.js +104 -0
- package/lib/plugins/events-default/events/emit.js.map +1 -0
- package/lib/plugins/events-default/events/emitAndReturn.d.ts +36 -0
- package/lib/plugins/events-default/events/emitAndReturn.js +100 -0
- package/lib/plugins/events-default/events/emitAndReturn.js.map +1 -0
- package/lib/plugins/events-default/events/emitStreamAndReceiveStream.d.ts +38 -0
- package/lib/plugins/events-default/events/emitStreamAndReceiveStream.js +134 -0
- package/lib/plugins/events-default/events/emitStreamAndReceiveStream.js.map +1 -0
- package/lib/plugins/events-default/events/index.d.ts +30 -0
- package/lib/plugins/events-default/events/index.js +38 -0
- package/lib/plugins/events-default/events/index.js.map +1 -0
- package/lib/plugins/events-default/index.d.ts +57 -0
- package/lib/plugins/events-default/index.js +86 -0
- package/lib/plugins/events-default/index.js.map +1 -0
- package/lib/plugins/observable-default/index.d.ts +43 -0
- package/lib/plugins/observable-default/index.js +151 -0
- package/lib/plugins/observable-default/index.js.map +1 -0
- package/lib/schemas/config-default.json +34 -0
- package/lib/schemas/config-default.plugin.json +36 -0
- package/lib/schemas/events-default.json +18 -0
- package/lib/schemas/events-default.plugin.json +17 -0
- package/lib/schemas/observable-default.json +33 -0
- package/lib/schemas/observable-default.plugin.json +24 -0
- package/lib/scripts/bsb-client-cli.d.ts +21 -0
- package/lib/scripts/bsb-client-cli.js +701 -0
- package/lib/scripts/bsb-client-cli.js.map +1 -0
- package/lib/scripts/bsb-plugin-cli.d.ts +15 -0
- package/lib/scripts/bsb-plugin-cli.js +547 -0
- package/lib/scripts/bsb-plugin-cli.js.map +1 -0
- package/lib/scripts/export-schemas.d.ts +17 -0
- package/lib/scripts/export-schemas.js +205 -0
- package/lib/scripts/export-schemas.js.map +1 -0
- package/lib/scripts/extract-schemas-from-source.d.ts +23 -0
- package/lib/scripts/extract-schemas-from-source.js +604 -0
- package/lib/scripts/extract-schemas-from-source.js.map +1 -0
- package/lib/scripts/generate-client-types.d.ts +22 -0
- package/lib/scripts/generate-client-types.js +537 -0
- package/lib/scripts/generate-client-types.js.map +1 -0
- package/lib/scripts/generate-plugin-json.d.ts +17 -0
- package/lib/scripts/generate-plugin-json.js +219 -0
- package/lib/scripts/generate-plugin-json.js.map +1 -0
- package/lib/serviceBase/config.d.ts +83 -0
- package/lib/serviceBase/config.js +236 -0
- package/lib/serviceBase/config.js.map +1 -0
- package/lib/serviceBase/events.d.ts +91 -0
- package/lib/serviceBase/events.js +519 -0
- package/lib/serviceBase/events.js.map +1 -0
- package/lib/serviceBase/index.d.ts +33 -0
- package/lib/serviceBase/index.js +50 -0
- package/lib/serviceBase/index.js.map +1 -0
- package/lib/serviceBase/observable.d.ts +249 -0
- package/lib/serviceBase/observable.js +551 -0
- package/lib/serviceBase/observable.js.map +1 -0
- package/lib/serviceBase/plugins.d.ts +48 -0
- package/lib/serviceBase/plugins.js +184 -0
- package/lib/serviceBase/plugins.js.map +1 -0
- package/lib/serviceBase/serviceBase.d.ts +228 -0
- package/lib/serviceBase/serviceBase.js +420 -0
- package/lib/serviceBase/serviceBase.js.map +1 -0
- package/lib/serviceBase/services.d.ts +63 -0
- package/lib/serviceBase/services.js +346 -0
- package/lib/serviceBase/services.js.map +1 -0
- package/lib/tests.d.ts +27 -0
- package/lib/tests.js +44 -0
- package/lib/tests.js.map +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BSB (Better-Service-Base) is an event-bus based microservice framework.
|
|
3
|
+
* Copyright (C) 2016 - 2025 BetterCorp (PTY) Ltd
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published
|
|
7
|
+
* by the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* Alternatively, you may obtain a commercial license for this program.
|
|
11
|
+
* The commercial license allows you to use the Program in a closed-source manner,
|
|
12
|
+
* including the right to create derivative works that are not subject to the terms
|
|
13
|
+
* of the AGPL.
|
|
14
|
+
*
|
|
15
|
+
* To obtain a commercial license, please contact the copyright holders at
|
|
16
|
+
* https://www.bettercorp.dev. The terms and conditions of the commercial license
|
|
17
|
+
* will be provided upon request.
|
|
18
|
+
*
|
|
19
|
+
* This program is distributed in the hope that it will be useful,
|
|
20
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
21
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
22
|
+
* GNU Affero General Public License for more details.
|
|
23
|
+
*
|
|
24
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
25
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
26
|
+
*/
|
|
27
|
+
import { Counter, DEBUG_MODE, DTrace, Gauge, Histogram, SmartLogMeta, Timer, Trace } from "../interfaces";
|
|
28
|
+
import { BSBError } from "./errorMessages";
|
|
29
|
+
/**
|
|
30
|
+
* Observable bus interface - unified for both logging and metrics
|
|
31
|
+
* @hidden
|
|
32
|
+
*/
|
|
33
|
+
interface ObservableBus {
|
|
34
|
+
readonly isReady: boolean;
|
|
35
|
+
debug(plugin: string, trace: DTrace, message: string, ...meta: any[]): void;
|
|
36
|
+
info(plugin: string, trace: DTrace, message: string, ...meta: any[]): void;
|
|
37
|
+
warn(plugin: string, trace: DTrace, message: string, ...meta: any[]): void;
|
|
38
|
+
error(plugin: string, trace: DTrace, message: string | BSBError<any>, ...meta: any[]): void;
|
|
39
|
+
createCounter(timestamp: number, pluginName: string, name: string, description: string, help: string, labels?: string[]): void;
|
|
40
|
+
incrementCounter(timestamp: number, pluginName: string, name: string, value: number, labels?: Record<string, string>): void;
|
|
41
|
+
createGauge(timestamp: number, pluginName: string, name: string, description: string, help: string, labels?: string[]): void;
|
|
42
|
+
setGauge(timestamp: number, pluginName: string, name: string, value: number, labels?: Record<string, string>): void;
|
|
43
|
+
createHistogram(timestamp: number, pluginName: string, name: string, description: string, help: string, boundaries?: number[], labels?: string[]): void;
|
|
44
|
+
observeHistogram(timestamp: number, pluginName: string, name: string, value: number, labels?: Record<string, string>): void;
|
|
45
|
+
startSpan(timestamp: number, appId: string, pluginName: string, traceId: string, parentSpanId: string | null, spanId: string, name: string, attributes?: Record<string, string | number | boolean>): void;
|
|
46
|
+
endSpan(timestamp: number, appId: string, pluginName: string, traceId: string, spanId: string, attributes?: Record<string, string | number | boolean>): void;
|
|
47
|
+
errorSpan(timestamp: number, appId: string, pluginName: string, traceId: string, spanId: string, error: Error, attributes?: Record<string, string | number | boolean>): void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Observable Backend - Unified backend for logging and metrics
|
|
51
|
+
*
|
|
52
|
+
* This is the internal backend that handles both logging and metrics operations.
|
|
53
|
+
* It replaces the separate PluginLogging and PluginMetrics classes with a single
|
|
54
|
+
* unified implementation.
|
|
55
|
+
*
|
|
56
|
+
* @group Observable
|
|
57
|
+
* @category Plugin Development Tools
|
|
58
|
+
* @internal
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* // Internal use only - plugins use Observable interface
|
|
63
|
+
* const backend = new ObservableBackend(
|
|
64
|
+
* 'development',
|
|
65
|
+
* 'my-app',
|
|
66
|
+
* 'my-plugin',
|
|
67
|
+
* sbObservable
|
|
68
|
+
* );
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare class ObservableBackend {
|
|
72
|
+
private bus;
|
|
73
|
+
private pluginName;
|
|
74
|
+
private appId;
|
|
75
|
+
private canDebug;
|
|
76
|
+
/**
|
|
77
|
+
* Create an ObservableBackend instance
|
|
78
|
+
* @param mode - Debug mode setting
|
|
79
|
+
* @param appId - Application ID
|
|
80
|
+
* @param pluginName - Plugin name
|
|
81
|
+
* @param bus - Observable bus for emitting events
|
|
82
|
+
*/
|
|
83
|
+
constructor(mode: DEBUG_MODE, appId: string, pluginName: string, bus: ObservableBus);
|
|
84
|
+
/**
|
|
85
|
+
* Logs a debug message
|
|
86
|
+
*
|
|
87
|
+
* @param trace - The trace to associate with the log
|
|
88
|
+
* @param message - The message to log
|
|
89
|
+
* @param meta - Additional information to log with the message
|
|
90
|
+
* @returns nothing
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* backend.debug(trace, "This is a debug log");
|
|
95
|
+
* backend.debug(trace, "This is a debug {key}", {"key": "log"});
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
debug<T extends string>(trace: DTrace, message: T, ...meta: SmartLogMeta<T>): void;
|
|
99
|
+
/**
|
|
100
|
+
* Logs an info message
|
|
101
|
+
*
|
|
102
|
+
* @param trace - The trace to associate with the log
|
|
103
|
+
* @param message - The message to log
|
|
104
|
+
* @param meta - Additional information to log with the message
|
|
105
|
+
* @returns nothing
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* backend.info(trace, "This is an info log");
|
|
110
|
+
* backend.info(trace, "This is an info {key}", {"key": "log"});
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
info<T extends string>(trace: DTrace, message: T, ...meta: SmartLogMeta<T>): void;
|
|
114
|
+
/**
|
|
115
|
+
* Logs a warn message
|
|
116
|
+
*
|
|
117
|
+
* @param trace - The trace to associate with the log
|
|
118
|
+
* @param message - The message to log
|
|
119
|
+
* @param meta - Additional information to log with the message
|
|
120
|
+
* @returns nothing
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* backend.warn(trace, "This is a warn log");
|
|
125
|
+
* backend.warn(trace, "This is a warn {key}", {"key": "log"});
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
warn<T extends string>(trace: DTrace, message: T, ...meta: SmartLogMeta<T>): void;
|
|
129
|
+
/**
|
|
130
|
+
* Logs an error message
|
|
131
|
+
*
|
|
132
|
+
* @param trace - The trace to associate with the log
|
|
133
|
+
* @param message - The message to log
|
|
134
|
+
* @param meta - Additional information to log with the message
|
|
135
|
+
* @returns nothing
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* backend.error(trace, "This is an error log");
|
|
140
|
+
* backend.error(trace, "This is an error {key}", {"key": "log"});
|
|
141
|
+
* ```
|
|
142
|
+
* ```ts
|
|
143
|
+
* backend.error(new BSBError(trace, "error-key", "This is an error log"));
|
|
144
|
+
* backend.error(new BSBError(trace, "error-key", "This is an error {key}", {"key": "log"}));
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
error<T extends string>(trace: DTrace, message: T, ...meta: SmartLogMeta<T>): void;
|
|
148
|
+
error<T extends string>(error: BSBError<T>): void;
|
|
149
|
+
/**
|
|
150
|
+
* Create a counter metric
|
|
151
|
+
*
|
|
152
|
+
* Counters are monotonically increasing values used to track cumulative totals.
|
|
153
|
+
* Common uses: request counts, error counts, bytes processed.
|
|
154
|
+
*
|
|
155
|
+
* @param name - Metric name (e.g., "requests_total")
|
|
156
|
+
* @param description - Short description
|
|
157
|
+
* @param help - Detailed help text
|
|
158
|
+
* @param labels - Optional label names for dimensional metrics
|
|
159
|
+
* @returns Counter instance with increment method
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* const requests = backend.createCounter(
|
|
164
|
+
* "http_requests_total",
|
|
165
|
+
* "Total HTTP requests",
|
|
166
|
+
* "Count of all HTTP requests received",
|
|
167
|
+
* ["method", "status"]
|
|
168
|
+
* );
|
|
169
|
+
* requests.increment(1, { method: "GET", status: "200" });
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
createCounter<LABELS extends string | undefined>(name: string, description: string, help: string, labels?: LABELS[]): Counter<LABELS>;
|
|
173
|
+
/**
|
|
174
|
+
* Create a gauge metric
|
|
175
|
+
*
|
|
176
|
+
* Gauges represent point-in-time values that can go up or down.
|
|
177
|
+
* Common uses: memory usage, active connections, queue depth, temperature.
|
|
178
|
+
*
|
|
179
|
+
* @param name - Metric name (e.g., "active_connections")
|
|
180
|
+
* @param description - Short description
|
|
181
|
+
* @param help - Detailed help text
|
|
182
|
+
* @param labels - Optional label names for dimensional metrics
|
|
183
|
+
* @returns Gauge instance with set, increment, and decrement methods
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* const activeConns = backend.createGauge(
|
|
188
|
+
* "active_connections",
|
|
189
|
+
* "Active connections",
|
|
190
|
+
* "Number of currently active connections"
|
|
191
|
+
* );
|
|
192
|
+
* activeConns.set(42);
|
|
193
|
+
* activeConns.increment(1);
|
|
194
|
+
* activeConns.decrement(1);
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
createGauge<LABELS extends string | undefined>(name: string, description: string, help: string, labels?: LABELS[]): Gauge<LABELS>;
|
|
198
|
+
/**
|
|
199
|
+
* Create a histogram metric
|
|
200
|
+
*
|
|
201
|
+
* Histograms track the distribution of values over time.
|
|
202
|
+
* Common uses: request duration, response size, batch size.
|
|
203
|
+
*
|
|
204
|
+
* @param name - Metric name (e.g., "request_duration_ms")
|
|
205
|
+
* @param description - Short description
|
|
206
|
+
* @param help - Detailed help text
|
|
207
|
+
* @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])
|
|
208
|
+
* @param labels - Optional label names for dimensional metrics
|
|
209
|
+
* @returns Histogram instance with record method
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* const duration = backend.createHistogram(
|
|
214
|
+
* "request_duration_ms",
|
|
215
|
+
* "Request duration",
|
|
216
|
+
* "Duration of HTTP requests in milliseconds",
|
|
217
|
+
* [10, 50, 100, 500, 1000, 5000],
|
|
218
|
+
* ["method"]
|
|
219
|
+
* );
|
|
220
|
+
* duration.record(125, { method: "GET" });
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
createHistogram<LABELS extends string | undefined>(name: string, description: string, help: string, boundaries?: number[], labels?: LABELS[]): Histogram<LABELS>;
|
|
224
|
+
/**
|
|
225
|
+
* Create a new distributed trace
|
|
226
|
+
*
|
|
227
|
+
* Creates a root trace with no parent. Use this when starting a new
|
|
228
|
+
* request or operation that should be tracked independently.
|
|
229
|
+
*
|
|
230
|
+
* @param name - Name of the trace/span (e.g., "http-request")
|
|
231
|
+
* @param attributes - Optional attributes to attach to the trace
|
|
232
|
+
* @returns Trace instance
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```typescript
|
|
236
|
+
* const trace = backend.createTrace("process-batch", {
|
|
237
|
+
* "batch.size": 100
|
|
238
|
+
* });
|
|
239
|
+
* // ... do work ...
|
|
240
|
+
* trace.end({ "batch.processed": 100 });
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
createTrace(name: string, attributes?: Record<string, string | number | boolean>): Trace;
|
|
244
|
+
/**
|
|
245
|
+
* Create a child span within an existing trace
|
|
246
|
+
*
|
|
247
|
+
* Creates a child span that inherits the trace ID from the parent.
|
|
248
|
+
* This is used internally by Observable.startSpan().
|
|
249
|
+
*
|
|
250
|
+
* @param trace - Parent DTrace object
|
|
251
|
+
* @param name - Name of the span (e.g., "database-query")
|
|
252
|
+
* @param attributes - Optional attributes to attach to the span
|
|
253
|
+
* @returns Trace instance representing the child span
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* // Usually accessed via Observable
|
|
258
|
+
* const childSpan = backend.createSpan(trace, "database-query");
|
|
259
|
+
* // ... do work ...
|
|
260
|
+
* childSpan.end();
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
createSpan(trace: DTrace, name: string, attributes?: Record<string, string | number | boolean>): Trace;
|
|
264
|
+
/**
|
|
265
|
+
* Create a high-resolution timer
|
|
266
|
+
*
|
|
267
|
+
* Returns a timer that can measure elapsed time in milliseconds with
|
|
268
|
+
* sub-millisecond precision using Node.js hrtime.
|
|
269
|
+
*
|
|
270
|
+
* @returns Timer instance with stop method
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```typescript
|
|
274
|
+
* const timer = backend.createTimer();
|
|
275
|
+
* await performOperation();
|
|
276
|
+
* const elapsed = timer.stop();
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
createTimer(): Timer;
|
|
280
|
+
}
|
|
281
|
+
export {};
|