@3sixty/telemetry-models 0.0.0-stage → 0.20.0-next.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 +201 -0
- package/README.md +24 -2
- package/dist/es/connectors/multiTelemetryConnector.js +184 -0
- package/dist/es/connectors/multiTelemetryConnector.js.map +1 -0
- package/dist/es/connectors/silentTelemetryConnector.js +57 -0
- package/dist/es/connectors/silentTelemetryConnector.js.map +1 -0
- package/dist/es/factories/metricsProducerFactory.js +13 -0
- package/dist/es/factories/metricsProducerFactory.js.map +1 -0
- package/dist/es/factories/telemetryConnectorFactory.js +9 -0
- package/dist/es/factories/telemetryConnectorFactory.js.map +1 -0
- package/dist/es/helpers/metricHelper.js +139 -0
- package/dist/es/helpers/metricHelper.js.map +1 -0
- package/dist/es/index.js +30 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/IMetricsCollectorComponent.js +2 -0
- package/dist/es/models/IMetricsCollectorComponent.js.map +1 -0
- package/dist/es/models/IMetricsProducer.js +2 -0
- package/dist/es/models/IMetricsProducer.js.map +1 -0
- package/dist/es/models/IMultiTelemetryConnectorConstructorOptions.js +4 -0
- package/dist/es/models/IMultiTelemetryConnectorConstructorOptions.js.map +1 -0
- package/dist/es/models/ITelemetryComponent.js +2 -0
- package/dist/es/models/ITelemetryComponent.js.map +1 -0
- package/dist/es/models/ITelemetryConnector.js +2 -0
- package/dist/es/models/ITelemetryConnector.js.map +1 -0
- package/dist/es/models/ITelemetryMetric.js +2 -0
- package/dist/es/models/ITelemetryMetric.js.map +1 -0
- package/dist/es/models/ITelemetryMetricValue.js +4 -0
- package/dist/es/models/ITelemetryMetricValue.js.map +1 -0
- package/dist/es/models/ITelemetryMetricValueEntry.js +2 -0
- package/dist/es/models/ITelemetryMetricValueEntry.js.map +1 -0
- package/dist/es/models/api/ITelemetryAddMetricValueRequest.js +2 -0
- package/dist/es/models/api/ITelemetryAddMetricValueRequest.js.map +1 -0
- package/dist/es/models/api/ITelemetryCreateMetricRequest.js +2 -0
- package/dist/es/models/api/ITelemetryCreateMetricRequest.js.map +1 -0
- package/dist/es/models/api/ITelemetryGetMetricRequest.js +4 -0
- package/dist/es/models/api/ITelemetryGetMetricRequest.js.map +1 -0
- package/dist/es/models/api/ITelemetryGetMetricResponse.js +2 -0
- package/dist/es/models/api/ITelemetryGetMetricResponse.js.map +1 -0
- package/dist/es/models/api/ITelemetryGetMetricValueRequest.js +4 -0
- package/dist/es/models/api/ITelemetryGetMetricValueRequest.js.map +1 -0
- package/dist/es/models/api/ITelemetryGetMetricValueResponse.js +2 -0
- package/dist/es/models/api/ITelemetryGetMetricValueResponse.js.map +1 -0
- package/dist/es/models/api/ITelemetryListRequest.js +4 -0
- package/dist/es/models/api/ITelemetryListRequest.js.map +1 -0
- package/dist/es/models/api/ITelemetryListResponse.js +2 -0
- package/dist/es/models/api/ITelemetryListResponse.js.map +1 -0
- package/dist/es/models/api/ITelemetryRemoveMetricRequest.js +4 -0
- package/dist/es/models/api/ITelemetryRemoveMetricRequest.js.map +1 -0
- package/dist/es/models/api/ITelemetryUpdateMetricRequest.js +4 -0
- package/dist/es/models/api/ITelemetryUpdateMetricRequest.js.map +1 -0
- package/dist/es/models/api/ITelemetryValuesListRequest.js +4 -0
- package/dist/es/models/api/ITelemetryValuesListRequest.js.map +1 -0
- package/dist/es/models/api/ITelemetryValuesListResponse.js +2 -0
- package/dist/es/models/api/ITelemetryValuesListResponse.js.map +1 -0
- package/dist/es/models/metricCounterOperation.js +17 -0
- package/dist/es/models/metricCounterOperation.js.map +1 -0
- package/dist/es/models/metricType.js +21 -0
- package/dist/es/models/metricType.js.map +1 -0
- package/dist/types/connectors/multiTelemetryConnector.d.ts +124 -0
- package/dist/types/connectors/silentTelemetryConnector.d.ts +56 -0
- package/dist/types/factories/metricsProducerFactory.d.ts +10 -0
- package/dist/types/factories/telemetryConnectorFactory.d.ts +6 -0
- package/dist/types/helpers/metricHelper.d.ts +67 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/types/models/IMetricsCollectorComponent.d.ts +6 -0
- package/dist/types/models/IMetricsProducer.d.ts +27 -0
- package/dist/types/models/IMultiTelemetryConnectorConstructorOptions.d.ts +9 -0
- package/dist/types/models/ITelemetryComponent.d.ts +109 -0
- package/dist/types/models/ITelemetryConnector.d.ts +109 -0
- package/dist/types/models/ITelemetryMetric.d.ts +31 -0
- package/dist/types/models/ITelemetryMetricValue.d.ts +23 -0
- package/dist/types/models/ITelemetryMetricValueEntry.d.ts +20 -0
- package/dist/types/models/api/ITelemetryAddMetricValueRequest.d.ts +30 -0
- package/dist/types/models/api/ITelemetryCreateMetricRequest.d.ts +11 -0
- package/dist/types/models/api/ITelemetryGetMetricRequest.d.ts +14 -0
- package/dist/types/models/api/ITelemetryGetMetricResponse.d.ts +20 -0
- package/dist/types/models/api/ITelemetryGetMetricValueRequest.d.ts +18 -0
- package/dist/types/models/api/ITelemetryGetMetricValueResponse.d.ts +10 -0
- package/dist/types/models/api/ITelemetryListRequest.d.ts +22 -0
- package/dist/types/models/api/ITelemetryListResponse.d.ts +19 -0
- package/dist/types/models/api/ITelemetryRemoveMetricRequest.d.ts +14 -0
- package/dist/types/models/api/ITelemetryUpdateMetricRequest.d.ts +31 -0
- package/dist/types/models/api/ITelemetryValuesListRequest.d.ts +35 -0
- package/dist/types/models/api/ITelemetryValuesListResponse.d.ts +24 -0
- package/dist/types/models/metricCounterOperation.d.ts +17 -0
- package/dist/types/models/metricType.d.ts +21 -0
- package/docs/changelog.md +0 -0
- package/docs/examples.md +142 -0
- package/docs/reference/classes/MetricHelper.md +226 -0
- package/docs/reference/classes/MultiTelemetryConnector.md +357 -0
- package/docs/reference/classes/SilentTelemetryConnector.md +191 -0
- package/docs/reference/index.md +42 -0
- package/docs/reference/interfaces/IMetricsCollectorComponent.md +7 -0
- package/docs/reference/interfaces/IMetricsProducer.md +45 -0
- package/docs/reference/interfaces/IMultiTelemetryConnectorConstructorOptions.md +11 -0
- package/docs/reference/interfaces/ITelemetryAddMetricValueRequest.md +41 -0
- package/docs/reference/interfaces/ITelemetryComponent.md +271 -0
- package/docs/reference/interfaces/ITelemetryConnector.md +271 -0
- package/docs/reference/interfaces/ITelemetryCreateMetricRequest.md +12 -0
- package/docs/reference/interfaces/ITelemetryGetMetricRequest.md +17 -0
- package/docs/reference/interfaces/ITelemetryGetMetricResponse.md +23 -0
- package/docs/reference/interfaces/ITelemetryGetMetricValueRequest.md +23 -0
- package/docs/reference/interfaces/ITelemetryGetMetricValueResponse.md +11 -0
- package/docs/reference/interfaces/ITelemetryListRequest.md +29 -0
- package/docs/reference/interfaces/ITelemetryListResponse.md +23 -0
- package/docs/reference/interfaces/ITelemetryMetric.md +52 -0
- package/docs/reference/interfaces/ITelemetryMetricValue.md +39 -0
- package/docs/reference/interfaces/ITelemetryMetricValueEntry.md +31 -0
- package/docs/reference/interfaces/ITelemetryRemoveMetricRequest.md +17 -0
- package/docs/reference/interfaces/ITelemetryUpdateMetricRequest.md +43 -0
- package/docs/reference/interfaces/ITelemetryValuesListRequest.md +49 -0
- package/docs/reference/interfaces/ITelemetryValuesListResponse.md +29 -0
- package/docs/reference/type-aliases/MetricCounterOperation.md +5 -0
- package/docs/reference/type-aliases/MetricType.md +5 -0
- package/docs/reference/variables/MetricCounterOperation.md +19 -0
- package/docs/reference/variables/MetricType.md +25 -0
- package/docs/reference/variables/MetricsProducerFactory.md +9 -0
- package/docs/reference/variables/TelemetryConnectorFactory.md +5 -0
- package/locales/en.json +7 -0
- package/package.json +51 -5
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ITelemetryConnector } from "../models/ITelemetryConnector.js";
|
|
2
|
+
import type { ITelemetryMetric } from "../models/ITelemetryMetric.js";
|
|
3
|
+
import type { ITelemetryMetricValueEntry } from "../models/ITelemetryMetricValueEntry.js";
|
|
4
|
+
import type { MetricCounterOperation } from "../models/metricCounterOperation.js";
|
|
5
|
+
/**
|
|
6
|
+
* Class for performing telemetry operations to nowhere.
|
|
7
|
+
*/
|
|
8
|
+
export declare class SilentTelemetryConnector implements ITelemetryConnector {
|
|
9
|
+
/**
|
|
10
|
+
* The namespace for the class.
|
|
11
|
+
*/
|
|
12
|
+
static readonly NAMESPACE: string;
|
|
13
|
+
/**
|
|
14
|
+
* Runtime name for the class.
|
|
15
|
+
*/
|
|
16
|
+
static readonly CLASS_NAME: string;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the class name of the component.
|
|
19
|
+
* @returns The class name of the component.
|
|
20
|
+
*/
|
|
21
|
+
className(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Create one or more metrics.
|
|
24
|
+
* @param metric The metric details, or the details of several metrics.
|
|
25
|
+
* @returns A promise that resolves when the metric has been created.
|
|
26
|
+
*/
|
|
27
|
+
createMetric(metric: ITelemetryMetric | ITelemetryMetric[]): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Update metric.
|
|
30
|
+
* @param metric The metric details.
|
|
31
|
+
* @returns A promise that resolves when the metric has been updated.
|
|
32
|
+
*/
|
|
33
|
+
updateMetric(metric: Omit<ITelemetryMetric, "type">): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Update metric value.
|
|
36
|
+
* @param id The id of the metric.
|
|
37
|
+
* @param value The value for the update operation.
|
|
38
|
+
* @param customData The custom data for the update operation.
|
|
39
|
+
* @returns The created metric value id.
|
|
40
|
+
*/
|
|
41
|
+
addMetricValue(id: string, value: MetricCounterOperation | number, customData?: {
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
}): Promise<string>;
|
|
44
|
+
/**
|
|
45
|
+
* Add multiple metric values.
|
|
46
|
+
* @param values The metric values to add.
|
|
47
|
+
* @returns The created metric value ids.
|
|
48
|
+
*/
|
|
49
|
+
addMetricValues(values: ITelemetryMetricValueEntry[]): Promise<string[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Remove metric.
|
|
52
|
+
* @param id The id of the metric.
|
|
53
|
+
* @returns A promise that resolves when the metric and all its values have been removed.
|
|
54
|
+
*/
|
|
55
|
+
removeMetric(id: string): Promise<void>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Factory } from "@3sixty/core";
|
|
2
|
+
import type { IMetricsProducer } from "../models/IMetricsProducer.js";
|
|
3
|
+
/**
|
|
4
|
+
* Factory for `IMetricsProducer` implementations.
|
|
5
|
+
*
|
|
6
|
+
* The engine registers producers with `MetricsProducerFactory` during
|
|
7
|
+
* initialisation. Third-party apps can also register their own producers
|
|
8
|
+
* before `engine.start()` is called.
|
|
9
|
+
*/
|
|
10
|
+
export declare const MetricsProducerFactory: Factory<IMetricsProducer>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ITelemetryComponent } from "../models/ITelemetryComponent.js";
|
|
2
|
+
import type { ITelemetryMetric } from "../models/ITelemetryMetric.js";
|
|
3
|
+
import type { ITelemetryMetricValueEntry } from "../models/ITelemetryMetricValueEntry.js";
|
|
4
|
+
/**
|
|
5
|
+
* Helper class for performing common metric operations, swallowing any errors from the telemetry component.
|
|
6
|
+
*/
|
|
7
|
+
export declare class MetricHelper {
|
|
8
|
+
/**
|
|
9
|
+
* Create multiple metrics if they don't already exist, swallowing any already exists errors.
|
|
10
|
+
* A convenience wrapper over createMetric for callers that always have a list.
|
|
11
|
+
* @param telemetryComponent The telemetry component to use for creating the metrics.
|
|
12
|
+
* @param metrics The telemetry metrics to create.
|
|
13
|
+
* @returns A promise that resolves when all metrics have been created or confirmed to exist.
|
|
14
|
+
*/
|
|
15
|
+
static createMetrics(telemetryComponent: ITelemetryComponent | undefined, metrics: ITelemetryMetric[]): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Create one or more metrics if they don't already exist, swallowing any already exists errors.
|
|
18
|
+
* @param telemetryComponent The telemetry component to use for creating the metrics.
|
|
19
|
+
* @param metric The telemetry metric to create, or the metrics to create.
|
|
20
|
+
* @returns A promise that resolves when the metrics have been created or confirmed to exist.
|
|
21
|
+
*/
|
|
22
|
+
static createMetric(telemetryComponent: ITelemetryComponent | undefined, metric: ITelemetryMetric | ITelemetryMetric[]): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Increment a metric counter, swallowing any telemetry errors.
|
|
25
|
+
* @param telemetryComponent The telemetry component to use for incrementing the metric.
|
|
26
|
+
* @param id The metric ID.
|
|
27
|
+
* @param customData Optional custom data for the increment.
|
|
28
|
+
* @param onError Optional callback invoked with the swallowed error, for callers that want visibility.
|
|
29
|
+
* @returns A promise that resolves when the increment has been recorded or the error swallowed.
|
|
30
|
+
*/
|
|
31
|
+
static metricIncrement(telemetryComponent: ITelemetryComponent | undefined, id: string, customData?: {
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}, onError?: (err: unknown) => Promise<void> | void): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Decrement a metric counter, swallowing any telemetry errors.
|
|
36
|
+
* @param telemetryComponent The telemetry component to use for decrementing the metric.
|
|
37
|
+
* @param id The metric ID.
|
|
38
|
+
* @param customData Optional custom data for the decrement.
|
|
39
|
+
* @param onError Optional callback invoked with the swallowed error, for callers that want visibility.
|
|
40
|
+
* @returns A promise that resolves when the decrement has been recorded or the error swallowed.
|
|
41
|
+
*/
|
|
42
|
+
static metricDecrement(telemetryComponent: ITelemetryComponent | undefined, id: string, customData?: {
|
|
43
|
+
[key: string]: unknown;
|
|
44
|
+
}, onError?: (err: unknown) => Promise<void> | void): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Set a metric value, swallowing any telemetry errors.
|
|
47
|
+
* @param telemetryComponent The telemetry component to use for setting the metric value.
|
|
48
|
+
* @param id The metric ID.
|
|
49
|
+
* @param value The metric value to set.
|
|
50
|
+
* @param customData Optional custom data for setting the value.
|
|
51
|
+
* @param onError Optional callback invoked with the swallowed error, for callers that want visibility.
|
|
52
|
+
* @returns A promise that resolves when the value has been recorded or the error swallowed.
|
|
53
|
+
*/
|
|
54
|
+
static metricValue(telemetryComponent: ITelemetryComponent | undefined, id: string, value: number, customData?: {
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
}, onError?: (err: unknown) => Promise<void> | void): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Set several metric values at once, swallowing any telemetry errors.
|
|
59
|
+
* Components which support it record the whole set in one operation, which for a persisted
|
|
60
|
+
* connector is a single write rather than one per value.
|
|
61
|
+
* @param telemetryComponent The telemetry component to use for setting the metric values.
|
|
62
|
+
* @param values The metric values to set.
|
|
63
|
+
* @param onError Optional callback invoked with the swallowed error, for callers that want visibility.
|
|
64
|
+
* @returns A promise that resolves when the values have been recorded or the error swallowed.
|
|
65
|
+
*/
|
|
66
|
+
static metricValues(telemetryComponent: ITelemetryComponent | undefined, values: ITelemetryMetricValueEntry[], onError?: (err: unknown) => Promise<void> | void): Promise<void>;
|
|
67
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export * from "./connectors/multiTelemetryConnector.js";
|
|
2
|
+
export * from "./connectors/silentTelemetryConnector.js";
|
|
3
|
+
export * from "./factories/metricsProducerFactory.js";
|
|
4
|
+
export * from "./factories/telemetryConnectorFactory.js";
|
|
5
|
+
export * from "./helpers/metricHelper.js";
|
|
6
|
+
export * from "./models/api/ITelemetryAddMetricValueRequest.js";
|
|
7
|
+
export * from "./models/api/ITelemetryCreateMetricRequest.js";
|
|
8
|
+
export * from "./models/api/ITelemetryGetMetricRequest.js";
|
|
9
|
+
export * from "./models/api/ITelemetryGetMetricResponse.js";
|
|
10
|
+
export * from "./models/api/ITelemetryGetMetricValueRequest.js";
|
|
11
|
+
export * from "./models/api/ITelemetryGetMetricValueResponse.js";
|
|
12
|
+
export * from "./models/api/ITelemetryListRequest.js";
|
|
13
|
+
export * from "./models/api/ITelemetryListResponse.js";
|
|
14
|
+
export * from "./models/api/ITelemetryRemoveMetricRequest.js";
|
|
15
|
+
export * from "./models/api/ITelemetryUpdateMetricRequest.js";
|
|
16
|
+
export * from "./models/api/ITelemetryValuesListRequest.js";
|
|
17
|
+
export * from "./models/api/ITelemetryValuesListResponse.js";
|
|
18
|
+
export * from "./models/IMetricsCollectorComponent.js";
|
|
19
|
+
export * from "./models/IMetricsProducer.js";
|
|
20
|
+
export * from "./models/IMultiTelemetryConnectorConstructorOptions.js";
|
|
21
|
+
export * from "./models/ITelemetryComponent.js";
|
|
22
|
+
export * from "./models/ITelemetryConnector.js";
|
|
23
|
+
export * from "./models/ITelemetryMetric.js";
|
|
24
|
+
export * from "./models/ITelemetryMetricValue.js";
|
|
25
|
+
export * from "./models/ITelemetryMetricValueEntry.js";
|
|
26
|
+
export * from "./models/metricCounterOperation.js";
|
|
27
|
+
export * from "./models/metricType.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { IComponent } from "@3sixty/core";
|
|
2
|
+
import type { ITelemetryMetricValueEntry } from "./ITelemetryMetricValueEntry.js";
|
|
3
|
+
/**
|
|
4
|
+
* Contract for a metrics producer.
|
|
5
|
+
*
|
|
6
|
+
* A producer declares its metrics with `register()` once and pushes current
|
|
7
|
+
* values with `collect()` on every poll cycle. Producers are discovered via
|
|
8
|
+
* `MetricsProducerFactory` and orchestrated by a `MetricsCollectorService`.
|
|
9
|
+
*
|
|
10
|
+
* Producers are factory-only entries - they are not lifecycle components of
|
|
11
|
+
* the engine. The orchestrating service owns the polling timer.
|
|
12
|
+
*/
|
|
13
|
+
export interface IMetricsProducer extends IComponent {
|
|
14
|
+
/**
|
|
15
|
+
* Register every metric this producer emits with the telemetry component.
|
|
16
|
+
* Called once when the orchestrating service starts.
|
|
17
|
+
* @returns A promise that resolves when all metrics have been registered.
|
|
18
|
+
*/
|
|
19
|
+
register(): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Read the current values for every metric this producer emits.
|
|
22
|
+
* Called on every poll cycle. The values are returned rather than recorded, so the
|
|
23
|
+
* orchestrating service can record a whole cycle in one operation.
|
|
24
|
+
* @returns The current values for this producer's metrics.
|
|
25
|
+
*/
|
|
26
|
+
collect(): Promise<ITelemetryMetricValueEntry[]>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { IComponent } from "@3sixty/core";
|
|
2
|
+
import type { ITelemetryMetric } from "./ITelemetryMetric.js";
|
|
3
|
+
import type { ITelemetryMetricValue } from "./ITelemetryMetricValue.js";
|
|
4
|
+
import type { ITelemetryMetricValueEntry } from "./ITelemetryMetricValueEntry.js";
|
|
5
|
+
import type { MetricCounterOperation } from "./metricCounterOperation.js";
|
|
6
|
+
import type { MetricType } from "./metricType.js";
|
|
7
|
+
/**
|
|
8
|
+
* Interface describing a telemetry component contract.
|
|
9
|
+
*/
|
|
10
|
+
export interface ITelemetryComponent extends IComponent {
|
|
11
|
+
/**
|
|
12
|
+
* Create one or more metrics.
|
|
13
|
+
* A single metric fails if it already exists; an array declares the set that should exist,
|
|
14
|
+
* creating the ones that are missing and leaving the rest untouched, so implementations
|
|
15
|
+
* which persist the definitions can resolve the whole set in one operation.
|
|
16
|
+
* @param metric The metric details, or the details of several metrics.
|
|
17
|
+
* @returns A promise that resolves when the metrics have been created.
|
|
18
|
+
*/
|
|
19
|
+
createMetric(metric: ITelemetryMetric | ITelemetryMetric[]): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Get the metric details and it's most recent value.
|
|
22
|
+
* @param id The metric id.
|
|
23
|
+
* @returns The metric details and it's most recent value.
|
|
24
|
+
*/
|
|
25
|
+
getMetric(id: string): Promise<{
|
|
26
|
+
metric: ITelemetryMetric;
|
|
27
|
+
value?: ITelemetryMetricValue;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Get a specific metric value by its id.
|
|
31
|
+
* @param id The id of the metric.
|
|
32
|
+
* @param valueId The id of the metric value.
|
|
33
|
+
* @returns The metric value.
|
|
34
|
+
*/
|
|
35
|
+
getMetricValue(id: string, valueId: string): Promise<ITelemetryMetricValue>;
|
|
36
|
+
/**
|
|
37
|
+
* Update metric.
|
|
38
|
+
* @param metric The metric details.
|
|
39
|
+
* @returns A promise that resolves when the metric has been updated.
|
|
40
|
+
*/
|
|
41
|
+
updateMetric(metric: Omit<ITelemetryMetric, "type">): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Add a metric value.
|
|
44
|
+
* @param id The id of the metric.
|
|
45
|
+
* @param value The value for the add operation.
|
|
46
|
+
* @param customData The custom data for the add operation.
|
|
47
|
+
* @returns The created metric value id.
|
|
48
|
+
*/
|
|
49
|
+
addMetricValue(id: string, value: MetricCounterOperation | number, customData?: {
|
|
50
|
+
[key: string]: unknown;
|
|
51
|
+
}): Promise<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Add multiple metric values, so implementations which persist them can do so in one
|
|
54
|
+
* operation instead of one per value.
|
|
55
|
+
* @param values The metric values to add.
|
|
56
|
+
* @returns The created metric value ids, in the order the values were supplied.
|
|
57
|
+
*/
|
|
58
|
+
addMetricValues(values: ITelemetryMetricValueEntry[]): Promise<string[]>;
|
|
59
|
+
/**
|
|
60
|
+
* Remove metric.
|
|
61
|
+
* @param id The id of the metric.
|
|
62
|
+
* @returns A promise that resolves when the metric and all its values have been removed.
|
|
63
|
+
*/
|
|
64
|
+
removeMetric(id: string): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Query the metrics.
|
|
67
|
+
* @param type The type of the metric.
|
|
68
|
+
* @param cursor The cursor to request the next chunk of entities.
|
|
69
|
+
* @param limit Limit the number of entities to return.
|
|
70
|
+
* @returns All the entities for the storage matching the conditions,
|
|
71
|
+
* and a cursor which can be used to request more entities.
|
|
72
|
+
* @throws NotImplementedError if the implementation does not support retrieval.
|
|
73
|
+
*/
|
|
74
|
+
query(type?: MetricType, cursor?: string, limit?: number): Promise<{
|
|
75
|
+
/**
|
|
76
|
+
* The metrics.
|
|
77
|
+
*/
|
|
78
|
+
entities: ITelemetryMetric[];
|
|
79
|
+
/**
|
|
80
|
+
* An optional cursor, when defined can be used to call find to get more values.
|
|
81
|
+
*/
|
|
82
|
+
cursor?: string;
|
|
83
|
+
}>;
|
|
84
|
+
/**
|
|
85
|
+
* Query the metric values.
|
|
86
|
+
* @param id The id of the metric.
|
|
87
|
+
* @param timeStart The inclusive time as the start of the metric entries.
|
|
88
|
+
* @param timeEnd The inclusive time as the end of the metric entries.
|
|
89
|
+
* @param cursor The cursor to request the next chunk of entities.
|
|
90
|
+
* @param limit Limit the number of entities to return.
|
|
91
|
+
* @returns All the entities for the storage matching the conditions,
|
|
92
|
+
* and a cursor which can be used to request more entities.
|
|
93
|
+
* @throws NotImplementedError if the implementation does not support retrieval.
|
|
94
|
+
*/
|
|
95
|
+
queryValues(id: string, timeStart?: number, timeEnd?: number, cursor?: string, limit?: number): Promise<{
|
|
96
|
+
/**
|
|
97
|
+
* The metric details.
|
|
98
|
+
*/
|
|
99
|
+
metric: ITelemetryMetric;
|
|
100
|
+
/**
|
|
101
|
+
* The values for the metric.
|
|
102
|
+
*/
|
|
103
|
+
entities: ITelemetryMetricValue[];
|
|
104
|
+
/**
|
|
105
|
+
* An optional cursor, when defined can be used to call find to get more values.
|
|
106
|
+
*/
|
|
107
|
+
cursor?: string;
|
|
108
|
+
}>;
|
|
109
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { IComponent } from "@3sixty/core";
|
|
2
|
+
import type { ITelemetryMetric } from "./ITelemetryMetric.js";
|
|
3
|
+
import type { ITelemetryMetricValue } from "./ITelemetryMetricValue.js";
|
|
4
|
+
import type { ITelemetryMetricValueEntry } from "./ITelemetryMetricValueEntry.js";
|
|
5
|
+
import type { MetricCounterOperation } from "./metricCounterOperation.js";
|
|
6
|
+
import type { MetricType } from "./metricType.js";
|
|
7
|
+
/**
|
|
8
|
+
* Interface describing a telemetry connector.
|
|
9
|
+
*/
|
|
10
|
+
export interface ITelemetryConnector extends IComponent {
|
|
11
|
+
/**
|
|
12
|
+
* Create one or more metrics.
|
|
13
|
+
* A single metric fails if it already exists; an array declares the set that should exist,
|
|
14
|
+
* creating the ones that are missing and leaving the rest untouched, so implementations
|
|
15
|
+
* which persist the definitions can resolve the whole set in one operation.
|
|
16
|
+
* @param metric The metric details, or the details of several metrics.
|
|
17
|
+
* @returns A promise that resolves when the metrics have been created.
|
|
18
|
+
*/
|
|
19
|
+
createMetric(metric: ITelemetryMetric | ITelemetryMetric[]): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Get the metric details and it's most recent value.
|
|
22
|
+
* @param id The metric id.
|
|
23
|
+
* @returns The metric details and it's most recent value.
|
|
24
|
+
*/
|
|
25
|
+
getMetric?(id: string): Promise<{
|
|
26
|
+
metric: ITelemetryMetric;
|
|
27
|
+
value?: ITelemetryMetricValue;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Get a specific metric value by its id.
|
|
31
|
+
* @param id The id of the metric.
|
|
32
|
+
* @param valueId The id of the metric value.
|
|
33
|
+
* @returns The metric value.
|
|
34
|
+
*/
|
|
35
|
+
getMetricValue?(id: string, valueId: string): Promise<ITelemetryMetricValue>;
|
|
36
|
+
/**
|
|
37
|
+
* Update metric.
|
|
38
|
+
* @param metric The metric details.
|
|
39
|
+
* @returns A promise that resolves when the metric has been updated.
|
|
40
|
+
*/
|
|
41
|
+
updateMetric(metric: Omit<ITelemetryMetric, "type">): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Update metric value.
|
|
44
|
+
* @param id The id of the metric.
|
|
45
|
+
* @param value The value for the update operation.
|
|
46
|
+
* @param customData The custom data for the update operation.
|
|
47
|
+
* @returns The created metric value id.
|
|
48
|
+
*/
|
|
49
|
+
addMetricValue(id: string, value: MetricCounterOperation | number, customData?: {
|
|
50
|
+
[key: string]: unknown;
|
|
51
|
+
}): Promise<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Add multiple metric values, so implementations which persist them can do so in one
|
|
54
|
+
* operation instead of one per value.
|
|
55
|
+
* @param values The metric values to add.
|
|
56
|
+
* @returns The created metric value ids, in the order the values were supplied.
|
|
57
|
+
*/
|
|
58
|
+
addMetricValues(values: ITelemetryMetricValueEntry[]): Promise<string[]>;
|
|
59
|
+
/**
|
|
60
|
+
* Remove metric.
|
|
61
|
+
* @param id The id of the metric.
|
|
62
|
+
* @returns A promise that resolves when the metric and all its values have been removed.
|
|
63
|
+
*/
|
|
64
|
+
removeMetric(id: string): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Query the metrics.
|
|
67
|
+
* @param type The type of the metric.
|
|
68
|
+
* @param cursor The cursor to request the next chunk of entities.
|
|
69
|
+
* @param limit Limit the number of entities to return.
|
|
70
|
+
* @returns All the entities for the storage matching the conditions,
|
|
71
|
+
* and a cursor which can be used to request more entities.
|
|
72
|
+
* @throws NotImplementedError if the implementation does not support retrieval.
|
|
73
|
+
*/
|
|
74
|
+
query?(type?: MetricType, cursor?: string, limit?: number): Promise<{
|
|
75
|
+
/**
|
|
76
|
+
* The metrics.
|
|
77
|
+
*/
|
|
78
|
+
entities: ITelemetryMetric[];
|
|
79
|
+
/**
|
|
80
|
+
* An optional cursor, when defined can be used to call find to get more values.
|
|
81
|
+
*/
|
|
82
|
+
cursor?: string;
|
|
83
|
+
}>;
|
|
84
|
+
/**
|
|
85
|
+
* Query the metric values.
|
|
86
|
+
* @param id The id of the metric.
|
|
87
|
+
* @param timeStart The inclusive time as the start of the metric entries.
|
|
88
|
+
* @param timeEnd The inclusive time as the end of the metric entries.
|
|
89
|
+
* @param cursor The cursor to request the next chunk of entities.
|
|
90
|
+
* @param limit Limit the number of entities to return.
|
|
91
|
+
* @returns All the entities for the storage matching the conditions,
|
|
92
|
+
* and a cursor which can be used to request more entities.
|
|
93
|
+
* @throws NotImplementedError if the implementation does not support retrieval.
|
|
94
|
+
*/
|
|
95
|
+
queryValues?(id: string, timeStart?: number, timeEnd?: number, cursor?: string, limit?: number): Promise<{
|
|
96
|
+
/**
|
|
97
|
+
* The metric details.
|
|
98
|
+
*/
|
|
99
|
+
metric: ITelemetryMetric;
|
|
100
|
+
/**
|
|
101
|
+
* The values for the metric.
|
|
102
|
+
*/
|
|
103
|
+
entities: ITelemetryMetricValue[];
|
|
104
|
+
/**
|
|
105
|
+
* An optional cursor, when defined can be used to call find to get more values.
|
|
106
|
+
*/
|
|
107
|
+
cursor?: string;
|
|
108
|
+
}>;
|
|
109
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { MetricType } from "./metricType.js";
|
|
2
|
+
/**
|
|
3
|
+
* Interface describing a telemetry metric.
|
|
4
|
+
*/
|
|
5
|
+
export interface ITelemetryMetric {
|
|
6
|
+
/**
|
|
7
|
+
* The id of the metric.
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* The label of the metric.
|
|
12
|
+
*/
|
|
13
|
+
label: string;
|
|
14
|
+
/**
|
|
15
|
+
* The type of the metric.
|
|
16
|
+
*/
|
|
17
|
+
type: MetricType;
|
|
18
|
+
/**
|
|
19
|
+
* Description.
|
|
20
|
+
*/
|
|
21
|
+
description?: string;
|
|
22
|
+
/**
|
|
23
|
+
* The unit the metric describes.
|
|
24
|
+
*/
|
|
25
|
+
unit?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The maximum number of values to retain; oldest are trimmed on each addMetricValue call.
|
|
28
|
+
* Unlimited when absent.
|
|
29
|
+
*/
|
|
30
|
+
maxHistory?: number;
|
|
31
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface describing a telemetry metric value.
|
|
3
|
+
*/
|
|
4
|
+
export interface ITelemetryMetricValue {
|
|
5
|
+
/**
|
|
6
|
+
* The id of the metric value.
|
|
7
|
+
*/
|
|
8
|
+
id: string;
|
|
9
|
+
/**
|
|
10
|
+
* The timestamp of the metric.
|
|
11
|
+
*/
|
|
12
|
+
ts: number;
|
|
13
|
+
/**
|
|
14
|
+
* The value of the metric.
|
|
15
|
+
*/
|
|
16
|
+
value: number;
|
|
17
|
+
/**
|
|
18
|
+
* The custom data for the metric value.
|
|
19
|
+
*/
|
|
20
|
+
customData?: {
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { MetricCounterOperation } from "./metricCounterOperation.js";
|
|
2
|
+
/**
|
|
3
|
+
* A single metric value in a batch add operation.
|
|
4
|
+
*/
|
|
5
|
+
export interface ITelemetryMetricValueEntry {
|
|
6
|
+
/**
|
|
7
|
+
* The id of the metric.
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* The value for the add operation.
|
|
12
|
+
*/
|
|
13
|
+
value: MetricCounterOperation | number;
|
|
14
|
+
/**
|
|
15
|
+
* The custom data for the metric value.
|
|
16
|
+
*/
|
|
17
|
+
customData?: {
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { MetricCounterOperation } from "../metricCounterOperation.js";
|
|
2
|
+
/**
|
|
3
|
+
* Add a telemetry metric value.
|
|
4
|
+
*/
|
|
5
|
+
export interface ITelemetryAddMetricValueRequest {
|
|
6
|
+
/**
|
|
7
|
+
* The path parameters.
|
|
8
|
+
*/
|
|
9
|
+
pathParams: {
|
|
10
|
+
/**
|
|
11
|
+
* The id of the metric.
|
|
12
|
+
*/
|
|
13
|
+
id: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The data to be used in the update.
|
|
17
|
+
*/
|
|
18
|
+
body: {
|
|
19
|
+
/**
|
|
20
|
+
* The value for the update operation.
|
|
21
|
+
*/
|
|
22
|
+
value: MetricCounterOperation | number;
|
|
23
|
+
/**
|
|
24
|
+
* The custom data for the update operation.
|
|
25
|
+
*/
|
|
26
|
+
customData?: {
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ITelemetryMetric } from "../ITelemetryMetric.js";
|
|
2
|
+
/**
|
|
3
|
+
* Create one or more telemetry metrics.
|
|
4
|
+
*/
|
|
5
|
+
export interface ITelemetryCreateMetricRequest {
|
|
6
|
+
/**
|
|
7
|
+
* The data to be used in the create. A single metric fails if it already exists; an array
|
|
8
|
+
* declares the set that should exist, creating the ones that are missing.
|
|
9
|
+
*/
|
|
10
|
+
body: ITelemetryMetric | ITelemetryMetric[];
|
|
11
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ITelemetryMetric } from "../ITelemetryMetric.js";
|
|
2
|
+
import type { ITelemetryMetricValue } from "../ITelemetryMetricValue.js";
|
|
3
|
+
/**
|
|
4
|
+
* Get a telemetry metric response.
|
|
5
|
+
*/
|
|
6
|
+
export interface ITelemetryGetMetricResponse {
|
|
7
|
+
/**
|
|
8
|
+
* The body parameters.
|
|
9
|
+
*/
|
|
10
|
+
body: {
|
|
11
|
+
/**
|
|
12
|
+
* The metric.
|
|
13
|
+
*/
|
|
14
|
+
metric: ITelemetryMetric;
|
|
15
|
+
/**
|
|
16
|
+
* The latest metric value.
|
|
17
|
+
*/
|
|
18
|
+
value?: ITelemetryMetricValue;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get a telemetry metric value.
|
|
3
|
+
*/
|
|
4
|
+
export interface ITelemetryGetMetricValueRequest {
|
|
5
|
+
/**
|
|
6
|
+
* The path parameters.
|
|
7
|
+
*/
|
|
8
|
+
pathParams: {
|
|
9
|
+
/**
|
|
10
|
+
* The id of the metric.
|
|
11
|
+
*/
|
|
12
|
+
id: string;
|
|
13
|
+
/**
|
|
14
|
+
* The id of the metric value.
|
|
15
|
+
*/
|
|
16
|
+
valueId: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the a list of the telemetry metrics.
|
|
3
|
+
*/
|
|
4
|
+
export interface ITelemetryListRequest {
|
|
5
|
+
/**
|
|
6
|
+
* The query parameters.
|
|
7
|
+
*/
|
|
8
|
+
query?: {
|
|
9
|
+
/**
|
|
10
|
+
* The type of the metric.
|
|
11
|
+
*/
|
|
12
|
+
type?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The optional cursor to get next chunk.
|
|
15
|
+
*/
|
|
16
|
+
cursor?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Limit the number of entities to return.
|
|
19
|
+
*/
|
|
20
|
+
limit?: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ITelemetryMetric } from "../ITelemetryMetric.js";
|
|
2
|
+
/**
|
|
3
|
+
* Response for telemetry list request.
|
|
4
|
+
*/
|
|
5
|
+
export interface ITelemetryListResponse {
|
|
6
|
+
/**
|
|
7
|
+
* The response payload.
|
|
8
|
+
*/
|
|
9
|
+
body: {
|
|
10
|
+
/**
|
|
11
|
+
* The metrics.
|
|
12
|
+
*/
|
|
13
|
+
entities: ITelemetryMetric[];
|
|
14
|
+
/**
|
|
15
|
+
* An optional cursor, when defined can be used to call find to get more entities.
|
|
16
|
+
*/
|
|
17
|
+
cursor?: string;
|
|
18
|
+
};
|
|
19
|
+
}
|