@oino-ts/common 0.21.0 → 0.21.2

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.
@@ -147,7 +147,7 @@ class OINOBenchmark {
147
147
  }
148
148
  }
149
149
  /**
150
- * Track an exception
150
+ * Track an exception. Does not consider enabled modules.
151
151
  *
152
152
  * @param module of the benchmark
153
153
  * @param method of the benchmark
@@ -156,9 +156,7 @@ class OINOBenchmark {
156
156
  * @param stack trace of the exception
157
157
  */
158
158
  static trackException(module, method, name, message, stack) {
159
- if (OINOBenchmark._enabled[module]) {
160
- OINOBenchmark._instance?._trackException(module, method, name, message, stack);
161
- }
159
+ OINOBenchmark._instance?._trackException(module, method, name, message, stack);
162
160
  }
163
161
  /**
164
162
  * Get all tracked exceptions.
@@ -178,7 +176,7 @@ class OINOMemoryBenchmark extends OINOBenchmark {
178
176
  _benchmarkCount = {};
179
177
  _benchmarkData = {};
180
178
  _benchmarkStart = {};
181
- _healthBenchmarks = 0;
179
+ _healthRequests = 0;
182
180
  _healthFailures = 0;
183
181
  _exceptions = [];
184
182
  /**
@@ -186,9 +184,10 @@ class OINOMemoryBenchmark extends OINOBenchmark {
186
184
  *
187
185
  */
188
186
  _reset() {
187
+ this._exceptions = [];
189
188
  this._benchmarkData = {};
190
189
  this._benchmarkCount = {};
191
- this._healthBenchmarks = 0;
190
+ this._healthRequests = 0;
192
191
  this._healthFailures = 0;
193
192
  }
194
193
  /**
@@ -259,7 +258,7 @@ class OINOMemoryBenchmark extends OINOBenchmark {
259
258
  }
260
259
  if (OINOBenchmark._healthBenchmarks.includes(name)) {
261
260
  // console.log(`Health benchmark ${name}: value=${value.toFixed(2)}ms, average=${(this._benchmarkData[name] / this._benchmarkCount[name]).toFixed(2)}ms, late=${late_ratio>=OINOBenchmark._healthLateRatio}, success=${success}`)
262
- this._healthBenchmarks += 1;
261
+ this._healthRequests += 1;
263
262
  if (!success) {
264
263
  this._healthFailures += 1;
265
264
  }
@@ -279,11 +278,11 @@ class OINOMemoryBenchmark extends OINOBenchmark {
279
278
  return this._exceptions;
280
279
  }
281
280
  _getHealth() {
282
- if ((OINOBenchmark._healthBenchmarks.length == 0) || (this._healthBenchmarks == 0)) {
281
+ if ((OINOBenchmark._healthBenchmarks.length == 0) || (this._healthRequests == 0)) {
283
282
  return 1.0;
284
283
  }
285
284
  else {
286
- return (this._healthBenchmarks - this._healthFailures) / this._healthBenchmarks;
285
+ return (this._healthRequests - this._healthFailures) / this._healthRequests;
287
286
  }
288
287
  }
289
288
  }
@@ -144,7 +144,7 @@ export class OINOBenchmark {
144
144
  }
145
145
  }
146
146
  /**
147
- * Track an exception
147
+ * Track an exception. Does not consider enabled modules.
148
148
  *
149
149
  * @param module of the benchmark
150
150
  * @param method of the benchmark
@@ -153,9 +153,7 @@ export class OINOBenchmark {
153
153
  * @param stack trace of the exception
154
154
  */
155
155
  static trackException(module, method, name, message, stack) {
156
- if (OINOBenchmark._enabled[module]) {
157
- OINOBenchmark._instance?._trackException(module, method, name, message, stack);
158
- }
156
+ OINOBenchmark._instance?._trackException(module, method, name, message, stack);
159
157
  }
160
158
  /**
161
159
  * Get all tracked exceptions.
@@ -174,7 +172,7 @@ export class OINOMemoryBenchmark extends OINOBenchmark {
174
172
  _benchmarkCount = {};
175
173
  _benchmarkData = {};
176
174
  _benchmarkStart = {};
177
- _healthBenchmarks = 0;
175
+ _healthRequests = 0;
178
176
  _healthFailures = 0;
179
177
  _exceptions = [];
180
178
  /**
@@ -182,9 +180,10 @@ export class OINOMemoryBenchmark extends OINOBenchmark {
182
180
  *
183
181
  */
184
182
  _reset() {
183
+ this._exceptions = [];
185
184
  this._benchmarkData = {};
186
185
  this._benchmarkCount = {};
187
- this._healthBenchmarks = 0;
186
+ this._healthRequests = 0;
188
187
  this._healthFailures = 0;
189
188
  }
