@twin.org/telemetry-service 0.0.1-next.3

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.
@@ -0,0 +1,99 @@
1
+ import { type ITelemetryComponent, type ITelemetryMetric, type ITelemetryMetricValue, type MetricType } from "@twin.org/telemetry-models";
2
+ /**
3
+ * Service for performing telemetry operations to a connector.
4
+ */
5
+ export declare class TelemetryService implements ITelemetryComponent {
6
+ /**
7
+ * Runtime name for the class.
8
+ */
9
+ readonly CLASS_NAME: string;
10
+ /**
11
+ * Create a new instance of TelemetryService.
12
+ * @param options The options for the connector.
13
+ * @param options.telemetryConnectorType The type of the telemetry connector to use, defaults to "telemetry".
14
+ */
15
+ constructor(options?: {
16
+ telemetryConnectorType?: string;
17
+ });
18
+ /**
19
+ * Create a new metric.
20
+ * @param metric The metric details.
21
+ * @returns Nothing.
22
+ */
23
+ createMetric(metric: ITelemetryMetric): Promise<void>;
24
+ /**
25
+ * Get the metric details and it's most recent value.
26
+ * @param id The metric id.
27
+ * @returns The metric details and it's most recent value.
28
+ */
29
+ getMetric(id: string): Promise<{
30
+ metric: ITelemetryMetric;
31
+ value: ITelemetryMetricValue;
32
+ }>;
33
+ /**
34
+ * Update metric.
35
+ * @param metric The metric details.
36
+ * @returns Nothing.
37
+ */
38
+ updateMetric(metric: Omit<ITelemetryMetric, "type">): Promise<void>;
39
+ /**
40
+ * Add a metric value.
41
+ * @param id The id of the metric.
42
+ * @param value The value for the add operation.
43
+ * @param customData The custom data for the add operation.
44
+ * @returns The created metric value id.
45
+ */
46
+ addMetricValue(id: string, value: "inc" | "dec" | number, customData?: {
47
+ [key: string]: unknown;
48
+ }): Promise<string>;
49
+ /**
50
+ * Remove metric.
51
+ * @param id The id of the metric.
52
+ * @returns Nothing.
53
+ */
54
+ removeMetric(id: string): Promise<void>;
55
+ /**
56
+ * Query the metrics.
57
+ * @param type The type of the metric.
58
+ * @param cursor The cursor to request the next page of entities.
59
+ * @param pageSize The maximum number of entities in a page.
60
+ * @returns All the entities for the storage matching the conditions,
61
+ * and a cursor which can be used to request more entities.
62
+ * @throws NotImplementedError if the implementation does not support retrieval.
63
+ */
64
+ query(type?: MetricType, cursor?: string, pageSize?: number): Promise<{
65
+ /**
66
+ * The metrics.
67
+ */
68
+ entities: ITelemetryMetric[];
69
+ /**
70
+ * An optional cursor, when defined can be used to call find to get more values.
71
+ */
72
+ cursor?: string;
73
+ }>;
74
+ /**
75
+ * Query the metric values.
76
+ * @param id The id of the metric.
77
+ * @param timeStart The inclusive time as the start of the metric entries.
78
+ * @param timeEnd The inclusive time as the end of the metric entries.
79
+ * @param cursor The cursor to request the next page of entities.
80
+ * @param pageSize The maximum number of entities in a page.
81
+ * @returns All the entities for the storage matching the conditions,
82
+ * and a cursor which can be used to request more entities.
83
+ * @throws NotImplementedError if the implementation does not support retrieval.
84
+ */
85
+ queryValues(id: string, timeStart?: number, timeEnd?: number, cursor?: string, pageSize?: number): Promise<{
86
+ /**
87
+ * The metric details.
88
+ */
89
+ metric: ITelemetryMetric;
90
+ /**
91
+ * The values for the metric.
92
+ */
93
+ entities: ITelemetryMetricValue[];
94
+ /**
95
+ * An optional cursor, when defined can be used to call find to get more values.
96
+ */
97
+ cursor?: string;
98
+ }>;
99
+ }
@@ -0,0 +1,5 @@
1
+ # @twin.org/telemetry-service - Changelog
2
+
3
+ ## v0.0.1-next.3
4
+
5
+ - Initial Release
@@ -0,0 +1 @@
1
+ # @twin.org/telemetry-service - Examples