@opentelemetry/exporter-metrics-otlp-http 0.27.0 → 0.29.1
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 +25 -30
- package/build/esm/OTLPMetricExporterBase.d.ts +17 -0
- package/build/esm/OTLPMetricExporterBase.js +103 -0
- package/build/esm/OTLPMetricExporterBase.js.map +1 -0
- package/build/esm/OTLPMetricExporterOptions.d.ts +10 -0
- package/build/esm/OTLPMetricExporterOptions.js +19 -0
- package/build/esm/OTLPMetricExporterOptions.js.map +1 -0
- package/build/esm/index.d.ts +2 -1
- package/build/esm/index.js +2 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/platform/browser/OTLPMetricExporter.d.ts +13 -7
- package/build/esm/platform/browser/OTLPMetricExporter.js +29 -21
- package/build/esm/platform/browser/OTLPMetricExporter.js.map +1 -1
- package/build/esm/platform/node/OTLPMetricExporter.d.ts +13 -7
- package/build/esm/platform/node/OTLPMetricExporter.js +27 -19
- package/build/esm/platform/node/OTLPMetricExporter.js.map +1 -1
- package/build/esm/version.d.ts +1 -1
- package/build/esm/version.js +1 -1
- package/build/esm/version.js.map +1 -1
- package/build/esnext/OTLPMetricExporterBase.d.ts +17 -0
- package/build/esnext/OTLPMetricExporterBase.js +55 -0
- package/build/esnext/OTLPMetricExporterBase.js.map +1 -0
- package/build/esnext/OTLPMetricExporterOptions.d.ts +10 -0
- package/build/esnext/OTLPMetricExporterOptions.js +19 -0
- package/build/esnext/OTLPMetricExporterOptions.js.map +1 -0
- package/build/esnext/index.d.ts +4 -0
- package/build/esnext/index.js +19 -0
- package/build/esnext/index.js.map +1 -0
- package/build/esnext/platform/browser/OTLPMetricExporter.d.ts +18 -0
- package/build/esnext/platform/browser/OTLPMetricExporter.js +49 -0
- package/build/esnext/platform/browser/OTLPMetricExporter.js.map +1 -0
- package/build/esnext/platform/browser/index.d.ts +2 -0
- package/build/esnext/platform/browser/index.js +17 -0
- package/build/esnext/platform/browser/index.js.map +1 -0
- package/build/esnext/platform/index.d.ts +2 -0
- package/build/esnext/platform/index.js +17 -0
- package/build/esnext/platform/index.js.map +1 -0
- package/build/esnext/platform/node/OTLPMetricExporter.d.ts +18 -0
- package/build/esnext/platform/node/OTLPMetricExporter.js +49 -0
- package/build/esnext/platform/node/OTLPMetricExporter.js.map +1 -0
- package/build/esnext/platform/node/index.d.ts +2 -0
- package/build/esnext/platform/node/index.js +17 -0
- package/build/esnext/platform/node/index.js.map +1 -0
- package/build/esnext/version.d.ts +2 -0
- package/build/esnext/version.js +18 -0
- package/build/esnext/version.js.map +1 -0
- package/build/src/OTLPMetricExporterBase.d.ts +17 -0
- package/build/src/OTLPMetricExporterBase.js +61 -0
- package/build/src/OTLPMetricExporterBase.js.map +1 -0
- package/build/src/OTLPMetricExporterOptions.d.ts +10 -0
- package/build/src/OTLPMetricExporterOptions.js +22 -0
- package/build/src/OTLPMetricExporterOptions.js.map +1 -0
- package/build/src/index.d.ts +2 -1
- package/build/src/index.js +2 -3
- package/build/src/index.js.map +1 -1
- package/build/src/platform/browser/OTLPMetricExporter.d.ts +13 -7
- package/build/src/platform/browser/OTLPMetricExporter.js +24 -19
- package/build/src/platform/browser/OTLPMetricExporter.js.map +1 -1
- package/build/src/platform/node/OTLPMetricExporter.d.ts +13 -7
- package/build/src/platform/node/OTLPMetricExporter.js +22 -17
- package/build/src/platform/node/OTLPMetricExporter.js.map +1 -1
- package/build/src/version.d.ts +1 -1
- package/build/src/version.js +1 -1
- package/build/src/version.js.map +1 -1
- package/package.json +34 -25
- package/build/esm/transformMetrics.d.ts +0 -47
- package/build/esm/transformMetrics.js +0 -188
- package/build/esm/transformMetrics.js.map +0 -1
- package/build/src/transformMetrics.d.ts +0 -47
- package/build/src/transformMetrics.js +0 -193
- package/build/src/transformMetrics.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
# OpenTelemetry Collector Metrics Exporter for web and node
|
|
2
2
|
|
|
3
3
|
[![NPM Published Version][npm-img]][npm-url]
|
|
4
|
-
[![dependencies][dependencies-image]][dependencies-url]
|
|
5
|
-
[![devDependencies][devDependencies-image]][devDependencies-url]
|
|
6
4
|
[![Apache License][license-image]][license-image]
|
|
7
5
|
|
|
8
|
-
This module provides exporter for web and node to be used with [opentelemetry-collector][opentelemetry-collector-url]
|
|
6
|
+
This module provides exporter for web and node to be used with [opentelemetry-collector][opentelemetry-collector-url].
|
|
7
|
+
Compatible with [opentelemetry-collector][opentelemetry-collector-url] versions `>=0.48 <=0.50`.
|
|
9
8
|
|
|
10
9
|
## Installation
|
|
11
10
|
|
|
@@ -24,45 +23,46 @@ To see sample code and documentation for the traces exporter, visit the [Collect
|
|
|
24
23
|
The OTLPMetricExporter in Web expects the endpoint to end in `/v1/metrics`.
|
|
25
24
|
|
|
26
25
|
```js
|
|
27
|
-
import { MeterProvider } from '@opentelemetry/sdk-metrics-base';
|
|
26
|
+
import { MeterProvider, PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics-base';
|
|
28
27
|
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';
|
|
29
28
|
const collectorOptions = {
|
|
30
|
-
url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:
|
|
29
|
+
url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:4318/v1/metrics
|
|
31
30
|
headers: {}, // an optional object containing custom headers to be sent with each request
|
|
32
31
|
concurrencyLimit: 1, // an optional limit on pending requests
|
|
33
32
|
};
|
|
34
33
|
const exporter = new OTLPMetricExporter(collectorOptions);
|
|
34
|
+
const meterProvider = new MeterProvider({});
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}).getMeter('example-meter');
|
|
36
|
+
meterProvider.addMetricReader(new PeriodicExportingMetricReader({
|
|
37
|
+
exporter: metricExporter,
|
|
38
|
+
exportIntervalMillis: 1000,
|
|
39
|
+
}));
|
|
41
40
|
|
|
42
41
|
// Now, start recording data
|
|
42
|
+
const meter = meterProvider.getMeter('example-meter');
|
|
43
43
|
const counter = meter.createCounter('metric_name');
|
|
44
44
|
counter.add(10, { 'key': 'value' });
|
|
45
|
-
|
|
46
45
|
```
|
|
47
46
|
|
|
48
47
|
## Metrics in Node
|
|
49
48
|
|
|
50
49
|
```js
|
|
51
|
-
const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
|
|
50
|
+
const { MeterProvider, PeriodicExportingMetricReader } = require('@opentelemetry/sdk-metrics-base');
|
|
52
51
|
const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-http');
|
|
53
52
|
const collectorOptions = {
|
|
54
|
-
url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:
|
|
53
|
+
url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:4318/v1/metrics
|
|
55
54
|
concurrencyLimit: 1, // an optional limit on pending requests
|
|
56
55
|
};
|
|
57
56
|
const exporter = new OTLPMetricExporter(collectorOptions);
|
|
57
|
+
const meterProvider = new MeterProvider({});
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}).getMeter('example-meter');
|
|
59
|
+
meterProvider.addMetricReader(new PeriodicExportingMetricReader({
|
|
60
|
+
exporter: metricExporter,
|
|
61
|
+
exportIntervalMillis: 1000,
|
|
62
|
+
}));
|
|
64
63
|
|
|
65
64
|
// Now, start recording data
|
|
65
|
+
const meter = meterProvider.getMeter('example-meter');
|
|
66
66
|
const counter = meter.createCounter('metric_name');
|
|
67
67
|
counter.add(10, { 'key': 'value' });
|
|
68
68
|
|
|
@@ -81,16 +81,16 @@ For exporting metrics with PROTOBUF please check [exporter-metrics-otlp-proto][n
|
|
|
81
81
|
Instead of providing options to `OTLPMetricExporter` and `OTLPTraceExporter` explicitly, environment variables may be provided instead.
|
|
82
82
|
|
|
83
83
|
```sh
|
|
84
|
-
OTEL_EXPORTER_OTLP_ENDPOINT=https://localhost:
|
|
84
|
+
OTEL_EXPORTER_OTLP_ENDPOINT=https://localhost:4318
|
|
85
85
|
# this will automatically append the version and signal path
|
|
86
|
-
# e.g. https://localhost:
|
|
86
|
+
# e.g. https://localhost:4318/v1/traces for `OTLPTraceExporter` and https://localhost:4318/v1/metrics for `OTLPMetricExporter`
|
|
87
87
|
```
|
|
88
88
|
|
|
89
89
|
If the trace and metric exporter endpoints have different providers, the env var for per-signal endpoints are available to use
|
|
90
90
|
|
|
91
91
|
```sh
|
|
92
|
-
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://trace-service:
|
|
93
|
-
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=https://metric-service:
|
|
92
|
+
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://trace-service:4318/v1/traces
|
|
93
|
+
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=https://metric-service:4318/v1/metrics
|
|
94
94
|
# version and signal needs to be explicit
|
|
95
95
|
```
|
|
96
96
|
|
|
@@ -100,9 +100,8 @@ For more details, see [OpenTelemetry Specification on Protocol Exporter][opentel
|
|
|
100
100
|
|
|
101
101
|
## Running opentelemetry-collector locally to see the metrics
|
|
102
102
|
|
|
103
|
-
1. Go to examples/otlp-exporter-node
|
|
104
|
-
2.
|
|
105
|
-
3. Open page at `http://localhost:9411/zipkin/` to observe the metrics
|
|
103
|
+
1. Go to `examples/otlp-exporter-node`
|
|
104
|
+
2. Follow the instructions there to observe the metrics.
|
|
106
105
|
|
|
107
106
|
## Useful links
|
|
108
107
|
|
|
@@ -117,10 +116,6 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
|
|
|
117
116
|
[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
|
|
118
117
|
[license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/LICENSE
|
|
119
118
|
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
|
|
120
|
-
[dependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=experimental%2Fpackages%2Fopentelemetry-exporter-metrics-otlp-http
|
|
121
|
-
[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=experimental%2Fpackages%2Fopentelemetry-exporter-metrics-otlp-http
|
|
122
|
-
[devDependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=experimental%2Fpackages%2Fopentelemetry-exporter-metrics-otlp-http&type=dev
|
|
123
|
-
[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=experimental%2Fpackages%2Fopentelemetry-exporter-metrics-otlp-http&type=dev
|
|
124
119
|
[npm-url]: https://www.npmjs.com/package/@opentelemetry/exporter-metrics-otlp-http
|
|
125
120
|
[npm-url-grpc]: https://www.npmjs.com/package/@opentelemetry/exporter-metrics-otlp-grpc
|
|
126
121
|
[npm-url-proto]: https://www.npmjs.com/package/@opentelemetry/exporter-metrics-otlp-proto
|
|
@@ -128,4 +123,4 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
|
|
|
128
123
|
[opentelemetry-collector-url]: https://github.com/open-telemetry/opentelemetry-collector
|
|
129
124
|
[opentelemetry-spec-protocol-exporter]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options
|
|
130
125
|
[semconv-resource-service-name]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#service
|
|
131
|
-
[trace-exporter-url]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/
|
|
126
|
+
[trace-exporter-url]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/exporter-trace-otlp-http
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ExportResult } from '@opentelemetry/core';
|
|
2
|
+
import { AggregationTemporality, AggregationTemporalitySelector, InstrumentType, PushMetricExporter, ResourceMetrics } from '@opentelemetry/sdk-metrics-base';
|
|
3
|
+
import { OTLPMetricExporterOptions } from './OTLPMetricExporterOptions';
|
|
4
|
+
import { OTLPExporterBase } from '@opentelemetry/otlp-exporter-base';
|
|
5
|
+
import { IExportMetricsServiceRequest } from '@opentelemetry/otlp-transformer';
|
|
6
|
+
export declare const CumulativeTemporalitySelector: AggregationTemporalitySelector;
|
|
7
|
+
export declare const DeltaTemporalitySelector: AggregationTemporalitySelector;
|
|
8
|
+
export declare class OTLPMetricExporterBase<T extends OTLPExporterBase<OTLPMetricExporterOptions, ResourceMetrics, IExportMetricsServiceRequest>> implements PushMetricExporter {
|
|
9
|
+
_otlpExporter: T;
|
|
10
|
+
protected _aggregationTemporalitySelector: AggregationTemporalitySelector;
|
|
11
|
+
constructor(exporter: T, config?: OTLPMetricExporterOptions);
|
|
12
|
+
export(metrics: ResourceMetrics, resultCallback: (result: ExportResult) => void): void;
|
|
13
|
+
shutdown(): Promise<void>;
|
|
14
|
+
forceFlush(): Promise<void>;
|
|
15
|
+
selectAggregationTemporality(instrumentType: InstrumentType): AggregationTemporality;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=OTLPMetricExporterBase.d.ts.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright The OpenTelemetry Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
27
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
+
function step(op) {
|
|
30
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
+
while (_) try {
|
|
32
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
+
switch (op[0]) {
|
|
35
|
+
case 0: case 1: t = op; break;
|
|
36
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
+
default:
|
|
40
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
+
if (t[2]) _.ops.pop();
|
|
45
|
+
_.trys.pop(); continue;
|
|
46
|
+
}
|
|
47
|
+
op = body.call(thisArg, _);
|
|
48
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
import { AggregationTemporality, InstrumentType } from '@opentelemetry/sdk-metrics-base';
|
|
53
|
+
import { defaultOptions } from './OTLPMetricExporterOptions';
|
|
54
|
+
export var CumulativeTemporalitySelector = function () { return AggregationTemporality.CUMULATIVE; };
|
|
55
|
+
export var DeltaTemporalitySelector = function (instrumentType) {
|
|
56
|
+
switch (instrumentType) {
|
|
57
|
+
case InstrumentType.COUNTER:
|
|
58
|
+
case InstrumentType.OBSERVABLE_COUNTER:
|
|
59
|
+
case InstrumentType.HISTOGRAM:
|
|
60
|
+
case InstrumentType.OBSERVABLE_GAUGE:
|
|
61
|
+
return AggregationTemporality.DELTA;
|
|
62
|
+
case InstrumentType.UP_DOWN_COUNTER:
|
|
63
|
+
case InstrumentType.OBSERVABLE_UP_DOWN_COUNTER:
|
|
64
|
+
return AggregationTemporality.CUMULATIVE;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
function chooseTemporalitySelector(temporalityPreference) {
|
|
68
|
+
if (temporalityPreference === AggregationTemporality.DELTA) {
|
|
69
|
+
return DeltaTemporalitySelector;
|
|
70
|
+
}
|
|
71
|
+
return CumulativeTemporalitySelector;
|
|
72
|
+
}
|
|
73
|
+
var OTLPMetricExporterBase = /** @class */ (function () {
|
|
74
|
+
function OTLPMetricExporterBase(exporter, config) {
|
|
75
|
+
if (config === void 0) { config = defaultOptions; }
|
|
76
|
+
this._otlpExporter = exporter;
|
|
77
|
+
this._aggregationTemporalitySelector = chooseTemporalitySelector(config.temporalityPreference);
|
|
78
|
+
}
|
|
79
|
+
OTLPMetricExporterBase.prototype.export = function (metrics, resultCallback) {
|
|
80
|
+
this._otlpExporter.export([metrics], resultCallback);
|
|
81
|
+
};
|
|
82
|
+
OTLPMetricExporterBase.prototype.shutdown = function () {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
switch (_a.label) {
|
|
86
|
+
case 0: return [4 /*yield*/, this._otlpExporter.shutdown()];
|
|
87
|
+
case 1:
|
|
88
|
+
_a.sent();
|
|
89
|
+
return [2 /*return*/];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
OTLPMetricExporterBase.prototype.forceFlush = function () {
|
|
95
|
+
return Promise.resolve();
|
|
96
|
+
};
|
|
97
|
+
OTLPMetricExporterBase.prototype.selectAggregationTemporality = function (instrumentType) {
|
|
98
|
+
return this._aggregationTemporalitySelector(instrumentType);
|
|
99
|
+
};
|
|
100
|
+
return OTLPMetricExporterBase;
|
|
101
|
+
}());
|
|
102
|
+
export { OTLPMetricExporterBase };
|
|
103
|
+
//# sourceMappingURL=OTLPMetricExporterBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OTLPMetricExporterBase.js","sourceRoot":"","sources":["../../src/OTLPMetricExporterBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,OAAO,EACL,sBAAsB,EAEtB,cAAc,EAGf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,cAAc,EAA6B,MAAM,6BAA6B,CAAC;AAIxF,MAAM,CAAC,IAAM,6BAA6B,GAAmC,cAAM,OAAA,sBAAsB,CAAC,UAAU,EAAjC,CAAiC,CAAC;AAErH,MAAM,CAAC,IAAM,wBAAwB,GAAmC,UAAC,cAA8B;IACrG,QAAQ,cAAc,EAAE;QACtB,KAAK,cAAc,CAAC,OAAO,CAAC;QAC5B,KAAK,cAAc,CAAC,kBAAkB,CAAC;QACvC,KAAK,cAAc,CAAC,SAAS,CAAC;QAC9B,KAAK,cAAc,CAAC,gBAAgB;YAClC,OAAO,sBAAsB,CAAC,KAAK,CAAC;QACtC,KAAK,cAAc,CAAC,eAAe,CAAC;QACpC,KAAK,cAAc,CAAC,0BAA0B;YAC5C,OAAO,sBAAsB,CAAC,UAAU,CAAC;KAC5C;AACH,CAAC,CAAC;AAEF,SAAS,yBAAyB,CAAC,qBAA8C;IAC/E,IAAI,qBAAqB,KAAK,sBAAsB,CAAC,KAAK,EAAE;QAC1D,OAAO,wBAAwB,CAAC;KACjC;IAED,OAAO,6BAA6B,CAAC;AACvC,CAAC;AAED;IAOE,gCAAY,QAAW,EACrB,MAAkD;QAAlD,uBAAA,EAAA,uBAAkD;QAClD,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC;QAC9B,IAAI,CAAC,+BAA+B,GAAG,yBAAyB,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;IACjG,CAAC;IAED,uCAAM,GAAN,UAAO,OAAwB,EAAE,cAA8C;QAC7E,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC;IACvD,CAAC;IAEK,yCAAQ,GAAd;;;;4BACE,qBAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAA;;wBAAnC,SAAmC,CAAC;;;;;KACrC;IAED,2CAAU,GAAV;QACE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,6DAA4B,GAA5B,UAA6B,cAA8B;QACzD,OAAO,IAAI,CAAC,+BAA+B,CAAC,cAAc,CAAC,CAAC;IAC9D,CAAC;IACH,6BAAC;AAAD,CAAC,AA5BD,IA4BC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ExportResult } from '@opentelemetry/core';\nimport {\n AggregationTemporality,\n AggregationTemporalitySelector,\n InstrumentType,\n PushMetricExporter,\n ResourceMetrics\n} from '@opentelemetry/sdk-metrics-base';\nimport { defaultOptions, OTLPMetricExporterOptions } from './OTLPMetricExporterOptions';\nimport { OTLPExporterBase } from '@opentelemetry/otlp-exporter-base';\nimport { IExportMetricsServiceRequest } from '@opentelemetry/otlp-transformer';\n\nexport const CumulativeTemporalitySelector: AggregationTemporalitySelector = () => AggregationTemporality.CUMULATIVE;\n\nexport const DeltaTemporalitySelector: AggregationTemporalitySelector = (instrumentType: InstrumentType) => {\n switch (instrumentType) {\n case InstrumentType.COUNTER:\n case InstrumentType.OBSERVABLE_COUNTER:\n case InstrumentType.HISTOGRAM:\n case InstrumentType.OBSERVABLE_GAUGE:\n return AggregationTemporality.DELTA;\n case InstrumentType.UP_DOWN_COUNTER:\n case InstrumentType.OBSERVABLE_UP_DOWN_COUNTER:\n return AggregationTemporality.CUMULATIVE;\n }\n};\n\nfunction chooseTemporalitySelector(temporalityPreference?: AggregationTemporality): AggregationTemporalitySelector {\n if (temporalityPreference === AggregationTemporality.DELTA) {\n return DeltaTemporalitySelector;\n }\n\n return CumulativeTemporalitySelector;\n}\n\nexport class OTLPMetricExporterBase<T extends OTLPExporterBase<OTLPMetricExporterOptions,\n ResourceMetrics,\n IExportMetricsServiceRequest>>\nimplements PushMetricExporter {\n public _otlpExporter: T;\n protected _aggregationTemporalitySelector: AggregationTemporalitySelector;\n\n constructor(exporter: T,\n config: OTLPMetricExporterOptions = defaultOptions) {\n this._otlpExporter = exporter;\n this._aggregationTemporalitySelector = chooseTemporalitySelector(config.temporalityPreference);\n }\n\n export(metrics: ResourceMetrics, resultCallback: (result: ExportResult) => void): void {\n this._otlpExporter.export([metrics], resultCallback);\n }\n\n async shutdown(): Promise<void> {\n await this._otlpExporter.shutdown();\n }\n\n forceFlush(): Promise<void> {\n return Promise.resolve();\n }\n\n selectAggregationTemporality(instrumentType: InstrumentType): AggregationTemporality {\n return this._aggregationTemporalitySelector(instrumentType);\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AggregationTemporality } from '@opentelemetry/sdk-metrics-base';
|
|
2
|
+
import { OTLPExporterConfigBase } from '@opentelemetry/otlp-exporter-base';
|
|
3
|
+
export interface OTLPMetricExporterOptions extends OTLPExporterConfigBase {
|
|
4
|
+
temporalityPreference?: AggregationTemporality;
|
|
5
|
+
}
|
|
6
|
+
export declare const defaultExporterTemporality = AggregationTemporality.CUMULATIVE;
|
|
7
|
+
export declare const defaultOptions: {
|
|
8
|
+
temporalityPreference: AggregationTemporality;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=OTLPMetricExporterOptions.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright The OpenTelemetry Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { AggregationTemporality } from '@opentelemetry/sdk-metrics-base';
|
|
17
|
+
export var defaultExporterTemporality = AggregationTemporality.CUMULATIVE;
|
|
18
|
+
export var defaultOptions = { temporalityPreference: defaultExporterTemporality };
|
|
19
|
+
//# sourceMappingURL=OTLPMetricExporterOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OTLPMetricExporterOptions.js","sourceRoot":"","sources":["../../src/OTLPMetricExporterOptions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAMzE,MAAM,CAAC,IAAM,0BAA0B,GAAG,sBAAsB,CAAC,UAAU,CAAC;AAC5E,MAAM,CAAC,IAAM,cAAc,GAAG,EAAC,qBAAqB,EAAE,0BAA0B,EAAC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AggregationTemporality } from '@opentelemetry/sdk-metrics-base';\nimport { OTLPExporterConfigBase } from '@opentelemetry/otlp-exporter-base';\n\nexport interface OTLPMetricExporterOptions extends OTLPExporterConfigBase {\n temporalityPreference?: AggregationTemporality\n}\nexport const defaultExporterTemporality = AggregationTemporality.CUMULATIVE;\nexport const defaultOptions = {temporalityPreference: defaultExporterTemporality};\n"]}
|
package/build/esm/index.d.ts
CHANGED
package/build/esm/index.js
CHANGED
|
@@ -14,5 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export * from './platform';
|
|
17
|
-
export
|
|
17
|
+
export * from './OTLPMetricExporterOptions';
|
|
18
|
+
export * from './OTLPMetricExporterBase';
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
package/build/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,YAAY,CAAC;AAC3B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './platform';\nexport * from './OTLPMetricExporterOptions';\nexport * from './OTLPMetricExporterBase';\n"]}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ResourceMetrics } from '@opentelemetry/sdk-metrics-base';
|
|
2
|
+
import { OTLPMetricExporterOptions } from '../../OTLPMetricExporterOptions';
|
|
3
|
+
import { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';
|
|
4
|
+
import { OTLPExporterBrowserBase, OTLPExporterConfigBase } from '@opentelemetry/otlp-exporter-base';
|
|
5
|
+
import { IExportMetricsServiceRequest } from '@opentelemetry/otlp-transformer';
|
|
6
|
+
declare class OTLPExporterBrowserProxy extends OTLPExporterBrowserBase<ResourceMetrics, IExportMetricsServiceRequest> {
|
|
7
|
+
constructor(config?: OTLPMetricExporterOptions & OTLPExporterConfigBase);
|
|
8
|
+
getDefaultUrl(config: OTLPExporterConfigBase): string;
|
|
9
|
+
convert(metrics: ResourceMetrics[]): IExportMetricsServiceRequest;
|
|
10
|
+
}
|
|
3
11
|
/**
|
|
4
12
|
* Collector Metric Exporter for Web
|
|
5
13
|
*/
|
|
6
|
-
export declare class OTLPMetricExporter extends
|
|
7
|
-
|
|
8
|
-
constructor(config?: otlpTypes.OTLPExporterConfigBase);
|
|
9
|
-
convert(metrics: MetricRecord[]): otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest;
|
|
10
|
-
getDefaultUrl(config: otlpTypes.OTLPExporterConfigBase): string;
|
|
14
|
+
export declare class OTLPMetricExporter extends OTLPMetricExporterBase<OTLPExporterBrowserProxy> {
|
|
15
|
+
constructor(config?: OTLPExporterConfigBase & OTLPMetricExporterOptions);
|
|
11
16
|
}
|
|
17
|
+
export {};
|
|
12
18
|
//# sourceMappingURL=OTLPMetricExporter.d.ts.map
|
|
@@ -28,37 +28,45 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
28
28
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
29
29
|
};
|
|
30
30
|
})();
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (config === void 0) { config = {}; }
|
|
31
|
+
import { baggageUtils, getEnv } from '@opentelemetry/core';
|
|
32
|
+
import { defaultOptions } from '../../OTLPMetricExporterOptions';
|
|
33
|
+
import { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';
|
|
34
|
+
import { OTLPExporterBrowserBase, appendResourcePathToUrl, appendRootPathToUrlIfNeeded } from '@opentelemetry/otlp-exporter-base';
|
|
35
|
+
import { createExportMetricsServiceRequest } from '@opentelemetry/otlp-transformer';
|
|
36
|
+
var DEFAULT_COLLECTOR_RESOURCE_PATH = 'v1/metrics';
|
|
37
|
+
var DEFAULT_COLLECTOR_URL = "http://localhost:4318/" + DEFAULT_COLLECTOR_RESOURCE_PATH;
|
|
38
|
+
var OTLPExporterBrowserProxy = /** @class */ (function (_super) {
|
|
39
|
+
__extends(OTLPExporterBrowserProxy, _super);
|
|
40
|
+
function OTLPExporterBrowserProxy(config) {
|
|
41
|
+
if (config === void 0) { config = defaultOptions; }
|
|
43
42
|
var _this = _super.call(this, config) || this;
|
|
44
|
-
// Converts time to nanoseconds
|
|
45
|
-
_this._startTime = new Date().getTime() * 1000000;
|
|
46
43
|
_this._headers = Object.assign(_this._headers, baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_METRICS_HEADERS));
|
|
47
44
|
return _this;
|
|
48
45
|
}
|
|
49
|
-
|
|
50
|
-
return toOTLPExportMetricServiceRequest(metrics, this._startTime, this);
|
|
51
|
-
};
|
|
52
|
-
OTLPMetricExporter.prototype.getDefaultUrl = function (config) {
|
|
46
|
+
OTLPExporterBrowserProxy.prototype.getDefaultUrl = function (config) {
|
|
53
47
|
return typeof config.url === 'string'
|
|
54
48
|
? config.url
|
|
55
49
|
: getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0
|
|
56
|
-
? getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT
|
|
50
|
+
? appendRootPathToUrlIfNeeded(getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
|
|
57
51
|
: getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0
|
|
58
|
-
?
|
|
52
|
+
? appendResourcePathToUrl(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
|
|
59
53
|
: DEFAULT_COLLECTOR_URL;
|
|
60
54
|
};
|
|
61
|
-
|
|
55
|
+
OTLPExporterBrowserProxy.prototype.convert = function (metrics) {
|
|
56
|
+
return createExportMetricsServiceRequest(metrics);
|
|
57
|
+
};
|
|
58
|
+
return OTLPExporterBrowserProxy;
|
|
62
59
|
}(OTLPExporterBrowserBase));
|
|
60
|
+
/**
|
|
61
|
+
* Collector Metric Exporter for Web
|
|
62
|
+
*/
|
|
63
|
+
var OTLPMetricExporter = /** @class */ (function (_super) {
|
|
64
|
+
__extends(OTLPMetricExporter, _super);
|
|
65
|
+
function OTLPMetricExporter(config) {
|
|
66
|
+
if (config === void 0) { config = defaultOptions; }
|
|
67
|
+
return _super.call(this, new OTLPExporterBrowserProxy(config), config) || this;
|
|
68
|
+
}
|
|
69
|
+
return OTLPMetricExporter;
|
|
70
|
+
}(OTLPMetricExporterBase));
|
|
63
71
|
export { OTLPMetricExporter };
|
|
64
72
|
//# sourceMappingURL=OTLPMetricExporter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OTLPMetricExporter.js","sourceRoot":"","sources":["../../../../src/platform/browser/OTLPMetricExporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAGH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"OTLPMetricExporter.js","sourceRoot":"","sources":["../../../../src/platform/browser/OTLPMetricExporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAA6B,MAAM,iCAAiC,CAAC;AAC5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EACL,uBAAuB,EAEvB,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,iCAAiC,EAAgC,MAAM,iCAAiC,CAAC;AAElH,IAAM,+BAA+B,GAAG,YAAY,CAAC;AACrD,IAAM,qBAAqB,GAAG,2BAAyB,+BAAiC,CAAC;AAEzF;IAAuC,4CAAsE;IAE3G,kCAAY,MAA2E;QAA3E,uBAAA,EAAA,uBAA2E;QAAvF,YACE,kBAAM,MAAM,CAAC,SAOd;QANC,KAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,CAC3B,KAAI,CAAC,QAAQ,EACb,YAAY,CAAC,uBAAuB,CAClC,MAAM,EAAE,CAAC,kCAAkC,CAC5C,CACF,CAAC;;IACJ,CAAC;IAED,gDAAa,GAAb,UAAc,MAA8B;QAC1C,OAAO,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ;YACnC,CAAC,CAAC,MAAM,CAAC,GAAG;YACZ,CAAC,CAAC,MAAM,EAAE,CAAC,mCAAmC,CAAC,MAAM,GAAG,CAAC;gBACvD,CAAC,CAAC,2BAA2B,CAAC,MAAM,EAAE,CAAC,mCAAmC,EAAE,+BAA+B,CAAC;gBAC5G,CAAC,CAAC,MAAM,EAAE,CAAC,2BAA2B,CAAC,MAAM,GAAG,CAAC;oBAC/C,CAAC,CAAC,uBAAuB,CAAC,MAAM,EAAE,CAAC,2BAA2B,EAAE,+BAA+B,CAAC;oBAChG,CAAC,CAAC,qBAAqB,CAAC;IAChC,CAAC;IAED,0CAAO,GAAP,UAAQ,OAA0B;QAChC,OAAO,iCAAiC,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;IACH,+BAAC;AAAD,CAAC,AAzBD,CAAuC,uBAAuB,GAyB7D;AAED;;GAEG;AACH;IAAwC,sCAAgD;IACtF,4BAAY,MAA2E;QAA3E,uBAAA,EAAA,uBAA2E;eACrF,kBAAM,IAAI,wBAAwB,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACrD,CAAC;IACH,yBAAC;AAAD,CAAC,AAJD,CAAwC,sBAAsB,GAI7D","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ResourceMetrics } from '@opentelemetry/sdk-metrics-base';\nimport { baggageUtils, getEnv } from '@opentelemetry/core';\nimport { defaultOptions, OTLPMetricExporterOptions } from '../../OTLPMetricExporterOptions';\nimport { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';\nimport {\n OTLPExporterBrowserBase,\n OTLPExporterConfigBase,\n appendResourcePathToUrl,\n appendRootPathToUrlIfNeeded\n} from '@opentelemetry/otlp-exporter-base';\nimport { createExportMetricsServiceRequest, IExportMetricsServiceRequest } from '@opentelemetry/otlp-transformer';\n\nconst DEFAULT_COLLECTOR_RESOURCE_PATH = 'v1/metrics';\nconst DEFAULT_COLLECTOR_URL = `http://localhost:4318/${DEFAULT_COLLECTOR_RESOURCE_PATH}`;\n\nclass OTLPExporterBrowserProxy extends OTLPExporterBrowserBase<ResourceMetrics, IExportMetricsServiceRequest> {\n\n constructor(config: OTLPMetricExporterOptions & OTLPExporterConfigBase = defaultOptions) {\n super(config);\n this._headers = Object.assign(\n this._headers,\n baggageUtils.parseKeyPairsIntoRecord(\n getEnv().OTEL_EXPORTER_OTLP_METRICS_HEADERS\n )\n );\n }\n\n getDefaultUrl(config: OTLPExporterConfigBase): string {\n return typeof config.url === 'string'\n ? config.url\n : getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0\n ? appendRootPathToUrlIfNeeded(getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)\n : getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0\n ? appendResourcePathToUrl(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)\n : DEFAULT_COLLECTOR_URL;\n }\n\n convert(metrics: ResourceMetrics[]): IExportMetricsServiceRequest {\n return createExportMetricsServiceRequest(metrics);\n }\n}\n\n/**\n * Collector Metric Exporter for Web\n */\nexport class OTLPMetricExporter extends OTLPMetricExporterBase<OTLPExporterBrowserProxy> {\n constructor(config: OTLPExporterConfigBase & OTLPMetricExporterOptions = defaultOptions) {\n super(new OTLPExporterBrowserProxy(config), config);\n }\n}\n"]}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ResourceMetrics } from '@opentelemetry/sdk-metrics-base';
|
|
2
|
+
import { OTLPMetricExporterOptions } from '../../OTLPMetricExporterOptions';
|
|
3
|
+
import { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';
|
|
4
|
+
import { OTLPExporterNodeBase, OTLPExporterNodeConfigBase } from '@opentelemetry/otlp-exporter-base';
|
|
5
|
+
import { IExportMetricsServiceRequest } from '@opentelemetry/otlp-transformer';
|
|
6
|
+
declare class OTLPExporterNodeProxy extends OTLPExporterNodeBase<ResourceMetrics, IExportMetricsServiceRequest> {
|
|
7
|
+
constructor(config?: OTLPExporterNodeConfigBase & OTLPMetricExporterOptions);
|
|
8
|
+
convert(metrics: ResourceMetrics[]): IExportMetricsServiceRequest;
|
|
9
|
+
getDefaultUrl(config: OTLPExporterNodeConfigBase): string;
|
|
10
|
+
}
|
|
3
11
|
/**
|
|
4
12
|
* Collector Metric Exporter for Node
|
|
5
13
|
*/
|
|
6
|
-
export declare class OTLPMetricExporter extends
|
|
7
|
-
|
|
8
|
-
constructor(config?: OTLPExporterNodeConfigBase);
|
|
9
|
-
convert(metrics: MetricRecord[]): otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest;
|
|
10
|
-
getDefaultUrl(config: OTLPExporterNodeConfigBase): string;
|
|
14
|
+
export declare class OTLPMetricExporter extends OTLPMetricExporterBase<OTLPExporterNodeProxy> {
|
|
15
|
+
constructor(config?: OTLPExporterNodeConfigBase & OTLPMetricExporterOptions);
|
|
11
16
|
}
|
|
17
|
+
export {};
|
|
12
18
|
//# sourceMappingURL=OTLPMetricExporter.d.ts.map
|
|
@@ -28,37 +28,45 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
28
28
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
29
29
|
};
|
|
30
30
|
})();
|
|
31
|
-
import { OTLPExporterNodeBase, appendResourcePathToUrlIfNotPresent } from '@opentelemetry/exporter-trace-otlp-http';
|
|
32
|
-
import { toOTLPExportMetricServiceRequest } from '../../transformMetrics';
|
|
33
31
|
import { getEnv, baggageUtils } from '@opentelemetry/core';
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
import { defaultOptions } from '../../OTLPMetricExporterOptions';
|
|
33
|
+
import { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';
|
|
34
|
+
import { OTLPExporterNodeBase, appendResourcePathToUrl, appendRootPathToUrlIfNeeded } from '@opentelemetry/otlp-exporter-base';
|
|
35
|
+
import { createExportMetricsServiceRequest } from '@opentelemetry/otlp-transformer';
|
|
36
|
+
var DEFAULT_COLLECTOR_RESOURCE_PATH = 'v1/metrics';
|
|
37
|
+
var DEFAULT_COLLECTOR_URL = "http://localhost:4318/" + DEFAULT_COLLECTOR_RESOURCE_PATH;
|
|
38
|
+
var OTLPExporterNodeProxy = /** @class */ (function (_super) {
|
|
39
|
+
__extends(OTLPExporterNodeProxy, _super);
|
|
40
|
+
function OTLPExporterNodeProxy(config) {
|
|
41
|
+
if (config === void 0) { config = defaultOptions; }
|
|
43
42
|
var _this = _super.call(this, config) || this;
|
|
44
|
-
// Converts time to nanoseconds
|
|
45
|
-
_this._startTime = new Date().getTime() * 1000000;
|
|
46
43
|
_this.headers = Object.assign(_this.headers, baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_METRICS_HEADERS));
|
|
47
44
|
return _this;
|
|
48
45
|
}
|
|
49
|
-
|
|
50
|
-
return
|
|
46
|
+
OTLPExporterNodeProxy.prototype.convert = function (metrics) {
|
|
47
|
+
return createExportMetricsServiceRequest(metrics);
|
|
51
48
|
};
|
|
52
|
-
|
|
49
|
+
OTLPExporterNodeProxy.prototype.getDefaultUrl = function (config) {
|
|
53
50
|
return typeof config.url === 'string'
|
|
54
51
|
? config.url
|
|
55
52
|
: getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0
|
|
56
|
-
? getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT
|
|
53
|
+
? appendRootPathToUrlIfNeeded(getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
|
|
57
54
|
: getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0
|
|
58
|
-
?
|
|
55
|
+
? appendResourcePathToUrl(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
|
|
59
56
|
: DEFAULT_COLLECTOR_URL;
|
|
60
57
|
};
|
|
61
|
-
return
|
|
58
|
+
return OTLPExporterNodeProxy;
|
|
62
59
|
}(OTLPExporterNodeBase));
|
|
60
|
+
/**
|
|
61
|
+
* Collector Metric Exporter for Node
|
|
62
|
+
*/
|
|
63
|
+
var OTLPMetricExporter = /** @class */ (function (_super) {
|
|
64
|
+
__extends(OTLPMetricExporter, _super);
|
|
65
|
+
function OTLPMetricExporter(config) {
|
|
66
|
+
if (config === void 0) { config = defaultOptions; }
|
|
67
|
+
return _super.call(this, new OTLPExporterNodeProxy(config), config) || this;
|
|
68
|
+
}
|
|
69
|
+
return OTLPMetricExporter;
|
|
70
|
+
}(OTLPMetricExporterBase));
|
|
63
71
|
export { OTLPMetricExporter };
|
|
64
72
|
//# sourceMappingURL=OTLPMetricExporter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OTLPMetricExporter.js","sourceRoot":"","sources":["../../../../src/platform/node/OTLPMetricExporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"OTLPMetricExporter.js","sourceRoot":"","sources":["../../../../src/platform/node/OTLPMetricExporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAGH,OAAO,EAAE,MAAM,EAAE,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAA6B,MAAM,iCAAiC,CAAC;AAC5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EACL,oBAAoB,EAEpB,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,iCAAiC,EAAgC,MAAM,iCAAiC,CAAC;AAElH,IAAM,+BAA+B,GAAG,YAAY,CAAC;AACrD,IAAM,qBAAqB,GAAG,2BAAyB,+BAAiC,CAAC;AAEzF;IAAoC,yCAAmE;IAErG,+BAAY,MAA+E;QAA/E,uBAAA,EAAA,uBAA+E;QAA3F,YACE,kBAAM,MAAM,CAAC,SAOd;QANC,KAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAC1B,KAAI,CAAC,OAAO,EACZ,YAAY,CAAC,uBAAuB,CAClC,MAAM,EAAE,CAAC,kCAAkC,CAC5C,CACF,CAAC;;IACJ,CAAC;IAED,uCAAO,GAAP,UAAQ,OAA0B;QAChC,OAAO,iCAAiC,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;IAED,6CAAa,GAAb,UAAc,MAAkC;QAC9C,OAAO,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ;YACnC,CAAC,CAAC,MAAM,CAAC,GAAG;YACZ,CAAC,CAAC,MAAM,EAAE,CAAC,mCAAmC,CAAC,MAAM,GAAG,CAAC;gBACvD,CAAC,CAAC,2BAA2B,CAAC,MAAM,EAAE,CAAC,mCAAmC,EAAE,+BAA+B,CAAC;gBAC5G,CAAC,CAAC,MAAM,EAAE,CAAC,2BAA2B,CAAC,MAAM,GAAG,CAAC;oBAC/C,CAAC,CAAC,uBAAuB,CAAC,MAAM,EAAE,CAAC,2BAA2B,EAAE,+BAA+B,CAAC;oBAChG,CAAC,CAAC,qBAAqB,CAAC;IAChC,CAAC;IACH,4BAAC;AAAD,CAAC,AAzBD,CAAoC,oBAAoB,GAyBvD;AAED;;GAEG;AACH;IAAwC,sCAA6C;IACnF,4BAAY,MAA+E;QAA/E,uBAAA,EAAA,uBAA+E;eACzF,kBAAM,IAAI,qBAAqB,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAClD,CAAC;IACH,yBAAC;AAAD,CAAC,AAJD,CAAwC,sBAAsB,GAI7D","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ResourceMetrics } from '@opentelemetry/sdk-metrics-base';\nimport { getEnv, baggageUtils} from '@opentelemetry/core';\nimport { defaultOptions, OTLPMetricExporterOptions } from '../../OTLPMetricExporterOptions';\nimport { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';\nimport {\n OTLPExporterNodeBase,\n OTLPExporterNodeConfigBase,\n appendResourcePathToUrl,\n appendRootPathToUrlIfNeeded\n} from '@opentelemetry/otlp-exporter-base';\nimport { createExportMetricsServiceRequest, IExportMetricsServiceRequest } from '@opentelemetry/otlp-transformer';\n\nconst DEFAULT_COLLECTOR_RESOURCE_PATH = 'v1/metrics';\nconst DEFAULT_COLLECTOR_URL = `http://localhost:4318/${DEFAULT_COLLECTOR_RESOURCE_PATH}`;\n\nclass OTLPExporterNodeProxy extends OTLPExporterNodeBase<ResourceMetrics, IExportMetricsServiceRequest> {\n\n constructor(config: OTLPExporterNodeConfigBase & OTLPMetricExporterOptions = defaultOptions) {\n super(config);\n this.headers = Object.assign(\n this.headers,\n baggageUtils.parseKeyPairsIntoRecord(\n getEnv().OTEL_EXPORTER_OTLP_METRICS_HEADERS\n )\n );\n }\n\n convert(metrics: ResourceMetrics[]): IExportMetricsServiceRequest {\n return createExportMetricsServiceRequest(metrics);\n }\n\n getDefaultUrl(config: OTLPExporterNodeConfigBase): string {\n return typeof config.url === 'string'\n ? config.url\n : getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0\n ? appendRootPathToUrlIfNeeded(getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)\n : getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0\n ? appendResourcePathToUrl(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)\n : DEFAULT_COLLECTOR_URL;\n }\n}\n\n/**\n * Collector Metric Exporter for Node\n */\nexport class OTLPMetricExporter extends OTLPMetricExporterBase<OTLPExporterNodeProxy> {\n constructor(config: OTLPExporterNodeConfigBase & OTLPMetricExporterOptions = defaultOptions) {\n super(new OTLPExporterNodeProxy(config), config);\n }\n}\n"]}
|
package/build/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.29.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/esm/version.js
CHANGED
package/build/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.29.1';\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ExportResult } from '@opentelemetry/core';
|
|
2
|
+
import { AggregationTemporality, AggregationTemporalitySelector, InstrumentType, PushMetricExporter, ResourceMetrics } from '@opentelemetry/sdk-metrics-base';
|
|
3
|
+
import { OTLPMetricExporterOptions } from './OTLPMetricExporterOptions';
|
|
4
|
+
import { OTLPExporterBase } from '@opentelemetry/otlp-exporter-base';
|
|
5
|
+
import { IExportMetricsServiceRequest } from '@opentelemetry/otlp-transformer';
|
|
6
|
+
export declare const CumulativeTemporalitySelector: AggregationTemporalitySelector;
|
|
7
|
+
export declare const DeltaTemporalitySelector: AggregationTemporalitySelector;
|
|
8
|
+
export declare class OTLPMetricExporterBase<T extends OTLPExporterBase<OTLPMetricExporterOptions, ResourceMetrics, IExportMetricsServiceRequest>> implements PushMetricExporter {
|
|
9
|
+
_otlpExporter: T;
|
|
10
|
+
protected _aggregationTemporalitySelector: AggregationTemporalitySelector;
|
|
11
|
+
constructor(exporter: T, config?: OTLPMetricExporterOptions);
|
|
12
|
+
export(metrics: ResourceMetrics, resultCallback: (result: ExportResult) => void): void;
|
|
13
|
+
shutdown(): Promise<void>;
|
|
14
|
+
forceFlush(): Promise<void>;
|
|
15
|
+
selectAggregationTemporality(instrumentType: InstrumentType): AggregationTemporality;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=OTLPMetricExporterBase.d.ts.map
|