190
189
  /**
@@ -255,7 +254,7 @@ export class OINOMemoryBenchmark extends OINOBenchmark {
255
254
  }
256
255
  if (OINOBenchmark._healthBenchmarks.includes(name)) {
257
256
  // console.log(`Health benchmark ${name}: value=${value.toFixed(2)}ms, average=${(this._benchmarkData[name] / this._benchmarkCount[name]).toFixed(2)}ms, late=${late_ratio>=OINOBenchmark._healthLateRatio}, success=${success}`)
258
- this._healthBenchmarks += 1;
257
+ this._healthRequests += 1;
259
258
  if (!success) {
260
259
  this._healthFailures += 1;
261
260
  }
@@ -275,11 +274,11 @@ export class OINOMemoryBenchmark extends OINOBenchmark {
275
274
  return this._exceptions;
276
275
  }
277
276
  _getHealth() {
278
- if ((OINOBenchmark._healthBenchmarks.length == 0) || (this._healthBenchmarks == 0)) {
277
+ if ((OINOBenchmark._healthBenchmarks.length == 0) || (this._healthRequests == 0)) {
279
278
  return 1.0;
280
279
  }
281
280
  else {
282
- return (this._healthBenchmarks - this._healthFailures) / this._healthBenchmarks;
281
+ return (this._healthRequests - this._healthFailures) / this._healthRequests;
283
282
  }
284
283
  }
285
284
  }
@@ -105,7 +105,7 @@ export declare abstract class OINOBenchmark {
105
105
  static trackMetric(module: string, method: string, value: number, success?: boolean): void;
106
106
  protected abstract _trackException(module: string, method: string, name: string, message: string, stack: string): void;
107
107
  /**
108
- * Track an exception
108
+ * Track an exception. Does not consider enabled modules.
109
109
  *
110
110
  * @param module of the benchmark
111
111
  * @param method of the benchmark
@@ -130,7 +130,7 @@ export declare class OINOMemoryBenchmark extends OINOBenchmark {
130
130
  protected _benchmarkCount: Record<string, number>;
131
131
  protected _benchmarkData: Record<string, number>;
132
132
  protected _benchmarkStart: Record<string, number>;
133
- protected _healthBenchmarks: number;
133
+ protected _healthRequests: number;
134
134
  protected _healthFailures: number;
135
135
  protected _exceptions: any[];
136
136
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oino-ts/common",
3
- "version": "0.21.0",
3
+ "version": "0.21.2",
4
4
  "description": "OINO TS package for common classes.",
5
5
  "author": "Matias Kiviniemi (pragmatta)",
6
6
  "license": "MPL-2.0",
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  },
21
21
  "devDependencies": {
22
- "@oino-ts/types": "0.21.0",
22
+ "@oino-ts/types": "0.21.2",
23
23
  "@types/node": "^22.0.0",
24
24
  "typescript": "~5.9.0"
25
25
  },
@@ -170,7 +170,7 @@ export abstract class OINOBenchmark {
170
170
 
171
171
  protected abstract _trackException(module:string, method:string, name:string, message:string, stack: string):void
172
172
  /**
173
- * Track an exception
173
+ * Track an exception. Does not consider enabled modules.
174
174
  *
175
175
  * @param module of the benchmark
176
176
  * @param method of the benchmark
@@ -179,9 +179,7 @@ export abstract class OINOBenchmark {
179
179
  * @param stack trace of the exception
180
180
  */
181
181
  static trackException(module:string, method:string, name:string, message:string, stack:string):void {
182
- if (OINOBenchmark._enabled[module]) {
183
- OINOBenchmark._instance?._trackException(module, method, name, message, stack)
184
- }
182
+ OINOBenchmark._instance?._trackException(module, method, name, message, stack)
185
183
  }
186
184
 
187
185
  protected abstract _getExceptions():any[]
@@ -204,7 +202,7 @@ export class OINOMemoryBenchmark extends OINOBenchmark {
204
202
  protected _benchmarkCount:Record<string, number> = {}
205
203
  protected _benchmarkData:Record<string, number> = {}
206
204
  protected _benchmarkStart:Record<string, number> = {}
207
- protected _healthBenchmarks: number = 0
205
+ protected _healthRequests: number = 0
208
206
  protected _healthFailures: number = 0
209
207
 
210
208
  protected _exceptions:any[] = []
@@ -214,9 +212,10 @@ export class OINOMemoryBenchmark extends OINOBenchmark {
214
212
  *
215
213
  */
216
214
  protected _reset():void {
215
+ this._exceptions = []
217
216
  this._benchmarkData = {}
218
217
  this._benchmarkCount = {}
219
- this._healthBenchmarks = 0
218
+ this._healthRequests = 0
220
219
  this._healthFailures = 0
221
220
  }
222
221
 
@@ -291,7 +290,7 @@ export class OINOMemoryBenchmark extends OINOBenchmark {
291
290
  }
292
291
  if (OINOBenchmark._healthBenchmarks.includes(name)) {
293
292
  // console.log(`Health benchmark ${name}: value=${value.toFixed(2)}ms, average=${(this._benchmarkData[name] / this._benchmarkCount[name]).toFixed(2)}ms, late=${late_ratio>=OINOBenchmark._healthLateRatio}, success=${success}`)
294
- this._healthBenchmarks += 1
293
+ this._healthRequests += 1
295
294
  if (!success) {
296
295
  this._healthFailures += 1
297
296
 
@@ -314,11 +313,11 @@ export class OINOMemoryBenchmark extends OINOBenchmark {
314
313
  }
315
314
 
316
315
  protected _getHealth(): number {
317
- if ((OINOBenchmark._healthBenchmarks.length == 0) || (this._healthBenchmarks == 0)) {
316
+ if ((OINOBenchmark._healthBenchmarks.length == 0) || (this._healthRequests == 0)) {
318
317
  return 1.0
319
318
 
320
319
  } else {
321
- return (this._healthBenchmarks - this._healthFailures) / this._healthBenchmarks
320
+ return (this._healthRequests - this._healthFailures) / this._healthRequests
322
321
  }
323
322
  }
324
323
  }