@3sixty/telemetry-connector-opentelemetry 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/README.md +34 -2
- package/dist/es/index.js +10 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/IOpenTelemetryOtlpHttpReaderConfig.js +2 -0
- package/dist/es/models/IOpenTelemetryOtlpHttpReaderConfig.js.map +1 -0
- package/dist/es/models/IOpenTelemetryPrometheusReaderConfig.js +2 -0
- package/dist/es/models/IOpenTelemetryPrometheusReaderConfig.js.map +1 -0
- package/dist/es/models/IOpenTelemetryReaderConfig.js +2 -0
- package/dist/es/models/IOpenTelemetryReaderConfig.js.map +1 -0
- package/dist/es/models/IOpenTelemetryTelemetryConnectorConfig.js +2 -0
- package/dist/es/models/IOpenTelemetryTelemetryConnectorConfig.js.map +1 -0
- package/dist/es/models/IOpenTelemetryTelemetryConnectorConstructorOptions.js +2 -0
- package/dist/es/models/IOpenTelemetryTelemetryConnectorConstructorOptions.js.map +1 -0
- package/dist/es/models/openTelemetryReaderTypes.js +17 -0
- package/dist/es/models/openTelemetryReaderTypes.js.map +1 -0
- package/dist/es/openTelemetryTelemetryConnector.js +378 -0
- package/dist/es/openTelemetryTelemetryConnector.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/models/IOpenTelemetryOtlpHttpReaderConfig.d.ts +27 -0
- package/dist/types/models/IOpenTelemetryPrometheusReaderConfig.d.ts +31 -0
- package/dist/types/models/IOpenTelemetryReaderConfig.d.ts +7 -0
- package/dist/types/models/IOpenTelemetryTelemetryConnectorConfig.d.ts +24 -0
- package/dist/types/models/IOpenTelemetryTelemetryConnectorConstructorOptions.d.ts +10 -0
- package/dist/types/models/openTelemetryReaderTypes.d.ts +17 -0
- package/dist/types/openTelemetryTelemetryConnector.d.ts +80 -0
- package/docs/changelog.md +0 -0
- package/docs/examples.md +172 -0
- package/docs/reference/classes/OpenTelemetryTelemetryConnector.md +265 -0
- package/docs/reference/index.md +21 -0
- package/docs/reference/interfaces/IOpenTelemetryOtlpHttpReaderConfig.md +52 -0
- package/docs/reference/interfaces/IOpenTelemetryPrometheusReaderConfig.md +63 -0
- package/docs/reference/interfaces/IOpenTelemetryTelemetryConnectorConfig.md +45 -0
- package/docs/reference/interfaces/IOpenTelemetryTelemetryConnectorConstructorOptions.md +11 -0
- package/docs/reference/type-aliases/IOpenTelemetryReaderConfig.md +6 -0
- package/docs/reference/type-aliases/OpenTelemetryReaderTypes.md +5 -0
- package/docs/reference/variables/OpenTelemetryReaderTypes.md +19 -0
- package/locales/en.json +15 -0
- package/package.json +65 -5
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { IOpenTelemetryReaderConfig } from "./IOpenTelemetryReaderConfig.js";
|
|
2
|
+
/**
|
|
3
|
+
* The options for the OpenTelemetry telemetry connector constructor.
|
|
4
|
+
*/
|
|
5
|
+
export interface IOpenTelemetryTelemetryConnectorConfig {
|
|
6
|
+
/**
|
|
7
|
+
* The name of the OpenTelemetry meter used to create instruments.
|
|
8
|
+
* @default twin-telemetry
|
|
9
|
+
*/
|
|
10
|
+
meterName?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The version reported by the OpenTelemetry meter.
|
|
13
|
+
* @default 1.0.0
|
|
14
|
+
*/
|
|
15
|
+
meterVersion?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Named metric-reader configurations keyed by an arbitrary id.
|
|
18
|
+
* Each entry's `type` field determines which exporter the connector instantiates
|
|
19
|
+
* in start(). Omit or pass an empty object for a no-op provider (useful for tests).
|
|
20
|
+
*/
|
|
21
|
+
readers?: {
|
|
22
|
+
[id: string]: IOpenTelemetryReaderConfig;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IOpenTelemetryTelemetryConnectorConfig } from "./IOpenTelemetryTelemetryConnectorConfig.js";
|
|
2
|
+
/**
|
|
3
|
+
* The options for the OpenTelemetry telemetry connector constructor.
|
|
4
|
+
*/
|
|
5
|
+
export interface IOpenTelemetryTelemetryConnectorConstructorOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The config for the telemetry connector.
|
|
8
|
+
*/
|
|
9
|
+
config?: IOpenTelemetryTelemetryConnectorConfig;
|
|
10
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The types of readers.
|
|
3
|
+
*/
|
|
4
|
+
export declare const OpenTelemetryReaderTypes: {
|
|
5
|
+
/**
|
|
6
|
+
* Prometheus.
|
|
7
|
+
*/
|
|
8
|
+
readonly Prometheus: "prometheus";
|
|
9
|
+
/**
|
|
10
|
+
* OTLP HTTP push exporter.
|
|
11
|
+
*/
|
|
12
|
+
readonly OtlpHttp: "otlp-http";
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The types of readers.
|
|
16
|
+
*/
|
|
17
|
+
export type OpenTelemetryReaderTypes = (typeof OpenTelemetryReaderTypes)[keyof typeof OpenTelemetryReaderTypes];
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type ITelemetryConnector, type ITelemetryMetric, type ITelemetryMetricValueEntry, MetricCounterOperation } from "@3sixty/telemetry-models";
|
|
2
|
+
import type { IOpenTelemetryTelemetryConnectorConstructorOptions } from "./models/IOpenTelemetryTelemetryConnectorConstructorOptions.js";
|
|
3
|
+
/**
|
|
4
|
+
* Class for performing telemetry operations using OpenTelemetry instruments.
|
|
5
|
+
* Metric definitions are held in memory. Persistence and querying are not supported;
|
|
6
|
+
* use a multi-connector with an EntityStorageTelemetryConnector for those capabilities.
|
|
7
|
+
*/
|
|
8
|
+
export declare class OpenTelemetryTelemetryConnector implements ITelemetryConnector {
|
|
9
|
+
/**
|
|
10
|
+
* The namespace supported by the telemetry connector.
|
|
11
|
+
*/
|
|
12
|
+
static readonly NAMESPACE: string;
|
|
13
|
+
/**
|
|
14
|
+
* Runtime name for the class.
|
|
15
|
+
*/
|
|
16
|
+
static readonly CLASS_NAME: string;
|
|
17
|
+
/**
|
|
18
|
+
* Create a new instance of OpenTelemetryTelemetryConnector.
|
|
19
|
+
* @param options The options for the connector.
|
|
20
|
+
* @throws GuardError When a reader config specifies an unsupported type.
|
|
21
|
+
*/
|
|
22
|
+
constructor(options?: IOpenTelemetryTelemetryConnectorConstructorOptions);
|
|
23
|
+
/**
|
|
24
|
+
* Returns the class name of the component.
|
|
25
|
+
* @returns The class name of the component.
|
|
26
|
+
*/
|
|
27
|
+
className(): string;
|
|
28
|
+
/**
|
|
29
|
+
* Enable OTEL forwarding. Subsequent calls to addMetricValue will create
|
|
30
|
+
* per-tenant/node MeterProviders on demand.
|
|
31
|
+
* @param nodeLoggingComponentType The node logging component type.
|
|
32
|
+
* @returns A promise that resolves when OTEL forwarding is enabled.
|
|
33
|
+
*/
|
|
34
|
+
start(nodeLoggingComponentType?: string): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Shut down all cached MeterProviders and disable OTEL forwarding.
|
|
37
|
+
* @param nodeLoggingComponentType The node logging component type.
|
|
38
|
+
* @returns A promise that resolves when all MeterProviders have shut down.
|
|
39
|
+
*/
|
|
40
|
+
stop(nodeLoggingComponentType?: string): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Register one or more metric definitions. If the connector is already started,
|
|
43
|
+
* the OTEL instrument is registered immediately for the current context.
|
|
44
|
+
* @param metric The metric details, or the details of several metrics.
|
|
45
|
+
* @returns A promise that resolves when the metrics have been registered.
|
|
46
|
+
*/
|
|
47
|
+
createMetric(metric: ITelemetryMetric | ITelemetryMetric[]): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Update the in-memory metadata for a registered metric.
|
|
50
|
+
* OpenTelemetry instrument descriptors are immutable once created; only the
|
|
51
|
+
* cached label, description and unit are updated.
|
|
52
|
+
* @param metric The metric details (type cannot be changed).
|
|
53
|
+
* @returns A promise that resolves when the metadata has been updated.
|
|
54
|
+
*/
|
|
55
|
+
updateMetric(metric: Omit<ITelemetryMetric, "type">): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Record a metric value and forward it to the appropriate OTEL instrument.
|
|
58
|
+
* The current tenant and node IDs are read from `ContextIdStore` and used to
|
|
59
|
+
* select (or create) the matching per-tenant/node `MeterProvider`.
|
|
60
|
+
* @param id The id of the metric.
|
|
61
|
+
* @param value The value for the operation.
|
|
62
|
+
* @param customData Optional custom data forwarded as OTEL attributes.
|
|
63
|
+
* @returns A generated 32-character hex id for the recorded value.
|
|
64
|
+
*/
|
|
65
|
+
addMetricValue(id: string, value: MetricCounterOperation | number, customData?: {
|
|
66
|
+
[key: string]: unknown;
|
|
67
|
+
}): Promise<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Add multiple metric values.
|
|
70
|
+
* @param values The metric values to add.
|
|
71
|
+
* @returns The created metric value ids, in the order the values were supplied.
|
|
72
|
+
*/
|
|
73
|
+
addMetricValues(values: ITelemetryMetricValueEntry[]): Promise<string[]>;
|
|
74
|
+
/**
|
|
75
|
+
* Remove a metric from the in-memory registry and from all cached provider instrument maps.
|
|
76
|
+
* @param id The id of the metric.
|
|
77
|
+
* @returns A promise that resolves when the metric has been removed.
|
|
78
|
+
*/
|
|
79
|
+
removeMetric(id: string): Promise<void>;
|
|
80
|
+
}
|
|
File without changes
|
package/docs/examples.md
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Telemetry Connector OpenTelemetry Examples
|
|
2
|
+
|
|
3
|
+
These examples show how to wire the connector to an OpenTelemetry SDK provider, record metrics, and connect to a Grafana/Prometheus stack.
|
|
4
|
+
|
|
5
|
+
## Prometheus Metric Naming
|
|
6
|
+
|
|
7
|
+
When using the Prometheus exporter, the OTEL SDK appends the `unit` field to the metric
|
|
8
|
+
name following the OpenMetrics convention. If you set `unit: "requests"` on a counter
|
|
9
|
+
named `api_requests`, Prometheus will expose it as `api_requests_requests_total` — which
|
|
10
|
+
may not be what you want. Omit the `unit` field (or leave it empty) to get clean names:
|
|
11
|
+
|
|
12
|
+
- `api_requests` (Counter, no unit) → `api_requests_total`
|
|
13
|
+
- `active_connections` (UpDownCounter, no unit) → `active_connections`
|
|
14
|
+
- `cpu_temperature` (Gauge, no unit) → `cpu_temperature`
|
|
15
|
+
|
|
16
|
+
> This only applies to the Prometheus exporter. OTLP exporters (e.g. Grafana Agent,
|
|
17
|
+
> Tempo, OTEL Collector) preserve the unit as metadata and are not affected.
|
|
18
|
+
|
|
19
|
+
## Basic Setup with Prometheus Exporter
|
|
20
|
+
|
|
21
|
+
Install the optional Prometheus exporter peer dependency alongside the connector:
|
|
22
|
+
|
|
23
|
+
```shell
|
|
24
|
+
npm install @opentelemetry/exporter-prometheus
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Pass a `readers` config map to the connector constructor. The connector instantiates the
|
|
28
|
+
exporter internally when `start()` is called — no manual `MeterProvider` wiring is needed.
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { EntityStorageConnectorFactory } from '@3sixty/entity-storage-models';
|
|
32
|
+
import { MemoryEntityStorageConnector } from '@3sixty/entity-storage-connector-memory';
|
|
33
|
+
import { TelemetryConnectorFactory } from '@3sixty/telemetry-models';
|
|
34
|
+
import {
|
|
35
|
+
OpenTelemetryTelemetryConnector,
|
|
36
|
+
initSchema,
|
|
37
|
+
type TelemetryMetric,
|
|
38
|
+
type TelemetryMetricValue
|
|
39
|
+
} from '@3sixty/telemetry-connector-opentelemetry';
|
|
40
|
+
|
|
41
|
+
// Register entity storage so the connector can persist metric definitions and history.
|
|
42
|
+
initSchema();
|
|
43
|
+
EntityStorageConnectorFactory.register(
|
|
44
|
+
'telemetry-metric',
|
|
45
|
+
() => new MemoryEntityStorageConnector<TelemetryMetric>({ entitySchema: 'TelemetryMetric' })
|
|
46
|
+
);
|
|
47
|
+
EntityStorageConnectorFactory.register(
|
|
48
|
+
'telemetry-metric-value',
|
|
49
|
+
() =>
|
|
50
|
+
new MemoryEntityStorageConnector<TelemetryMetricValue>({ entitySchema: 'TelemetryMetricValue' })
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const connector = new OpenTelemetryTelemetryConnector({
|
|
54
|
+
config: {
|
|
55
|
+
meterName: 'my-service',
|
|
56
|
+
meterVersion: '1.0.0',
|
|
57
|
+
readers: {
|
|
58
|
+
prometheus: { type: 'prometheus', port: 9464 }
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
await connector.start();
|
|
64
|
+
|
|
65
|
+
TelemetryConnectorFactory.register('telemetry', () => connector);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Creating and Recording Metrics
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { MetricType } from '@3sixty/telemetry-models';
|
|
72
|
+
import { OpenTelemetryTelemetryConnector } from '@3sixty/telemetry-connector-opentelemetry';
|
|
73
|
+
|
|
74
|
+
const connector = new OpenTelemetryTelemetryConnector();
|
|
75
|
+
|
|
76
|
+
console.log(connector.className()); // OpenTelemetryTelemetryConnector
|
|
77
|
+
|
|
78
|
+
await connector.createMetric({
|
|
79
|
+
id: 'api-requests',
|
|
80
|
+
label: 'API Requests',
|
|
81
|
+
description: 'Total number of API requests received',
|
|
82
|
+
unit: 'requests',
|
|
83
|
+
type: MetricType.Counter
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
await connector.createMetric({
|
|
87
|
+
id: 'active-connections',
|
|
88
|
+
label: 'Active Connections',
|
|
89
|
+
description: 'Number of currently active WebSocket connections',
|
|
90
|
+
unit: 'connections',
|
|
91
|
+
type: MetricType.IncDecCounter
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
await connector.createMetric({
|
|
95
|
+
id: 'cpu-temperature',
|
|
96
|
+
label: 'CPU Temperature',
|
|
97
|
+
description: 'Current CPU temperature reading',
|
|
98
|
+
unit: 'celsius',
|
|
99
|
+
type: MetricType.Gauge
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// Counter: increment only
|
|
103
|
+
await connector.addMetricValue('api-requests', 'inc');
|
|
104
|
+
await connector.addMetricValue('api-requests', 10, { route: '/api/health', statusCode: 200 });
|
|
105
|
+
|
|
106
|
+
// IncDecCounter: increment and decrement
|
|
107
|
+
await connector.addMetricValue('active-connections', 'inc');
|
|
108
|
+
await connector.addMetricValue('active-connections', 'dec');
|
|
109
|
+
|
|
110
|
+
// Gauge: absolute value
|
|
111
|
+
await connector.addMetricValue('cpu-temperature', 72.4);
|
|
112
|
+
await connector.addMetricValue('cpu-temperature', 68.1, { node: 'edge-1' });
|
|
113
|
+
|
|
114
|
+
const latest = await connector.getMetric('cpu-temperature');
|
|
115
|
+
console.log(latest.value.value); // 68.1
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Querying the Local Registry
|
|
119
|
+
|
|
120
|
+
The connector keeps an in-memory mirror of all recorded values so you can read back metrics without a separate query backend.
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
import { MetricType } from '@3sixty/telemetry-models';
|
|
124
|
+
import { OpenTelemetryTelemetryConnector } from '@3sixty/telemetry-connector-opentelemetry';
|
|
125
|
+
|
|
126
|
+
const connector = new OpenTelemetryTelemetryConnector();
|
|
127
|
+
|
|
128
|
+
// List all metrics of a given type
|
|
129
|
+
const counters = await connector.query(MetricType.Counter, undefined, 25);
|
|
130
|
+
console.log(counters.entities.length);
|
|
131
|
+
|
|
132
|
+
// Paginate through value history
|
|
133
|
+
const page1 = await connector.queryValues(
|
|
134
|
+
'api-requests',
|
|
135
|
+
Date.now() - 3_600_000,
|
|
136
|
+
Date.now(),
|
|
137
|
+
undefined,
|
|
138
|
+
20
|
|
139
|
+
);
|
|
140
|
+
console.log(page1.entities.length);
|
|
141
|
+
|
|
142
|
+
if (page1.cursor) {
|
|
143
|
+
const page2 = await connector.queryValues('api-requests', undefined, undefined, page1.cursor, 20);
|
|
144
|
+
console.log(page2.entities.length);
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Updating and Removing Metrics
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import { OpenTelemetryTelemetryConnector } from '@3sixty/telemetry-connector-opentelemetry';
|
|
152
|
+
|
|
153
|
+
const connector = new OpenTelemetryTelemetryConnector();
|
|
154
|
+
|
|
155
|
+
await connector.updateMetric({
|
|
156
|
+
id: 'api-requests',
|
|
157
|
+
label: 'API Requests Total',
|
|
158
|
+
description: 'Cumulative count of all API requests',
|
|
159
|
+
unit: 'requests'
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
await connector.removeMetric('api-requests');
|
|
163
|
+
|
|
164
|
+
const result = await connector.query(undefined, undefined, 10);
|
|
165
|
+
console.log(result.entities.length); // 0
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Connecting to Grafana via OTLP
|
|
169
|
+
|
|
170
|
+
> OTLP exporter support is planned for a future release. The `readers` config map currently
|
|
171
|
+
> supports `type: "prometheus"` only. Additional reader types (OTLP HTTP, OTLP gRPC, etc.)
|
|
172
|
+
> will be added as further discriminated-union members of `IOpenTelemetryReaderConfig`.
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
# Class: OpenTelemetryTelemetryConnector
|
|
2
|
+
|
|
3
|
+
Class for performing telemetry operations using OpenTelemetry instruments.
|
|
4
|
+
Metric definitions are held in memory. Persistence and querying are not supported;
|
|
5
|
+
use a multi-connector with an EntityStorageTelemetryConnector for those capabilities.
|
|
6
|
+
|
|
7
|
+
## Implements
|
|
8
|
+
|
|
9
|
+
- `ITelemetryConnector`
|
|
10
|
+
|
|
11
|
+
## Constructors
|
|
12
|
+
|
|
13
|
+
### Constructor
|
|
14
|
+
|
|
15
|
+
> **new OpenTelemetryTelemetryConnector**(`options?`): `OpenTelemetryTelemetryConnector`
|
|
16
|
+
|
|
17
|
+
Create a new instance of OpenTelemetryTelemetryConnector.
|
|
18
|
+
|
|
19
|
+
#### Parameters
|
|
20
|
+
|
|
21
|
+
##### options?
|
|
22
|
+
|
|
23
|
+
[`IOpenTelemetryTelemetryConnectorConstructorOptions`](../interfaces/IOpenTelemetryTelemetryConnectorConstructorOptions.md)
|
|
24
|
+
|
|
25
|
+
The options for the connector.
|
|
26
|
+
|
|
27
|
+
#### Returns
|
|
28
|
+
|
|
29
|
+
`OpenTelemetryTelemetryConnector`
|
|
30
|
+
|
|
31
|
+
#### Throws
|
|
32
|
+
|
|
33
|
+
GuardError When a reader config specifies an unsupported type.
|
|
34
|
+
|
|
35
|
+
## Properties
|
|
36
|
+
|
|
37
|
+
### NAMESPACE {#namespace}
|
|
38
|
+
|
|
39
|
+
> `readonly` `static` **NAMESPACE**: `string` = `"open-telemetry"`
|
|
40
|
+
|
|
41
|
+
The namespace supported by the telemetry connector.
|
|
42
|
+
|
|
43
|
+
***
|
|
44
|
+
|
|
45
|
+
### CLASS\_NAME {#class_name}
|
|
46
|
+
|
|
47
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
48
|
+
|
|
49
|
+
Runtime name for the class.
|
|
50
|
+
|
|
51
|
+
## Methods
|
|
52
|
+
|
|
53
|
+
### className() {#classname}
|
|
54
|
+
|
|
55
|
+
> **className**(): `string`
|
|
56
|
+
|
|
57
|
+
Returns the class name of the component.
|
|
58
|
+
|
|
59
|
+
#### Returns
|
|
60
|
+
|
|
61
|
+
`string`
|
|
62
|
+
|
|
63
|
+
The class name of the component.
|
|
64
|
+
|
|
65
|
+
#### Implementation of
|
|
66
|
+
|
|
67
|
+
`ITelemetryConnector.className`
|
|
68
|
+
|
|
69
|
+
***
|
|
70
|
+
|
|
71
|
+
### start() {#start}
|
|
72
|
+
|
|
73
|
+
> **start**(`nodeLoggingComponentType?`): `Promise`\<`void`\>
|
|
74
|
+
|
|
75
|
+
Enable OTEL forwarding. Subsequent calls to addMetricValue will create
|
|
76
|
+
per-tenant/node MeterProviders on demand.
|
|
77
|
+
|
|
78
|
+
#### Parameters
|
|
79
|
+
|
|
80
|
+
##### nodeLoggingComponentType?
|
|
81
|
+
|
|
82
|
+
`string`
|
|
83
|
+
|
|
84
|
+
The node logging component type.
|
|
85
|
+
|
|
86
|
+
#### Returns
|
|
87
|
+
|
|
88
|
+
`Promise`\<`void`\>
|
|
89
|
+
|
|
90
|
+
A promise that resolves when OTEL forwarding is enabled.
|
|
91
|
+
|
|
92
|
+
#### Implementation of
|
|
93
|
+
|
|
94
|
+
`ITelemetryConnector.start`
|
|
95
|
+
|
|
96
|
+
***
|
|
97
|
+
|
|
98
|
+
### stop() {#stop}
|
|
99
|
+
|
|
100
|
+
> **stop**(`nodeLoggingComponentType?`): `Promise`\<`void`\>
|
|
101
|
+
|
|
102
|
+
Shut down all cached MeterProviders and disable OTEL forwarding.
|
|
103
|
+
|
|
104
|
+
#### Parameters
|
|
105
|
+
|
|
106
|
+
##### nodeLoggingComponentType?
|
|
107
|
+
|
|
108
|
+
`string`
|
|
109
|
+
|
|
110
|
+
The node logging component type.
|
|
111
|
+
|
|
112
|
+
#### Returns
|
|
113
|
+
|
|
114
|
+
`Promise`\<`void`\>
|
|
115
|
+
|
|
116
|
+
A promise that resolves when all MeterProviders have shut down.
|
|
117
|
+
|
|
118
|
+
#### Implementation of
|
|
119
|
+
|
|
120
|
+
`ITelemetryConnector.stop`
|
|
121
|
+
|
|
122
|
+
***
|
|
123
|
+
|
|
124
|
+
### createMetric() {#createmetric}
|
|
125
|
+
|
|
126
|
+
> **createMetric**(`metric`): `Promise`\<`void`\>
|
|
127
|
+
|
|
128
|
+
Register one or more metric definitions. If the connector is already started,
|
|
129
|
+
the OTEL instrument is registered immediately for the current context.
|
|
130
|
+
|
|
131
|
+
#### Parameters
|
|
132
|
+
|
|
133
|
+
##### metric
|
|
134
|
+
|
|
135
|
+
`ITelemetryMetric` \| `ITelemetryMetric`[]
|
|
136
|
+
|
|
137
|
+
The metric details, or the details of several metrics.
|
|
138
|
+
|
|
139
|
+
#### Returns
|
|
140
|
+
|
|
141
|
+
`Promise`\<`void`\>
|
|
142
|
+
|
|
143
|
+
A promise that resolves when the metrics have been registered.
|
|
144
|
+
|
|
145
|
+
#### Implementation of
|
|
146
|
+
|
|
147
|
+
`ITelemetryConnector.createMetric`
|
|
148
|
+
|
|
149
|
+
***
|
|
150
|
+
|
|
151
|
+
### updateMetric() {#updatemetric}
|
|
152
|
+
|
|
153
|
+
> **updateMetric**(`metric`): `Promise`\<`void`\>
|
|
154
|
+
|
|
155
|
+
Update the in-memory metadata for a registered metric.
|
|
156
|
+
OpenTelemetry instrument descriptors are immutable once created; only the
|
|
157
|
+
cached label, description and unit are updated.
|
|
158
|
+
|
|
159
|
+
#### Parameters
|
|
160
|
+
|
|
161
|
+
##### metric
|
|
162
|
+
|
|
163
|
+
`Omit`\<`ITelemetryMetric`, `"type"`\>
|
|
164
|
+
|
|
165
|
+
The metric details (type cannot be changed).
|
|
166
|
+
|
|
167
|
+
#### Returns
|
|
168
|
+
|
|
169
|
+
`Promise`\<`void`\>
|
|
170
|
+
|
|
171
|
+
A promise that resolves when the metadata has been updated.
|
|
172
|
+
|
|
173
|
+
#### Implementation of
|
|
174
|
+
|
|
175
|
+
`ITelemetryConnector.updateMetric`
|
|
176
|
+
|
|
177
|
+
***
|
|
178
|
+
|
|
179
|
+
### addMetricValue() {#addmetricvalue}
|
|
180
|
+
|
|
181
|
+
> **addMetricValue**(`id`, `value`, `customData?`): `Promise`\<`string`\>
|
|
182
|
+
|
|
183
|
+
Record a metric value and forward it to the appropriate OTEL instrument.
|
|
184
|
+
The current tenant and node IDs are read from `ContextIdStore` and used to
|
|
185
|
+
select (or create) the matching per-tenant/node `MeterProvider`.
|
|
186
|
+
|
|
187
|
+
#### Parameters
|
|
188
|
+
|
|
189
|
+
##### id
|
|
190
|
+
|
|
191
|
+
`string`
|
|
192
|
+
|
|
193
|
+
The id of the metric.
|
|
194
|
+
|
|
195
|
+
##### value
|
|
196
|
+
|
|
197
|
+
`number` \| `MetricCounterOperation`
|
|
198
|
+
|
|
199
|
+
The value for the operation.
|
|
200
|
+
|
|
201
|
+
##### customData?
|
|
202
|
+
|
|
203
|
+
Optional custom data forwarded as OTEL attributes.
|
|
204
|
+
|
|
205
|
+
#### Returns
|
|
206
|
+
|
|
207
|
+
`Promise`\<`string`\>
|
|
208
|
+
|
|
209
|
+
A generated 32-character hex id for the recorded value.
|
|
210
|
+
|
|
211
|
+
#### Implementation of
|
|
212
|
+
|
|
213
|
+
`ITelemetryConnector.addMetricValue`
|
|
214
|
+
|
|
215
|
+
***
|
|
216
|
+
|
|
217
|
+
### addMetricValues() {#addmetricvalues}
|
|
218
|
+
|
|
219
|
+
> **addMetricValues**(`values`): `Promise`\<`string`[]\>
|
|
220
|
+
|
|
221
|
+
Add multiple metric values.
|
|
222
|
+
|
|
223
|
+
#### Parameters
|
|
224
|
+
|
|
225
|
+
##### values
|
|
226
|
+
|
|
227
|
+
`ITelemetryMetricValueEntry`[]
|
|
228
|
+
|
|
229
|
+
The metric values to add.
|
|
230
|
+
|
|
231
|
+
#### Returns
|
|
232
|
+
|
|
233
|
+
`Promise`\<`string`[]\>
|
|
234
|
+
|
|
235
|
+
The created metric value ids, in the order the values were supplied.
|
|
236
|
+
|
|
237
|
+
#### Implementation of
|
|
238
|
+
|
|
239
|
+
`ITelemetryConnector.addMetricValues`
|
|
240
|
+
|
|
241
|
+
***
|
|
242
|
+
|
|
243
|
+
### removeMetric() {#removemetric}
|
|
244
|
+
|
|
245
|
+
> **removeMetric**(`id`): `Promise`\<`void`\>
|
|
246
|
+
|
|
247
|
+
Remove a metric from the in-memory registry and from all cached provider instrument maps.
|
|
248
|
+
|
|
249
|
+
#### Parameters
|
|
250
|
+
|
|
251
|
+
##### id
|
|
252
|
+
|
|
253
|
+
`string`
|
|
254
|
+
|
|
255
|
+
The id of the metric.
|
|
256
|
+
|
|
257
|
+
#### Returns
|
|
258
|
+
|
|
259
|
+
`Promise`\<`void`\>
|
|
260
|
+
|
|
261
|
+
A promise that resolves when the metric has been removed.
|
|
262
|
+
|
|
263
|
+
#### Implementation of
|
|
264
|
+
|
|
265
|
+
`ITelemetryConnector.removeMetric`
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @3sixty/telemetry-connector-opentelemetry
|
|
2
|
+
|
|
3
|
+
## Classes
|
|
4
|
+
|
|
5
|
+
- [OpenTelemetryTelemetryConnector](classes/OpenTelemetryTelemetryConnector.md)
|
|
6
|
+
|
|
7
|
+
## Interfaces
|
|
8
|
+
|
|
9
|
+
- [IOpenTelemetryOtlpHttpReaderConfig](interfaces/IOpenTelemetryOtlpHttpReaderConfig.md)
|
|
10
|
+
- [IOpenTelemetryPrometheusReaderConfig](interfaces/IOpenTelemetryPrometheusReaderConfig.md)
|
|
11
|
+
- [IOpenTelemetryTelemetryConnectorConfig](interfaces/IOpenTelemetryTelemetryConnectorConfig.md)
|
|
12
|
+
- [IOpenTelemetryTelemetryConnectorConstructorOptions](interfaces/IOpenTelemetryTelemetryConnectorConstructorOptions.md)
|
|
13
|
+
|
|
14
|
+
## Type Aliases
|
|
15
|
+
|
|
16
|
+
- [IOpenTelemetryReaderConfig](type-aliases/IOpenTelemetryReaderConfig.md)
|
|
17
|
+
- [OpenTelemetryReaderTypes](type-aliases/OpenTelemetryReaderTypes.md)
|
|
18
|
+
|
|
19
|
+
## Variables
|
|
20
|
+
|
|
21
|
+
- [OpenTelemetryReaderTypes](variables/OpenTelemetryReaderTypes.md)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Interface: IOpenTelemetryOtlpHttpReaderConfig
|
|
2
|
+
|
|
3
|
+
Configuration for an OTLP HTTP push exporter reader.
|
|
4
|
+
The connector instantiates an OTLPMetricExporter wrapped in a PeriodicExportingMetricReader.
|
|
5
|
+
|
|
6
|
+
## Properties
|
|
7
|
+
|
|
8
|
+
### type {#type}
|
|
9
|
+
|
|
10
|
+
> **type**: `"otlp-http"`
|
|
11
|
+
|
|
12
|
+
Type.
|
|
13
|
+
|
|
14
|
+
***
|
|
15
|
+
|
|
16
|
+
### url? {#url}
|
|
17
|
+
|
|
18
|
+
> `optional` **url?**: `string`
|
|
19
|
+
|
|
20
|
+
The OTLP HTTP endpoint URL to push metrics to.
|
|
21
|
+
|
|
22
|
+
#### Default
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
http://localhost:4318/v1/metrics
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
***
|
|
29
|
+
|
|
30
|
+
### exportIntervalMs? {#exportintervalms}
|
|
31
|
+
|
|
32
|
+
> `optional` **exportIntervalMs?**: `number`
|
|
33
|
+
|
|
34
|
+
How often metrics are exported, in milliseconds.
|
|
35
|
+
|
|
36
|
+
#### Default
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
60000
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
***
|
|
43
|
+
|
|
44
|
+
### headers? {#headers}
|
|
45
|
+
|
|
46
|
+
> `optional` **headers?**: `object`
|
|
47
|
+
|
|
48
|
+
Optional HTTP headers included in every export request.
|
|
49
|
+
|
|
50
|
+
#### Index Signature
|
|
51
|
+
|
|
52
|
+
\[`key`: `string`\]: `string`
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Interface: IOpenTelemetryPrometheusReaderConfig
|
|
2
|
+
|
|
3
|
+
Configuration for a Prometheus scrape-endpoint reader.
|
|
4
|
+
The connector instantiates a PrometheusExporter from these options in start().
|
|
5
|
+
|
|
6
|
+
## Properties
|
|
7
|
+
|
|
8
|
+
### type {#type}
|
|
9
|
+
|
|
10
|
+
> **type**: `"prometheus"`
|
|
11
|
+
|
|
12
|
+
Type.
|
|
13
|
+
|
|
14
|
+
***
|
|
15
|
+
|
|
16
|
+
### port? {#port}
|
|
17
|
+
|
|
18
|
+
> `optional` **port?**: `number`
|
|
19
|
+
|
|
20
|
+
TCP port the Prometheus HTTP server listens on.
|
|
21
|
+
|
|
22
|
+
#### Default
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
9464
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
***
|
|
29
|
+
|
|
30
|
+
### endpoint? {#endpoint}
|
|
31
|
+
|
|
32
|
+
> `optional` **endpoint?**: `string`
|
|
33
|
+
|
|
34
|
+
HTTP path that Prometheus scrapes.
|
|
35
|
+
|
|
36
|
+
#### Default
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
/metrics
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
***
|
|
43
|
+
|
|
44
|
+
### startServer? {#startserver}
|
|
45
|
+
|
|
46
|
+
> `optional` **startServer?**: `boolean`
|
|
47
|
+
|
|
48
|
+
Whether to start the built-in HTTP server automatically.
|
|
49
|
+
Set to false if you manage the server externally.
|
|
50
|
+
|
|
51
|
+
#### Default
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
true
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
***
|
|
58
|
+
|
|
59
|
+
### prefix? {#prefix}
|
|
60
|
+
|
|
61
|
+
> `optional` **prefix?**: `string`
|
|
62
|
+
|
|
63
|
+
Optional string prepended to every exported metric name.
|