@twin.org/telemetry-service 0.0.3-next.6 → 0.0.3-next.8
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/dist/es/index.js +5 -2
- package/dist/es/index.js.map +1 -1
- package/dist/es/metricsCollectorService.js +114 -0
- package/dist/es/metricsCollectorService.js.map +1 -0
- package/dist/es/models/IMetricsCollectorServiceConfig.js +4 -0
- package/dist/es/models/IMetricsCollectorServiceConfig.js.map +1 -0
- package/dist/es/models/IMetricsCollectorServiceConstructorOptions.js +2 -0
- package/dist/es/models/IMetricsCollectorServiceConstructorOptions.js.map +1 -0
- package/dist/types/index.d.ts +5 -2
- package/dist/types/metricsCollectorService.d.ts +38 -0
- package/dist/types/models/IMetricsCollectorServiceConfig.d.ts +10 -0
- package/dist/types/models/IMetricsCollectorServiceConstructorOptions.d.ts +15 -0
- package/docs/changelog.md +28 -0
- package/docs/reference/classes/MetricsCollectorService.md +98 -0
- package/docs/reference/index.md +3 -0
- package/docs/reference/interfaces/IMetricsCollectorServiceConfig.md +17 -0
- package/docs/reference/interfaces/IMetricsCollectorServiceConstructorOptions.md +25 -0
- package/locales/en.json +7 -1
- package/package.json +3 -2
package/dist/es/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
// Copyright 2024 IOTA Stiftung.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
export * from "./metricsCollectorService.js";
|
|
4
|
+
export * from "./models/IMetricsCollectorServiceConfig.js";
|
|
5
|
+
export * from "./models/IMetricsCollectorServiceConstructorOptions.js";
|
|
6
|
+
export * from "./models/ITelemetryServiceConstructorOptions.js";
|
|
7
|
+
export * from "./restEntryPoints.js";
|
|
3
8
|
export * from "./telemetryRoutes.js";
|
|
4
9
|
export * from "./telemetryService.js";
|
|
5
|
-
export * from "./restEntryPoints.js";
|
|
6
|
-
export * from "./models/ITelemetryServiceConstructorOptions.js";
|
|
7
10
|
//# sourceMappingURL=index.js.map
|
package/dist/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,wDAAwD,CAAC;AACvE,cAAc,iDAAiD,CAAC;AAChE,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./metricsCollectorService.js\";\nexport * from \"./models/IMetricsCollectorServiceConfig.js\";\nexport * from \"./models/IMetricsCollectorServiceConstructorOptions.js\";\nexport * from \"./models/ITelemetryServiceConstructorOptions.js\";\nexport * from \"./restEntryPoints.js\";\nexport * from \"./telemetryRoutes.js\";\nexport * from \"./telemetryService.js\";\n"]}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Copyright 2026 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { BaseError, ComponentFactory } from "@twin.org/core";
|
|
4
|
+
import { MetricsProducerFactory } from "@twin.org/telemetry-models";
|
|
5
|
+
/**
|
|
6
|
+
* Collects metrics from registered producers at a fixed interval.
|
|
7
|
+
*/
|
|
8
|
+
export class MetricsCollectorService {
|
|
9
|
+
/**
|
|
10
|
+
* Runtime name for the class.
|
|
11
|
+
*/
|
|
12
|
+
static CLASS_NAME = "MetricsCollectorService";
|
|
13
|
+
/**
|
|
14
|
+
* Resolved logging component for internal use.
|
|
15
|
+
*/
|
|
16
|
+
_loggingComponent;
|
|
17
|
+
/**
|
|
18
|
+
* Polling interval in milliseconds.
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
_intervalMs;
|
|
22
|
+
/**
|
|
23
|
+
* Pending scheduled tick handle.
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
_timer;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the service is currently running.
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
_running;
|
|
32
|
+
/**
|
|
33
|
+
* Create a new instance of MetricsCollectorService.
|
|
34
|
+
* @param options The options for the service.
|
|
35
|
+
*/
|
|
36
|
+
constructor(options) {
|
|
37
|
+
this._loggingComponent = ComponentFactory.getIfExists(options?.loggingComponentType ?? "logging");
|
|
38
|
+
const intervalMs = options?.config?.intervalMs ?? 60_000;
|
|
39
|
+
if (!Number.isFinite(intervalMs) || intervalMs <= 0) {
|
|
40
|
+
throw new RangeError(`intervalMs must be a finite positive number, got ${intervalMs}`);
|
|
41
|
+
}
|
|
42
|
+
this._intervalMs = intervalMs;
|
|
43
|
+
this._running = false;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns the class name of the component.
|
|
47
|
+
* @returns The class name of the component.
|
|
48
|
+
*/
|
|
49
|
+
className() {
|
|
50
|
+
return MetricsCollectorService.CLASS_NAME;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Start the service: register all producers and begin the polling cycle.
|
|
54
|
+
*/
|
|
55
|
+
async start() {
|
|
56
|
+
if (this._running) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this._running = true;
|
|
60
|
+
const names = MetricsProducerFactory.names();
|
|
61
|
+
const producers = names.map(name => MetricsProducerFactory.get(name));
|
|
62
|
+
for (const producer of producers) {
|
|
63
|
+
await producer.register();
|
|
64
|
+
}
|
|
65
|
+
await this.tick();
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Stop the service and cancel the pending timer.
|
|
69
|
+
*/
|
|
70
|
+
async stop() {
|
|
71
|
+
this._running = false;
|
|
72
|
+
if (this._timer !== undefined) {
|
|
73
|
+
globalThis.clearTimeout(this._timer);
|
|
74
|
+
this._timer = undefined;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* One collection cycle across all registered producers.
|
|
79
|
+
* Public so tests can drive it deterministically.
|
|
80
|
+
*/
|
|
81
|
+
async tick() {
|
|
82
|
+
const names = MetricsProducerFactory.names();
|
|
83
|
+
const producers = names.map(name => MetricsProducerFactory.get(name));
|
|
84
|
+
for (const producer of producers) {
|
|
85
|
+
try {
|
|
86
|
+
await producer.collect();
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
await this._loggingComponent?.log({
|
|
90
|
+
source: MetricsCollectorService.CLASS_NAME,
|
|
91
|
+
level: "error",
|
|
92
|
+
message: "producerCollectionFailed",
|
|
93
|
+
data: {
|
|
94
|
+
producer: producer.className()
|
|
95
|
+
},
|
|
96
|
+
error: BaseError.fromError(err)
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
this.scheduleNext();
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Schedule the next tick. Re-schedules itself after each tick completes.
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
106
|
+
scheduleNext() {
|
|
107
|
+
if (this._running) {
|
|
108
|
+
this._timer = globalThis.setTimeout(async () => {
|
|
109
|
+
await this.tick();
|
|
110
|
+
}, this._intervalMs);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=metricsCollectorService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metricsCollectorService.js","sourceRoot":"","sources":["../../src/metricsCollectorService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAG7D,OAAO,EAEN,sBAAsB,EACtB,M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IAAI,CAAC,WAAW,CAAC,CAAC;QACtB,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseError, ComponentFactory } from \"@twin.org/core\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\ttype IMetricsCollectorComponent,\n\tMetricsProducerFactory\n} from \"@twin.org/telemetry-models\";\nimport type { IMetricsCollectorServiceConstructorOptions } from \"./models/IMetricsCollectorServiceConstructorOptions.js\";\n\n/**\n * Collects metrics from registered producers at a fixed interval.\n */\nexport class MetricsCollectorService implements IMetricsCollectorComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<MetricsCollectorService>();\n\n\t/**\n\t * Resolved logging component for internal use.\n\t */\n\tprivate readonly _loggingComponent?: ILoggingComponent;\n\n\t/**\n\t * Polling interval in milliseconds.\n\t * @internal\n\t */\n\tprivate readonly _intervalMs: number;\n\n\t/**\n\t * Pending scheduled tick handle.\n\t * @internal\n\t */\n\tprivate _timer: ReturnType<typeof globalThis.setTimeout> | undefined;\n\n\t/**\n\t * Whether the service is currently running.\n\t * @internal\n\t */\n\tprivate _running: boolean;\n\n\t/**\n\t * Create a new instance of MetricsCollectorService.\n\t * @param options The options for the service.\n\t */\n\tconstructor(options?: IMetricsCollectorServiceConstructorOptions) {\n\t\tthis._loggingComponent = ComponentFactory.getIfExists<ILoggingComponent>(\n\t\t\toptions?.loggingComponentType ?? \"logging\"\n\t\t);\n\n\t\tconst intervalMs = options?.config?.intervalMs ?? 60_000;\n\t\tif (!Number.isFinite(intervalMs) || intervalMs <= 0) {\n\t\t\tthrow new RangeError(`intervalMs must be a finite positive number, got ${intervalMs}`);\n\t\t}\n\t\tthis._intervalMs = intervalMs;\n\t\tthis._running = false;\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn MetricsCollectorService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Start the service: register all producers and begin the polling cycle.\n\t */\n\tpublic async start(): Promise<void> {\n\t\tif (this._running) {\n\t\t\treturn;\n\t\t}\n\t\tthis._running = true;\n\n\t\tconst names = MetricsProducerFactory.names();\n\t\tconst producers = names.map(name => MetricsProducerFactory.get(name));\n\n\t\tfor (const producer of producers) {\n\t\t\tawait producer.register();\n\t\t}\n\n\t\tawait this.tick();\n\t}\n\n\t/**\n\t * Stop the service and cancel the pending timer.\n\t */\n\tpublic async stop(): Promise<void> {\n\t\tthis._running = false;\n\t\tif (this._timer !== undefined) {\n\t\t\tglobalThis.clearTimeout(this._timer);\n\t\t\tthis._timer = undefined;\n\t\t}\n\t}\n\n\t/**\n\t * One collection cycle across all registered producers.\n\t * Public so tests can drive it deterministically.\n\t */\n\tpublic async tick(): Promise<void> {\n\t\tconst names = MetricsProducerFactory.names();\n\t\tconst producers = names.map(name => MetricsProducerFactory.get(name));\n\n\t\tfor (const producer of producers) {\n\t\t\ttry {\n\t\t\t\tawait producer.collect();\n\t\t\t} catch (err) {\n\t\t\t\tawait this._loggingComponent?.log({\n\t\t\t\t\tsource: MetricsCollectorService.CLASS_NAME,\n\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\tmessage: \"producerCollectionFailed\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tproducer: producer.className()\n\t\t\t\t\t},\n\t\t\t\t\terror: BaseError.fromError(err)\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tthis.scheduleNext();\n\t}\n\n\t/**\n\t * Schedule the next tick. Re-schedules itself after each tick completes.\n\t * @internal\n\t */\n\tprivate scheduleNext(): void {\n\t\tif (this._running) {\n\t\t\tthis._timer = globalThis.setTimeout(async () => {\n\t\t\t\tawait this.tick();\n\t\t\t}, this._intervalMs);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IMetricsCollectorServiceConfig.js","sourceRoot":"","sources":["../../../src/models/IMetricsCollectorServiceConfig.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The options for the metrics collector service config.\n */\nexport interface IMetricsCollectorServiceConfig {\n\t/**\n\t * Polling interval in milliseconds.\n\t * @default 60000\n\t */\n\tintervalMs?: number;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IMetricsCollectorServiceConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IMetricsCollectorServiceConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IMetricsCollectorServiceConfig } from \"./IMetricsCollectorServiceConfig.js\";\n\n/**\n * The options for the metrics collector service constructor.\n */\nexport interface IMetricsCollectorServiceConstructorOptions {\n\t/**\n\t * The type of the logging component to use.\n\t * @default logging\n\t */\n\tloggingComponentType?: string;\n\n\t/**\n\t * The configuration options for the metrics collector service.\n\t */\n\tconfig?: IMetricsCollectorServiceConfig;\n}\n"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
export * from "./metricsCollectorService.js";
|
|
2
|
+
export * from "./models/IMetricsCollectorServiceConfig.js";
|
|
3
|
+
export * from "./models/IMetricsCollectorServiceConstructorOptions.js";
|
|
4
|
+
export * from "./models/ITelemetryServiceConstructorOptions.js";
|
|
5
|
+
export * from "./restEntryPoints.js";
|
|
1
6
|
export * from "./telemetryRoutes.js";
|
|
2
7
|
export * from "./telemetryService.js";
|
|
3
|
-
export * from "./restEntryPoints.js";
|
|
4
|
-
export * from "./models/ITelemetryServiceConstructorOptions.js";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type IMetricsCollectorComponent } from "@twin.org/telemetry-models";
|
|
2
|
+
import type { IMetricsCollectorServiceConstructorOptions } from "./models/IMetricsCollectorServiceConstructorOptions.js";
|
|
3
|
+
/**
|
|
4
|
+
* Collects metrics from registered producers at a fixed interval.
|
|
5
|
+
*/
|
|
6
|
+
export declare class MetricsCollectorService implements IMetricsCollectorComponent {
|
|
7
|
+
/**
|
|
8
|
+
* Runtime name for the class.
|
|
9
|
+
*/
|
|
10
|
+
static readonly CLASS_NAME: string;
|
|
11
|
+
/**
|
|
12
|
+
* Resolved logging component for internal use.
|
|
13
|
+
*/
|
|
14
|
+
private readonly _loggingComponent?;
|
|
15
|
+
/**
|
|
16
|
+
* Create a new instance of MetricsCollectorService.
|
|
17
|
+
* @param options The options for the service.
|
|
18
|
+
*/
|
|
19
|
+
constructor(options?: IMetricsCollectorServiceConstructorOptions);
|
|
20
|
+
/**
|
|
21
|
+
* Returns the class name of the component.
|
|
22
|
+
* @returns The class name of the component.
|
|
23
|
+
*/
|
|
24
|
+
className(): string;
|
|
25
|
+
/**
|
|
26
|
+
* Start the service: register all producers and begin the polling cycle.
|
|
27
|
+
*/
|
|
28
|
+
start(): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Stop the service and cancel the pending timer.
|
|
31
|
+
*/
|
|
32
|
+
stop(): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* One collection cycle across all registered producers.
|
|
35
|
+
* Public so tests can drive it deterministically.
|
|
36
|
+
*/
|
|
37
|
+
tick(): Promise<void>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IMetricsCollectorServiceConfig } from "./IMetricsCollectorServiceConfig.js";
|
|
2
|
+
/**
|
|
3
|
+
* The options for the metrics collector service constructor.
|
|
4
|
+
*/
|
|
5
|
+
export interface IMetricsCollectorServiceConstructorOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The type of the logging component to use.
|
|
8
|
+
* @default logging
|
|
9
|
+
*/
|
|
10
|
+
loggingComponentType?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The configuration options for the metrics collector service.
|
|
13
|
+
*/
|
|
14
|
+
config?: IMetricsCollectorServiceConfig;
|
|
15
|
+
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.8](https://github.com/iotaledger/twin-telemetry/compare/telemetry-service-v0.0.3-next.7...telemetry-service-v0.0.3-next.8) (2026-05-19)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Miscellaneous Chores
|
|
7
|
+
|
|
8
|
+
* **telemetry-service:** Synchronize repo versions
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/telemetry-models bumped from 0.0.3-next.7 to 0.0.3-next.8
|
|
16
|
+
|
|
17
|
+
## [0.0.3-next.7](https://github.com/iotaledger/twin-telemetry/compare/telemetry-service-v0.0.3-next.6...telemetry-service-v0.0.3-next.7) (2026-05-19)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* add metrics producer infrastructure ([#30](https://github.com/iotaledger/twin-telemetry/issues/30)) ([8990b99](https://github.com/iotaledger/twin-telemetry/commit/8990b990d22f331d44562c2781c9b6ddf846db88))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
* The following workspace dependencies were updated
|
|
28
|
+
* dependencies
|
|
29
|
+
* @twin.org/telemetry-models bumped from 0.0.3-next.6 to 0.0.3-next.7
|
|
30
|
+
|
|
3
31
|
## [0.0.3-next.6](https://github.com/iotaledger/twin-telemetry/compare/telemetry-service-v0.0.3-next.5...telemetry-service-v0.0.3-next.6) (2026-05-11)
|
|
4
32
|
|
|
5
33
|
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Class: MetricsCollectorService
|
|
2
|
+
|
|
3
|
+
Collects metrics from registered producers at a fixed interval.
|
|
4
|
+
|
|
5
|
+
## Implements
|
|
6
|
+
|
|
7
|
+
- `IMetricsCollectorComponent`
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### Constructor
|
|
12
|
+
|
|
13
|
+
> **new MetricsCollectorService**(`options?`): `MetricsCollectorService`
|
|
14
|
+
|
|
15
|
+
Create a new instance of MetricsCollectorService.
|
|
16
|
+
|
|
17
|
+
#### Parameters
|
|
18
|
+
|
|
19
|
+
##### options?
|
|
20
|
+
|
|
21
|
+
[`IMetricsCollectorServiceConstructorOptions`](../interfaces/IMetricsCollectorServiceConstructorOptions.md)
|
|
22
|
+
|
|
23
|
+
The options for the service.
|
|
24
|
+
|
|
25
|
+
#### Returns
|
|
26
|
+
|
|
27
|
+
`MetricsCollectorService`
|
|
28
|
+
|
|
29
|
+
## Properties
|
|
30
|
+
|
|
31
|
+
### CLASS\_NAME {#class_name}
|
|
32
|
+
|
|
33
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
34
|
+
|
|
35
|
+
Runtime name for the class.
|
|
36
|
+
|
|
37
|
+
## Methods
|
|
38
|
+
|
|
39
|
+
### className() {#classname}
|
|
40
|
+
|
|
41
|
+
> **className**(): `string`
|
|
42
|
+
|
|
43
|
+
Returns the class name of the component.
|
|
44
|
+
|
|
45
|
+
#### Returns
|
|
46
|
+
|
|
47
|
+
`string`
|
|
48
|
+
|
|
49
|
+
The class name of the component.
|
|
50
|
+
|
|
51
|
+
#### Implementation of
|
|
52
|
+
|
|
53
|
+
`IMetricsCollectorComponent.className`
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
### start() {#start}
|
|
58
|
+
|
|
59
|
+
> **start**(): `Promise`\<`void`\>
|
|
60
|
+
|
|
61
|
+
Start the service: register all producers and begin the polling cycle.
|
|
62
|
+
|
|
63
|
+
#### Returns
|
|
64
|
+
|
|
65
|
+
`Promise`\<`void`\>
|
|
66
|
+
|
|
67
|
+
#### Implementation of
|
|
68
|
+
|
|
69
|
+
`IMetricsCollectorComponent.start`
|
|
70
|
+
|
|
71
|
+
***
|
|
72
|
+
|
|
73
|
+
### stop() {#stop}
|
|
74
|
+
|
|
75
|
+
> **stop**(): `Promise`\<`void`\>
|
|
76
|
+
|
|
77
|
+
Stop the service and cancel the pending timer.
|
|
78
|
+
|
|
79
|
+
#### Returns
|
|
80
|
+
|
|
81
|
+
`Promise`\<`void`\>
|
|
82
|
+
|
|
83
|
+
#### Implementation of
|
|
84
|
+
|
|
85
|
+
`IMetricsCollectorComponent.stop`
|
|
86
|
+
|
|
87
|
+
***
|
|
88
|
+
|
|
89
|
+
### tick() {#tick}
|
|
90
|
+
|
|
91
|
+
> **tick**(): `Promise`\<`void`\>
|
|
92
|
+
|
|
93
|
+
One collection cycle across all registered producers.
|
|
94
|
+
Public so tests can drive it deterministically.
|
|
95
|
+
|
|
96
|
+
#### Returns
|
|
97
|
+
|
|
98
|
+
`Promise`\<`void`\>
|
package/docs/reference/index.md
CHANGED
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
## Classes
|
|
4
4
|
|
|
5
|
+
- [MetricsCollectorService](classes/MetricsCollectorService.md)
|
|
5
6
|
- [TelemetryService](classes/TelemetryService.md)
|
|
6
7
|
|
|
7
8
|
## Interfaces
|
|
8
9
|
|
|
10
|
+
- [IMetricsCollectorServiceConfig](interfaces/IMetricsCollectorServiceConfig.md)
|
|
11
|
+
- [IMetricsCollectorServiceConstructorOptions](interfaces/IMetricsCollectorServiceConstructorOptions.md)
|
|
9
12
|
- [ITelemetryServiceConstructorOptions](interfaces/ITelemetryServiceConstructorOptions.md)
|
|
10
13
|
|
|
11
14
|
## Variables
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Interface: IMetricsCollectorServiceConfig
|
|
2
|
+
|
|
3
|
+
The options for the metrics collector service config.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### intervalMs? {#intervalms}
|
|
8
|
+
|
|
9
|
+
> `optional` **intervalMs?**: `number`
|
|
10
|
+
|
|
11
|
+
Polling interval in milliseconds.
|
|
12
|
+
|
|
13
|
+
#### Default
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
60000
|
|
17
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Interface: IMetricsCollectorServiceConstructorOptions
|
|
2
|
+
|
|
3
|
+
The options for the metrics collector service constructor.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### loggingComponentType? {#loggingcomponenttype}
|
|
8
|
+
|
|
9
|
+
> `optional` **loggingComponentType?**: `string`
|
|
10
|
+
|
|
11
|
+
The type of the logging component to use.
|
|
12
|
+
|
|
13
|
+
#### Default
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
logging
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
***
|
|
20
|
+
|
|
21
|
+
### config? {#config}
|
|
22
|
+
|
|
23
|
+
> `optional` **config?**: [`IMetricsCollectorServiceConfig`](IMetricsCollectorServiceConfig.md)
|
|
24
|
+
|
|
25
|
+
The configuration options for the metrics collector service.
|
package/locales/en.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/telemetry-service",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.8",
|
|
4
4
|
"description": "Telemetry service implementation with REST entry points.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
"@twin.org/api-models": "next",
|
|
18
18
|
"@twin.org/core": "next",
|
|
19
19
|
"@twin.org/entity": "next",
|
|
20
|
+
"@twin.org/logging-models": "next",
|
|
20
21
|
"@twin.org/nameof": "next",
|
|
21
|
-
"@twin.org/telemetry-models": "0.0.3-next.
|
|
22
|
+
"@twin.org/telemetry-models": "0.0.3-next.8",
|
|
22
23
|
"@twin.org/web": "next"
|
|
23
24
|
},
|
|
24
25
|
"main": "./dist/es/index.js",
|