@3sixty/telemetry-processors 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/index.js +9 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/metricsRouteProcessor.js +320 -0
- package/dist/es/metricsRouteProcessor.js.map +1 -0
- package/dist/es/models/IMetricsRouteProcessorConfig.js +4 -0
- package/dist/es/models/IMetricsRouteProcessorConfig.js.map +1 -0
- package/dist/es/models/IMetricsRouteProcessorConstructorOptions.js +2 -0
- package/dist/es/models/IMetricsRouteProcessorConstructorOptions.js.map +1 -0
- package/dist/es/models/IPendingMetricRecording.js +2 -0
- package/dist/es/models/IPendingMetricRecording.js.map +1 -0
- package/dist/es/models/restRequestsMetrics.js +12 -0
- package/dist/es/models/restRequestsMetrics.js.map +1 -0
- package/dist/es/models/telemetryMetricIds.js +13 -0
- package/dist/es/models/telemetryMetricIds.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/metricsRouteProcessor.d.ts +65 -0
- package/dist/types/models/IMetricsRouteProcessorConfig.d.ts +34 -0
- package/dist/types/models/IMetricsRouteProcessorConstructorOptions.d.ts +18 -0
- package/dist/types/models/IPendingMetricRecording.d.ts +27 -0
- package/dist/types/models/restRequestsMetrics.d.ts +5 -0
- package/dist/types/models/telemetryMetricIds.d.ts +13 -0
- package/docs/changelog.md +0 -0
- package/docs/examples.md +37 -0
- package/docs/reference/classes/MetricsRouteProcessor.md +173 -0
- package/docs/reference/index.md +20 -0
- package/docs/reference/interfaces/IMetricsRouteProcessorConfig.md +68 -0
- package/docs/reference/interfaces/IMetricsRouteProcessorConstructorOptions.md +27 -0
- package/docs/reference/interfaces/IPendingMetricRecording.md +44 -0
- package/docs/reference/type-aliases/TelemetryMetricIds.md +5 -0
- package/docs/reference/variables/RestRequestsMetrics.md +5 -0
- package/docs/reference/variables/TelemetryMetricIds.md +13 -0
- package/locales/en.json +9 -0
- package/package.json +39 -5
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright 2026 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
/**
|
|
4
|
+
* Metric IDs emitted by telemetry-processors.
|
|
5
|
+
*/
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
|
+
export const TelemetryMetricIds = {
|
|
8
|
+
/**
|
|
9
|
+
* Total number of REST requests received.
|
|
10
|
+
*/
|
|
11
|
+
RestRequests: "rest_requests"
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=telemetryMetricIds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetryMetricIds.js","sourceRoot":"","sources":["../../../src/models/telemetryMetricIds.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IACjC;;OAEG;IACH,YAAY,EAAE,eAAe;CACpB,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Metric IDs emitted by telemetry-processors.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const TelemetryMetricIds = {\n\t/**\n\t * Total number of REST requests received.\n\t */\n\tRestRequests: \"rest_requests\"\n} as const;\n\n/**\n * Metric IDs emitted by telemetry-processors.\n */\nexport type TelemetryMetricIds = (typeof TelemetryMetricIds)[keyof typeof TelemetryMetricIds];\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./metricsRouteProcessor.js";
|
|
2
|
+
export * from "./models/IMetricsRouteProcessorConfig.js";
|
|
3
|
+
export * from "./models/IMetricsRouteProcessorConstructorOptions.js";
|
|
4
|
+
export * from "./models/IPendingMetricRecording.js";
|
|
5
|
+
export * from "./models/restRequestsMetrics.js";
|
|
6
|
+
export * from "./models/telemetryMetricIds.js";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { IBaseRoute, IBaseRouteProcessor, IHttpResponse, IHttpServerRequest } from "@3sixty/api-models";
|
|
2
|
+
import { type IContextIds } from "@3sixty/context";
|
|
3
|
+
import type { IMetricsRouteProcessorConstructorOptions } from "./models/IMetricsRouteProcessorConstructorOptions.js";
|
|
4
|
+
/**
|
|
5
|
+
* Route processor that records HTTP request counts after each request completes.
|
|
6
|
+
* Emits a single counter labelled with the HTTP method, route template, and status class.
|
|
7
|
+
* Raw request URLs are never used as labels to keep cardinality bounded.
|
|
8
|
+
* Recording is queued off the response path, so the reply never waits for telemetry storage.
|
|
9
|
+
*/
|
|
10
|
+
export declare class MetricsRouteProcessor implements IBaseRouteProcessor {
|
|
11
|
+
/**
|
|
12
|
+
* Runtime name for the class.
|
|
13
|
+
*/
|
|
14
|
+
static readonly CLASS_NAME: string;
|
|
15
|
+
/**
|
|
16
|
+
* Default number of request values to retain.
|
|
17
|
+
*/
|
|
18
|
+
static readonly DEFAULT_MAX_HISTORY: number;
|
|
19
|
+
/**
|
|
20
|
+
* Default path prefixes excluded from metrics recording, the probe and info routes.
|
|
21
|
+
* The root entry is matched in full, so the routes below it are still recorded.
|
|
22
|
+
*/
|
|
23
|
+
static readonly DEFAULT_EXCLUDE_PATHS: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Default number of recordings queued before new ones are dropped.
|
|
26
|
+
*/
|
|
27
|
+
static readonly DEFAULT_MAX_PENDING_RECORDINGS: number;
|
|
28
|
+
/**
|
|
29
|
+
* Default interval in milliseconds between drains of the queue.
|
|
30
|
+
*/
|
|
31
|
+
static readonly DEFAULT_DRAIN_INTERVAL_MS: number;
|
|
32
|
+
/**
|
|
33
|
+
* Create a new instance of MetricsRouteProcessor.
|
|
34
|
+
* @param options The options for the processor.
|
|
35
|
+
*/
|
|
36
|
+
constructor(options?: IMetricsRouteProcessorConstructorOptions);
|
|
37
|
+
/**
|
|
38
|
+
* Returns the class name of the component.
|
|
39
|
+
* @returns The class name of the component.
|
|
40
|
+
*/
|
|
41
|
+
className(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Register all REST request metrics and start the timer which drains the queued recordings.
|
|
44
|
+
* @returns A promise that resolves when all metrics have been registered.
|
|
45
|
+
*/
|
|
46
|
+
start(): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Clear the drain timer and hand over the recordings which are still queued.
|
|
49
|
+
* When a drain is already running it finishes the batch it took, and anything queued after
|
|
50
|
+
* that is left unwritten rather than holding the shutdown open.
|
|
51
|
+
* @returns A promise that resolves when the queued recordings have been handed over.
|
|
52
|
+
*/
|
|
53
|
+
stop(): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Queue a counter increment after the request completes.
|
|
56
|
+
* @param request The HTTP request.
|
|
57
|
+
* @param response The HTTP response.
|
|
58
|
+
* @param route The matched route definition, if any.
|
|
59
|
+
* @param contextIds The context IDs for the request.
|
|
60
|
+
* @param processorState Shared state for the current request processor chain.
|
|
61
|
+
*/
|
|
62
|
+
post(request: IHttpServerRequest, response: IHttpResponse, route: IBaseRoute | undefined, contextIds: IContextIds, processorState: {
|
|
63
|
+
[id: string]: unknown;
|
|
64
|
+
}): Promise<void>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for the MetricsRouteProcessor.
|
|
3
|
+
*/
|
|
4
|
+
export interface IMetricsRouteProcessorConfig {
|
|
5
|
+
/**
|
|
6
|
+
* URL path prefixes that should not be recorded as metrics, with the root path "/" matched in
|
|
7
|
+
* full so the routes below it are still recorded.
|
|
8
|
+
* Useful for suppressing noise from health-check or metrics-scrape endpoints. Supplying this
|
|
9
|
+
* replaces the defaults rather than adding to them, so include the probe paths to keep them
|
|
10
|
+
* excluded, or an empty array to record every route.
|
|
11
|
+
* @default ["/", "/favicon.ico", "/spec", "/livez", "/readyz", "/info", "/health"].
|
|
12
|
+
*/
|
|
13
|
+
excludePaths?: string[];
|
|
14
|
+
/**
|
|
15
|
+
* Maximum number of request values to retain. A value is recorded for every request that
|
|
16
|
+
* is not excluded, so without a cap the history grows for as long as the node serves
|
|
17
|
+
* traffic; values <= 0 retain everything.
|
|
18
|
+
* @default 10000.
|
|
19
|
+
*/
|
|
20
|
+
maxHistory?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Maximum number of recordings queued off the response path before new ones are dropped.
|
|
23
|
+
* Recording never blocks the response, so without a cap a telemetry component slower than the
|
|
24
|
+
* request rate would queue values without bound; values <= 0 queue everything.
|
|
25
|
+
* @default 1000.
|
|
26
|
+
*/
|
|
27
|
+
maxPendingRecordings?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Interval in milliseconds between drains of the queued recordings; values <= 0 use the
|
|
30
|
+
* default.
|
|
31
|
+
* @default 1000.
|
|
32
|
+
*/
|
|
33
|
+
drainIntervalMs?: number;
|
|
34
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IMetricsRouteProcessorConfig } from "./IMetricsRouteProcessorConfig.js";
|
|
2
|
+
/**
|
|
3
|
+
* Constructor options for the MetricsRouteProcessor.
|
|
4
|
+
*/
|
|
5
|
+
export interface IMetricsRouteProcessorConstructorOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The component type to use for the telemetry component.
|
|
8
|
+
*/
|
|
9
|
+
telemetryComponentType?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The component type to use for logging metric recording failures.
|
|
12
|
+
*/
|
|
13
|
+
loggingComponentType?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optional processor configuration.
|
|
16
|
+
*/
|
|
17
|
+
config?: IMetricsRouteProcessorConfig;
|
|
18
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { IContextIds } from "@3sixty/context";
|
|
2
|
+
/**
|
|
3
|
+
* A request metric queued by the metrics route processor, waiting to be handed to the
|
|
4
|
+
* telemetry component.
|
|
5
|
+
*/
|
|
6
|
+
export interface IPendingMetricRecording {
|
|
7
|
+
/**
|
|
8
|
+
* The context IDs of the request, used to record the metric in that request's context.
|
|
9
|
+
*/
|
|
10
|
+
contextIds: IContextIds;
|
|
11
|
+
/**
|
|
12
|
+
* The HTTP method of the request.
|
|
13
|
+
*/
|
|
14
|
+
method: string;
|
|
15
|
+
/**
|
|
16
|
+
* The route template path of the request.
|
|
17
|
+
*/
|
|
18
|
+
route: string;
|
|
19
|
+
/**
|
|
20
|
+
* The HTTP status code of the response.
|
|
21
|
+
*/
|
|
22
|
+
statusCode: number;
|
|
23
|
+
/**
|
|
24
|
+
* The status class of the response.
|
|
25
|
+
*/
|
|
26
|
+
statusClass: string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metric IDs emitted by telemetry-processors.
|
|
3
|
+
*/
|
|
4
|
+
export declare const TelemetryMetricIds: {
|
|
5
|
+
/**
|
|
6
|
+
* Total number of REST requests received.
|
|
7
|
+
*/
|
|
8
|
+
readonly RestRequests: "rest_requests";
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Metric IDs emitted by telemetry-processors.
|
|
12
|
+
*/
|
|
13
|
+
export type TelemetryMetricIds = (typeof TelemetryMetricIds)[keyof typeof TelemetryMetricIds];
|
|
File without changes
|
package/docs/examples.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Telemetry Processors Examples
|
|
2
|
+
|
|
3
|
+
These examples show how to register the request counter and record route metrics after an HTTP request completes.
|
|
4
|
+
|
|
5
|
+
## MetricsRouteProcessor
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { ComponentFactory } from '@3sixty/core';
|
|
9
|
+
import { SilentTelemetryConnector } from '@3sixty/telemetry-models';
|
|
10
|
+
import { MetricsRouteProcessor } from '@3sixty/telemetry-processors';
|
|
11
|
+
|
|
12
|
+
ComponentFactory.register('telemetry', () => new SilentTelemetryConnector());
|
|
13
|
+
|
|
14
|
+
// The probe and info routes are excluded by default; supplying excludePaths replaces that
|
|
15
|
+
// list, so include them to keep them excluded.
|
|
16
|
+
const processor = new MetricsRouteProcessor({
|
|
17
|
+
telemetryComponentType: 'telemetry',
|
|
18
|
+
config: { excludePaths: ['/livez', '/readyz', '/info', '/metrics'] }
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
console.log(processor.className()); // metricsRouteProcessor
|
|
22
|
+
|
|
23
|
+
// start also starts the timer which drains the queued recordings.
|
|
24
|
+
await processor.start();
|
|
25
|
+
|
|
26
|
+
// post only queues the recording, so the response is not charged with storage latency.
|
|
27
|
+
await processor.post(
|
|
28
|
+
{ method: 'GET', url: '/api/v1/items/abc123' },
|
|
29
|
+
{ statusCode: 200 },
|
|
30
|
+
{ operationId: 'getItem', path: '/api/v1/items/:id' },
|
|
31
|
+
{},
|
|
32
|
+
{}
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
// stop clears the timer and hands over anything still queued.
|
|
36
|
+
await processor.stop();
|
|
37
|
+
```
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Class: MetricsRouteProcessor
|
|
2
|
+
|
|
3
|
+
Route processor that records HTTP request counts after each request completes.
|
|
4
|
+
Emits a single counter labelled with the HTTP method, route template, and status class.
|
|
5
|
+
Raw request URLs are never used as labels to keep cardinality bounded.
|
|
6
|
+
Recording is queued off the response path, so the reply never waits for telemetry storage.
|
|
7
|
+
|
|
8
|
+
## Implements
|
|
9
|
+
|
|
10
|
+
- `IBaseRouteProcessor`
|
|
11
|
+
|
|
12
|
+
## Constructors
|
|
13
|
+
|
|
14
|
+
### Constructor
|
|
15
|
+
|
|
16
|
+
> **new MetricsRouteProcessor**(`options?`): `MetricsRouteProcessor`
|
|
17
|
+
|
|
18
|
+
Create a new instance of MetricsRouteProcessor.
|
|
19
|
+
|
|
20
|
+
#### Parameters
|
|
21
|
+
|
|
22
|
+
##### options?
|
|
23
|
+
|
|
24
|
+
[`IMetricsRouteProcessorConstructorOptions`](../interfaces/IMetricsRouteProcessorConstructorOptions.md)
|
|
25
|
+
|
|
26
|
+
The options for the processor.
|
|
27
|
+
|
|
28
|
+
#### Returns
|
|
29
|
+
|
|
30
|
+
`MetricsRouteProcessor`
|
|
31
|
+
|
|
32
|
+
## Properties
|
|
33
|
+
|
|
34
|
+
### CLASS\_NAME {#class_name}
|
|
35
|
+
|
|
36
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
37
|
+
|
|
38
|
+
Runtime name for the class.
|
|
39
|
+
|
|
40
|
+
***
|
|
41
|
+
|
|
42
|
+
### DEFAULT\_MAX\_HISTORY {#default_max_history}
|
|
43
|
+
|
|
44
|
+
> `readonly` `static` **DEFAULT\_MAX\_HISTORY**: `number` = `10000`
|
|
45
|
+
|
|
46
|
+
Default number of request values to retain.
|
|
47
|
+
|
|
48
|
+
***
|
|
49
|
+
|
|
50
|
+
### DEFAULT\_EXCLUDE\_PATHS {#default_exclude_paths}
|
|
51
|
+
|
|
52
|
+
> `readonly` `static` **DEFAULT\_EXCLUDE\_PATHS**: `string`[]
|
|
53
|
+
|
|
54
|
+
Default path prefixes excluded from metrics recording, the probe and info routes.
|
|
55
|
+
The root entry is matched in full, so the routes below it are still recorded.
|
|
56
|
+
|
|
57
|
+
***
|
|
58
|
+
|
|
59
|
+
### DEFAULT\_MAX\_PENDING\_RECORDINGS {#default_max_pending_recordings}
|
|
60
|
+
|
|
61
|
+
> `readonly` `static` **DEFAULT\_MAX\_PENDING\_RECORDINGS**: `number` = `1000`
|
|
62
|
+
|
|
63
|
+
Default number of recordings queued before new ones are dropped.
|
|
64
|
+
|
|
65
|
+
***
|
|
66
|
+
|
|
67
|
+
### DEFAULT\_DRAIN\_INTERVAL\_MS {#default_drain_interval_ms}
|
|
68
|
+
|
|
69
|
+
> `readonly` `static` **DEFAULT\_DRAIN\_INTERVAL\_MS**: `number` = `1000`
|
|
70
|
+
|
|
71
|
+
Default interval in milliseconds between drains of the queue.
|
|
72
|
+
|
|
73
|
+
## Methods
|
|
74
|
+
|
|
75
|
+
### className() {#classname}
|
|
76
|
+
|
|
77
|
+
> **className**(): `string`
|
|
78
|
+
|
|
79
|
+
Returns the class name of the component.
|
|
80
|
+
|
|
81
|
+
#### Returns
|
|
82
|
+
|
|
83
|
+
`string`
|
|
84
|
+
|
|
85
|
+
The class name of the component.
|
|
86
|
+
|
|
87
|
+
#### Implementation of
|
|
88
|
+
|
|
89
|
+
`IBaseRouteProcessor.className`
|
|
90
|
+
|
|
91
|
+
***
|
|
92
|
+
|
|
93
|
+
### start() {#start}
|
|
94
|
+
|
|
95
|
+
> **start**(): `Promise`\<`void`\>
|
|
96
|
+
|
|
97
|
+
Register all REST request metrics and start the timer which drains the queued recordings.
|
|
98
|
+
|
|
99
|
+
#### Returns
|
|
100
|
+
|
|
101
|
+
`Promise`\<`void`\>
|
|
102
|
+
|
|
103
|
+
A promise that resolves when all metrics have been registered.
|
|
104
|
+
|
|
105
|
+
#### Implementation of
|
|
106
|
+
|
|
107
|
+
`IBaseRouteProcessor.start`
|
|
108
|
+
|
|
109
|
+
***
|
|
110
|
+
|
|
111
|
+
### stop() {#stop}
|
|
112
|
+
|
|
113
|
+
> **stop**(): `Promise`\<`void`\>
|
|
114
|
+
|
|
115
|
+
Clear the drain timer and hand over the recordings which are still queued.
|
|
116
|
+
When a drain is already running it finishes the batch it took, and anything queued after
|
|
117
|
+
that is left unwritten rather than holding the shutdown open.
|
|
118
|
+
|
|
119
|
+
#### Returns
|
|
120
|
+
|
|
121
|
+
`Promise`\<`void`\>
|
|
122
|
+
|
|
123
|
+
A promise that resolves when the queued recordings have been handed over.
|
|
124
|
+
|
|
125
|
+
#### Implementation of
|
|
126
|
+
|
|
127
|
+
`IBaseRouteProcessor.stop`
|
|
128
|
+
|
|
129
|
+
***
|
|
130
|
+
|
|
131
|
+
### post() {#post}
|
|
132
|
+
|
|
133
|
+
> **post**(`request`, `response`, `route`, `contextIds`, `processorState`): `Promise`\<`void`\>
|
|
134
|
+
|
|
135
|
+
Queue a counter increment after the request completes.
|
|
136
|
+
|
|
137
|
+
#### Parameters
|
|
138
|
+
|
|
139
|
+
##### request
|
|
140
|
+
|
|
141
|
+
`IHttpServerRequest`
|
|
142
|
+
|
|
143
|
+
The HTTP request.
|
|
144
|
+
|
|
145
|
+
##### response
|
|
146
|
+
|
|
147
|
+
`IHttpResponse`
|
|
148
|
+
|
|
149
|
+
The HTTP response.
|
|
150
|
+
|
|
151
|
+
##### route
|
|
152
|
+
|
|
153
|
+
`IBaseRoute` \| `undefined`
|
|
154
|
+
|
|
155
|
+
The matched route definition, if any.
|
|
156
|
+
|
|
157
|
+
##### contextIds
|
|
158
|
+
|
|
159
|
+
`IContextIds`
|
|
160
|
+
|
|
161
|
+
The context IDs for the request.
|
|
162
|
+
|
|
163
|
+
##### processorState
|
|
164
|
+
|
|
165
|
+
Shared state for the current request processor chain.
|
|
166
|
+
|
|
167
|
+
#### Returns
|
|
168
|
+
|
|
169
|
+
`Promise`\<`void`\>
|
|
170
|
+
|
|
171
|
+
#### Implementation of
|
|
172
|
+
|
|
173
|
+
`IBaseRouteProcessor.post`
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# @3sixty/telemetry-processors
|
|
2
|
+
|
|
3
|
+
## Classes
|
|
4
|
+
|
|
5
|
+
- [MetricsRouteProcessor](classes/MetricsRouteProcessor.md)
|
|
6
|
+
|
|
7
|
+
## Interfaces
|
|
8
|
+
|
|
9
|
+
- [IMetricsRouteProcessorConfig](interfaces/IMetricsRouteProcessorConfig.md)
|
|
10
|
+
- [IMetricsRouteProcessorConstructorOptions](interfaces/IMetricsRouteProcessorConstructorOptions.md)
|
|
11
|
+
- [IPendingMetricRecording](interfaces/IPendingMetricRecording.md)
|
|
12
|
+
|
|
13
|
+
## Type Aliases
|
|
14
|
+
|
|
15
|
+
- [TelemetryMetricIds](type-aliases/TelemetryMetricIds.md)
|
|
16
|
+
|
|
17
|
+
## Variables
|
|
18
|
+
|
|
19
|
+
- [RestRequestsMetrics](variables/RestRequestsMetrics.md)
|
|
20
|
+
- [TelemetryMetricIds](variables/TelemetryMetricIds.md)
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Interface: IMetricsRouteProcessorConfig
|
|
2
|
+
|
|
3
|
+
Configuration for the MetricsRouteProcessor.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### excludePaths? {#excludepaths}
|
|
8
|
+
|
|
9
|
+
> `optional` **excludePaths?**: `string`[]
|
|
10
|
+
|
|
11
|
+
URL path prefixes that should not be recorded as metrics, with the root path "/" matched in
|
|
12
|
+
full so the routes below it are still recorded.
|
|
13
|
+
Useful for suppressing noise from health-check or metrics-scrape endpoints. Supplying this
|
|
14
|
+
replaces the defaults rather than adding to them, so include the probe paths to keep them
|
|
15
|
+
excluded, or an empty array to record every route.
|
|
16
|
+
|
|
17
|
+
#### Default
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
["/", "/favicon.ico", "/spec", "/livez", "/readyz", "/info", "/health"].
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
***
|
|
24
|
+
|
|
25
|
+
### maxHistory? {#maxhistory}
|
|
26
|
+
|
|
27
|
+
> `optional` **maxHistory?**: `number`
|
|
28
|
+
|
|
29
|
+
Maximum number of request values to retain. A value is recorded for every request that
|
|
30
|
+
is not excluded, so without a cap the history grows for as long as the node serves
|
|
31
|
+
traffic; values <= 0 retain everything.
|
|
32
|
+
|
|
33
|
+
#### Default
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
10000.
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
***
|
|
40
|
+
|
|
41
|
+
### maxPendingRecordings? {#maxpendingrecordings}
|
|
42
|
+
|
|
43
|
+
> `optional` **maxPendingRecordings?**: `number`
|
|
44
|
+
|
|
45
|
+
Maximum number of recordings queued off the response path before new ones are dropped.
|
|
46
|
+
Recording never blocks the response, so without a cap a telemetry component slower than the
|
|
47
|
+
request rate would queue values without bound; values <= 0 queue everything.
|
|
48
|
+
|
|
49
|
+
#### Default
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
1000.
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
### drainIntervalMs? {#drainintervalms}
|
|
58
|
+
|
|
59
|
+
> `optional` **drainIntervalMs?**: `number`
|
|
60
|
+
|
|
61
|
+
Interval in milliseconds between drains of the queued recordings; values <= 0 use the
|
|
62
|
+
default.
|
|
63
|
+
|
|
64
|
+
#### Default
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
1000.
|
|
68
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Interface: IMetricsRouteProcessorConstructorOptions
|
|
2
|
+
|
|
3
|
+
Constructor options for the MetricsRouteProcessor.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### telemetryComponentType? {#telemetrycomponenttype}
|
|
8
|
+
|
|
9
|
+
> `optional` **telemetryComponentType?**: `string`
|
|
10
|
+
|
|
11
|
+
The component type to use for the telemetry component.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### loggingComponentType? {#loggingcomponenttype}
|
|
16
|
+
|
|
17
|
+
> `optional` **loggingComponentType?**: `string`
|
|
18
|
+
|
|
19
|
+
The component type to use for logging metric recording failures.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### config? {#config}
|
|
24
|
+
|
|
25
|
+
> `optional` **config?**: [`IMetricsRouteProcessorConfig`](IMetricsRouteProcessorConfig.md)
|
|
26
|
+
|
|
27
|
+
Optional processor configuration.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Interface: IPendingMetricRecording
|
|
2
|
+
|
|
3
|
+
A request metric queued by the metrics route processor, waiting to be handed to the
|
|
4
|
+
telemetry component.
|
|
5
|
+
|
|
6
|
+
## Properties
|
|
7
|
+
|
|
8
|
+
### contextIds {#contextids}
|
|
9
|
+
|
|
10
|
+
> **contextIds**: `IContextIds`
|
|
11
|
+
|
|
12
|
+
The context IDs of the request, used to record the metric in that request's context.
|
|
13
|
+
|
|
14
|
+
***
|
|
15
|
+
|
|
16
|
+
### method {#method}
|
|
17
|
+
|
|
18
|
+
> **method**: `string`
|
|
19
|
+
|
|
20
|
+
The HTTP method of the request.
|
|
21
|
+
|
|
22
|
+
***
|
|
23
|
+
|
|
24
|
+
### route {#route}
|
|
25
|
+
|
|
26
|
+
> **route**: `string`
|
|
27
|
+
|
|
28
|
+
The route template path of the request.
|
|
29
|
+
|
|
30
|
+
***
|
|
31
|
+
|
|
32
|
+
### statusCode {#statuscode}
|
|
33
|
+
|
|
34
|
+
> **statusCode**: `number`
|
|
35
|
+
|
|
36
|
+
The HTTP status code of the response.
|
|
37
|
+
|
|
38
|
+
***
|
|
39
|
+
|
|
40
|
+
### statusClass {#statusclass}
|
|
41
|
+
|
|
42
|
+
> **statusClass**: `string`
|
|
43
|
+
|
|
44
|
+
The status class of the response.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Variable: TelemetryMetricIds
|
|
2
|
+
|
|
3
|
+
> `const` **TelemetryMetricIds**: `object`
|
|
4
|
+
|
|
5
|
+
Metric IDs emitted by telemetry-processors.
|
|
6
|
+
|
|
7
|
+
## Type Declaration
|
|
8
|
+
|
|
9
|
+
### RestRequests {#restrequests}
|
|
10
|
+
|
|
11
|
+
> `readonly` **RestRequests**: `"rest_requests"` = `"rest_requests"`
|
|
12
|
+
|
|
13
|
+
Total number of REST requests received.
|
package/locales/en.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"warn": {
|
|
3
|
+
"metricsRouteProcessor": {
|
|
4
|
+
"metricRecordsFailed": "Failed to record \"{count}\" request metrics",
|
|
5
|
+
"metricDrainFailed": "Failed to hand the queued request metrics to the telemetry component",
|
|
6
|
+
"metricRecordsDropped": "Dropped \"{count}\" request metrics because the recording queue was full"
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@3sixty/telemetry-processors",
|
|
3
|
+
"version": "0.20.0-next.0",
|
|
4
|
+
"description": "Route processors for recording telemetry metrics.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/3sixtyglobal/telemetry.git",
|
|
8
|
+
"directory": "packages/telemetry-processors"
|
|
9
|
+
},
|
|
10
|
+
"author": "martyn.janes@iota.org",
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=24.0.0"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@3sixty/api-models": "next",
|
|
18
|
+
"@3sixty/context": "next",
|
|
19
|
+
"@3sixty/core": "next",
|
|
20
|
+
"@3sixty/logging-models": "next",
|
|
21
|
+
"@3sixty/nameof": "next",
|
|
22
|
+
"@3sixty/telemetry-models": "0.20.0-next.0"
|
|
23
|
+
},
|
|
24
|
+
"main": "./dist/es/index.js",
|
|
25
|
+
"types": "./dist/types/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/types/index.d.ts",
|
|
29
|
+
"import": "./dist/es/index.js",
|
|
30
|
+
"default": "./dist/es/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./locales/*.json": "./locales/*.json"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist/es",
|
|
36
|
+
"dist/types",
|
|
37
|
+
"locales",
|
|
38
|
+
"docs"
|
|
39
|
+
]
|
|
40
|
+
}
|