@opentelemetry/exporter-metrics-otlp-http 0.27.0 → 0.28.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.
Files changed (74) hide show
  1. package/README.md +3 -9
  2. package/build/esm/OTLPMetricExporterBase.d.ts +15 -0
  3. package/build/esm/OTLPMetricExporterBase.js +85 -0
  4. package/build/esm/OTLPMetricExporterBase.js.map +1 -0
  5. package/build/esm/OTLPMetricExporterOptions.d.ts +10 -0
  6. package/build/esm/OTLPMetricExporterOptions.js +19 -0
  7. package/build/esm/OTLPMetricExporterOptions.js.map +1 -0
  8. package/build/esm/index.d.ts +2 -0
  9. package/build/esm/index.js +2 -0
  10. package/build/esm/index.js.map +1 -1
  11. package/build/esm/platform/browser/OTLPMetricExporter.d.ts +14 -7
  12. package/build/esm/platform/browser/OTLPMetricExporter.js +27 -17
  13. package/build/esm/platform/browser/OTLPMetricExporter.js.map +1 -1
  14. package/build/esm/platform/node/OTLPMetricExporter.d.ts +14 -7
  15. package/build/esm/platform/node/OTLPMetricExporter.js +25 -15
  16. package/build/esm/platform/node/OTLPMetricExporter.js.map +1 -1
  17. package/build/esm/transformMetrics.d.ts +23 -32
  18. package/build/esm/transformMetrics.js +107 -111
  19. package/build/esm/transformMetrics.js.map +1 -1
  20. package/build/esm/version.d.ts +1 -1
  21. package/build/esm/version.js +1 -1
  22. package/build/esm/version.js.map +1 -1
  23. package/build/esnext/OTLPMetricExporterBase.d.ts +15 -0
  24. package/build/esnext/OTLPMetricExporterBase.js +37 -0
  25. package/build/esnext/OTLPMetricExporterBase.js.map +1 -0
  26. package/build/esnext/OTLPMetricExporterOptions.d.ts +10 -0
  27. package/build/esnext/OTLPMetricExporterOptions.js +19 -0
  28. package/build/esnext/OTLPMetricExporterOptions.js.map +1 -0
  29. package/build/esnext/index.d.ts +5 -0
  30. package/build/esnext/index.js +20 -0
  31. package/build/esnext/index.js.map +1 -0
  32. package/build/esnext/platform/browser/OTLPMetricExporter.d.ts +19 -0
  33. package/build/esnext/platform/browser/OTLPMetricExporter.js +51 -0
  34. package/build/esnext/platform/browser/OTLPMetricExporter.js.map +1 -0
  35. package/build/esnext/platform/browser/index.d.ts +2 -0
  36. package/build/esnext/platform/browser/index.js +17 -0
  37. package/build/esnext/platform/browser/index.js.map +1 -0
  38. package/build/esnext/platform/index.d.ts +2 -0
  39. package/build/esnext/platform/index.js +17 -0
  40. package/build/esnext/platform/index.js.map +1 -0
  41. package/build/esnext/platform/node/OTLPMetricExporter.d.ts +19 -0
  42. package/build/esnext/platform/node/OTLPMetricExporter.js +51 -0
  43. package/build/esnext/platform/node/OTLPMetricExporter.js.map +1 -0
  44. package/build/esnext/platform/node/index.d.ts +2 -0
  45. package/build/esnext/platform/node/index.js +17 -0
  46. package/build/esnext/platform/node/index.js.map +1 -0
  47. package/build/esnext/transformMetrics.d.ts +38 -0
  48. package/build/esnext/transformMetrics.js +167 -0
  49. package/build/esnext/transformMetrics.js.map +1 -0
  50. package/build/esnext/version.d.ts +2 -0
  51. package/build/esnext/version.js +18 -0
  52. package/build/esnext/version.js.map +1 -0
  53. package/build/src/OTLPMetricExporterBase.d.ts +15 -0
  54. package/build/src/OTLPMetricExporterBase.js +41 -0
  55. package/build/src/OTLPMetricExporterBase.js.map +1 -0
  56. package/build/src/OTLPMetricExporterOptions.d.ts +10 -0
  57. package/build/src/OTLPMetricExporterOptions.js +22 -0
  58. package/build/src/OTLPMetricExporterOptions.js.map +1 -0
  59. package/build/src/index.d.ts +2 -0
  60. package/build/src/index.js +2 -0
  61. package/build/src/index.js.map +1 -1
  62. package/build/src/platform/browser/OTLPMetricExporter.d.ts +14 -7
  63. package/build/src/platform/browser/OTLPMetricExporter.js +24 -17
  64. package/build/src/platform/browser/OTLPMetricExporter.js.map +1 -1
  65. package/build/src/platform/node/OTLPMetricExporter.d.ts +14 -7
  66. package/build/src/platform/node/OTLPMetricExporter.js +22 -15
  67. package/build/src/platform/node/OTLPMetricExporter.js.map +1 -1
  68. package/build/src/transformMetrics.d.ts +23 -32
  69. package/build/src/transformMetrics.js +94 -111
  70. package/build/src/transformMetrics.js.map +1 -1
  71. package/build/src/version.d.ts +1 -1
  72. package/build/src/version.js +1 -1
  73. package/build/src/version.js.map +1 -1
  74. package/package.json +33 -24
package/README.md CHANGED
@@ -1,8 +1,6 @@
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
6
  This module provides exporter for web and node to be used with [opentelemetry-collector][opentelemetry-collector-url] - last tested with version **0.25.0**.
@@ -27,7 +25,7 @@ The OTLPMetricExporter in Web expects the endpoint to end in `/v1/metrics`.
27
25
  import { MeterProvider } from '@opentelemetry/sdk-metrics-base';
28
26
  import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';
29
27
  const collectorOptions = {
30
- url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:55681/v1/metrics
28
+ url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:4318/v1/metrics
31
29
  headers: {}, // an optional object containing custom headers to be sent with each request
32
30
  concurrencyLimit: 1, // an optional limit on pending requests
33
31
  };
@@ -51,7 +49,7 @@ counter.add(10, { 'key': 'value' });
51
49
  const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
52
50
  const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-http');
53
51
  const collectorOptions = {
54
- url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:55681/v1/metrics
52
+ url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:4318/v1/metrics
55
53
  concurrencyLimit: 1, // an optional limit on pending requests
56
54
  };
57
55
  const exporter = new OTLPMetricExporter(collectorOptions);
@@ -117,10 +115,6 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
117
115
  [discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
118
116
  [license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/LICENSE
119
117
  [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
118
  [npm-url]: https://www.npmjs.com/package/@opentelemetry/exporter-metrics-otlp-http
125
119
  [npm-url-grpc]: https://www.npmjs.com/package/@opentelemetry/exporter-metrics-otlp-grpc
126
120
  [npm-url-proto]: https://www.npmjs.com/package/@opentelemetry/exporter-metrics-otlp-proto
@@ -128,4 +122,4 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
128
122
  [opentelemetry-collector-url]: https://github.com/open-telemetry/opentelemetry-collector
129
123
  [opentelemetry-spec-protocol-exporter]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#configuration-options
130
124
  [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/opentelemetry-exporter-trace-otlp-http
125
+ [trace-exporter-url]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/exporter-trace-otlp-http
@@ -0,0 +1,15 @@
1
+ import { ExportResult } from '@opentelemetry/core';
2
+ import { AggregationTemporality, PushMetricExporter, ResourceMetrics } from '@opentelemetry/sdk-metrics-base';
3
+ import { otlpTypes } from '@opentelemetry/exporter-trace-otlp-http';
4
+ import { OTLPMetricExporterOptions } from './OTLPMetricExporterOptions';
5
+ import { OTLPExporterBase } from '@opentelemetry/otlp-exporter-base';
6
+ export declare class OTLPMetricExporterBase<T extends OTLPExporterBase<OTLPMetricExporterOptions, ResourceMetrics, otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest>> implements PushMetricExporter {
7
+ _otlpExporter: T;
8
+ protected _preferredAggregationTemporality: AggregationTemporality;
9
+ constructor(exporter: T, config?: OTLPMetricExporterOptions);
10
+ export(metrics: ResourceMetrics, resultCallback: (result: ExportResult) => void): void;
11
+ shutdown(): Promise<void>;
12
+ forceFlush(): Promise<void>;
13
+ getPreferredAggregationTemporality(): AggregationTemporality;
14
+ }
15
+ //# sourceMappingURL=OTLPMetricExporterBase.d.ts.map
@@ -0,0 +1,85 @@
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 } from '@opentelemetry/sdk-metrics-base';
53
+ import { defaultOptions } from './OTLPMetricExporterOptions';
54
+ var OTLPMetricExporterBase = /** @class */ (function () {
55
+ function OTLPMetricExporterBase(exporter, config) {
56
+ if (config === void 0) { config = defaultOptions; }
57
+ var _a;
58
+ this._otlpExporter = exporter;
59
+ this._preferredAggregationTemporality = (_a = config.aggregationTemporality) !== null && _a !== void 0 ? _a : AggregationTemporality.CUMULATIVE;
60
+ }
61
+ OTLPMetricExporterBase.prototype.export = function (metrics, resultCallback) {
62
+ this._otlpExporter.export([metrics], resultCallback);
63
+ };
64
+ OTLPMetricExporterBase.prototype.shutdown = function () {
65
+ return __awaiter(this, void 0, void 0, function () {
66
+ return __generator(this, function (_a) {
67
+ switch (_a.label) {
68
+ case 0: return [4 /*yield*/, this._otlpExporter.shutdown()];
69
+ case 1:
70
+ _a.sent();
71
+ return [2 /*return*/];
72
+ }
73
+ });
74
+ });
75
+ };
76
+ OTLPMetricExporterBase.prototype.forceFlush = function () {
77
+ return Promise.resolve();
78
+ };
79
+ OTLPMetricExporterBase.prototype.getPreferredAggregationTemporality = function () {
80
+ return this._preferredAggregationTemporality;
81
+ };
82
+ return OTLPMetricExporterBase;
83
+ }());
84
+ export { OTLPMetricExporterBase };
85
+ //# sourceMappingURL=OTLPMetricExporterBase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OTLPMetricExporterBase.js","sourceRoot":"","sources":["../../src/OTLPMetricExporterBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,OAAO,EAAE,sBAAsB,EAAuC,MAAM,iCAAiC,CAAC;AAE9G,OAAO,EAAE,cAAc,EAA6B,MAAM,6BAA6B,CAAC;AAGxF;IAOE,gCAAY,QAAW,EACX,MAAkD;QAAlD,uBAAA,EAAA,uBAAkD;;QAC5D,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC;QAC9B,IAAI,CAAC,gCAAgC,GAAG,MAAA,MAAM,CAAC,sBAAsB,mCAAI,sBAAsB,CAAC,UAAU,CAAC;IAC7G,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,mEAAkC,GAAlC;QACE,OAAO,IAAI,CAAC,gCAAgC,CAAC;IAC/C,CAAC;IAEH,6BAAC;AAAD,CAAC,AA7BD,IA6BC","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 { AggregationTemporality, PushMetricExporter, ResourceMetrics } from '@opentelemetry/sdk-metrics-base';\nimport { otlpTypes } from '@opentelemetry/exporter-trace-otlp-http';\nimport { defaultOptions, OTLPMetricExporterOptions } from './OTLPMetricExporterOptions';\nimport { OTLPExporterBase } from '@opentelemetry/otlp-exporter-base';\n\nexport class OTLPMetricExporterBase<T extends OTLPExporterBase<OTLPMetricExporterOptions,\n ResourceMetrics,\n otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest>>\n implements PushMetricExporter {\n public _otlpExporter: T;\n protected _preferredAggregationTemporality: AggregationTemporality;\n\n constructor(exporter: T,\n config: OTLPMetricExporterOptions = defaultOptions) {\n this._otlpExporter = exporter;\n this._preferredAggregationTemporality = config.aggregationTemporality ?? AggregationTemporality.CUMULATIVE;\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 getPreferredAggregationTemporality(): AggregationTemporality {\n return this._preferredAggregationTemporality;\n }\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
+ aggregationTemporality?: AggregationTemporality;
5
+ }
6
+ export declare const defaultExporterTemporality = AggregationTemporality.CUMULATIVE;
7
+ export declare const defaultOptions: {
8
+ aggregationTemporality: 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 = { aggregationTemporality: 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,sBAAsB,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 aggregationTemporality?: AggregationTemporality\n}\nexport const defaultExporterTemporality = AggregationTemporality.CUMULATIVE;\nexport const defaultOptions = {aggregationTemporality: defaultExporterTemporality};\n"]}
@@ -1,3 +1,5 @@
1
1
  export * from './platform';
2
+ export * from './OTLPMetricExporterOptions';
3
+ export * from './OTLPMetricExporterBase';
2
4
  export { toOTLPExportMetricServiceRequest } from './transformMetrics';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -14,5 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export * from './platform';
17
+ export * from './OTLPMetricExporterOptions';
18
+ export * from './OTLPMetricExporterBase';
17
19
  export { toOTLPExportMetricServiceRequest } from './transformMetrics';
18
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,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 { toOTLPExportMetricServiceRequest } from './transformMetrics';\n"]}
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;AACzC,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,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';\nexport { toOTLPExportMetricServiceRequest } from './transformMetrics';\n"]}
@@ -1,12 +1,19 @@
1
- import { MetricRecord, MetricExporter } from '@opentelemetry/sdk-metrics-base';
2
- import { OTLPExporterBrowserBase, otlpTypes } from '@opentelemetry/exporter-trace-otlp-http';
1
+ import { AggregationTemporality, ResourceMetrics } from '@opentelemetry/sdk-metrics-base';
2
+ import { otlpTypes } from '@opentelemetry/exporter-trace-otlp-http';
3
+ import { OTLPMetricExporterOptions } from '../../OTLPMetricExporterOptions';
4
+ import { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';
5
+ import { OTLPExporterBrowserBase, OTLPExporterConfigBase } from '@opentelemetry/otlp-exporter-base';
6
+ declare class OTLPExporterBrowserProxy extends OTLPExporterBrowserBase<ResourceMetrics, otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest> {
7
+ protected readonly _aggregationTemporality: AggregationTemporality;
8
+ constructor(config?: OTLPMetricExporterOptions & OTLPExporterConfigBase);
9
+ getDefaultUrl(config: OTLPExporterConfigBase): string;
10
+ convert(metrics: ResourceMetrics[]): otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest;
11
+ }
3
12
  /**
4
13
  * Collector Metric Exporter for Web
5
14
  */
6
- export declare class OTLPMetricExporter extends OTLPExporterBrowserBase<MetricRecord, otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest> implements MetricExporter {
7
- private readonly _startTime;
8
- constructor(config?: otlpTypes.OTLPExporterConfigBase);
9
- convert(metrics: MetricRecord[]): otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest;
10
- getDefaultUrl(config: otlpTypes.OTLPExporterConfigBase): string;
15
+ export declare class OTLPMetricExporter extends OTLPMetricExporterBase<OTLPExporterBrowserProxy> {
16
+ constructor(config?: OTLPExporterConfigBase & OTLPMetricExporterOptions);
11
17
  }
18
+ export {};
12
19
  //# sourceMappingURL=OTLPMetricExporter.d.ts.map
@@ -28,28 +28,24 @@ 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 { OTLPExporterBrowserBase, appendResourcePathToUrlIfNotPresent } from '@opentelemetry/exporter-trace-otlp-http';
32
31
  import { toOTLPExportMetricServiceRequest } from '../../transformMetrics';
33
- import { getEnv, baggageUtils } from '@opentelemetry/core';
32
+ import { baggageUtils, getEnv } from '@opentelemetry/core';
33
+ import { defaultExporterTemporality, defaultOptions } from '../../OTLPMetricExporterOptions';
34
+ import { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';
35
+ import { appendResourcePathToUrlIfNotPresent, OTLPExporterBrowserBase } from '@opentelemetry/otlp-exporter-base';
34
36
  var DEFAULT_COLLECTOR_RESOURCE_PATH = '/v1/metrics';
35
- var DEFAULT_COLLECTOR_URL = "http://localhost:55681" + DEFAULT_COLLECTOR_RESOURCE_PATH;
36
- /**
37
- * Collector Metric Exporter for Web
38
- */
39
- var OTLPMetricExporter = /** @class */ (function (_super) {
40
- __extends(OTLPMetricExporter, _super);
41
- function OTLPMetricExporter(config) {
42
- if (config === void 0) { config = {}; }
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; }
42
+ var _a;
43
43
  var _this = _super.call(this, config) || this;
44
- // Converts time to nanoseconds
45
- _this._startTime = new Date().getTime() * 1000000;
46
44
  _this._headers = Object.assign(_this._headers, baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_METRICS_HEADERS));
45
+ _this._aggregationTemporality = (_a = config.aggregationTemporality) !== null && _a !== void 0 ? _a : defaultExporterTemporality;
47
46
  return _this;
48
47
  }
49
- OTLPMetricExporter.prototype.convert = function (metrics) {
50
- return toOTLPExportMetricServiceRequest(metrics, this._startTime, this);
51
- };
52
- OTLPMetricExporter.prototype.getDefaultUrl = function (config) {
48
+ OTLPExporterBrowserProxy.prototype.getDefaultUrl = function (config) {
53
49
  return typeof config.url === 'string'
54
50
  ? config.url
55
51
  : getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0
@@ -58,7 +54,21 @@ var OTLPMetricExporter = /** @class */ (function (_super) {
58
54
  ? appendResourcePathToUrlIfNotPresent(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
59
55
  : DEFAULT_COLLECTOR_URL;
60
56
  };
61
- return OTLPMetricExporter;
57
+ OTLPExporterBrowserProxy.prototype.convert = function (metrics) {
58
+ return toOTLPExportMetricServiceRequest(metrics[0], this._aggregationTemporality, this);
59
+ };
60
+ return OTLPExporterBrowserProxy;
62
61
  }(OTLPExporterBrowserBase));
62
+ /**
63
+ * Collector Metric Exporter for Web
64
+ */
65
+ var OTLPMetricExporter = /** @class */ (function (_super) {
66
+ __extends(OTLPMetricExporter, _super);
67
+ function OTLPMetricExporter(config) {
68
+ if (config === void 0) { config = defaultOptions; }
69
+ return _super.call(this, new OTLPExporterBrowserProxy(config), config) || this;
70
+ }
71
+ return OTLPMetricExporter;
72
+ }(OTLPMetricExporterBase));
63
73
  export { OTLPMetricExporter };
64
74
  //# 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,uBAAuB,EAAa,mCAAmC,EAAE,MAAM,yCAAyC,CAAC;AAClI,OAAO,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE3D,IAAM,+BAA+B,GAAG,aAAa,CAAC;AACtD,IAAM,qBAAqB,GAAC,2BAAyB,+BAAiC,CAAC;AAEvF;;GAEG;AACH;IACU,sCAGP;IAKD,4BAAY,MAA6C;QAA7C,uBAAA,EAAA,WAA6C;QAAzD,YACE,kBAAM,MAAM,CAAC,SAOd;QAXD,+BAA+B;QACd,gBAAU,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC;QAI3D,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,oCAAO,GAAP,UACE,OAAuB;QAEvB,OAAO,gCAAgC,CACrC,OAAO,EACP,IAAI,CAAC,UAAU,EACf,IAAI,CACL,CAAC;IACJ,CAAC;IAED,0CAAa,GAAb,UAAc,MAAwC;QACpD,OAAO,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ;YACnC,CAAC,CAAC,MAAM,CAAC,GAAG;YACZ,CAAC,CAAC,MAAM,EAAE,CAAC,mCAAmC,CAAC,MAAM,GAAG,CAAC;gBACzD,CAAC,CAAC,MAAM,EAAE,CAAC,mCAAmC;gBAC9C,CAAC,CAAC,MAAM,EAAE,CAAC,2BAA2B,CAAC,MAAM,GAAG,CAAC;oBACjD,CAAC,CAAC,mCAAmC,CAAC,MAAM,EAAE,CAAC,2BAA2B,EAAE,+BAA+B,CAAC;oBAC5G,CAAC,CAAC,qBAAqB,CAAC;IAC5B,CAAC;IACH,yBAAC;AAAD,CAAC,AAtCD,CACU,uBAAuB,GAqChC","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 { MetricRecord, MetricExporter } from '@opentelemetry/sdk-metrics-base';\nimport { OTLPExporterBrowserBase, otlpTypes, appendResourcePathToUrlIfNotPresent } from '@opentelemetry/exporter-trace-otlp-http';\nimport { toOTLPExportMetricServiceRequest } from '../../transformMetrics';\nimport { getEnv, baggageUtils } from '@opentelemetry/core';\n\nconst DEFAULT_COLLECTOR_RESOURCE_PATH = '/v1/metrics';\nconst DEFAULT_COLLECTOR_URL=`http://localhost:55681${DEFAULT_COLLECTOR_RESOURCE_PATH}`;\n\n/**\n * Collector Metric Exporter for Web\n */\nexport class OTLPMetricExporter\n extends OTLPExporterBrowserBase<\n MetricRecord,\n otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest\n >\n implements MetricExporter {\n // Converts time to nanoseconds\n private readonly _startTime = new Date().getTime() * 1000000;\n\n constructor(config: otlpTypes.OTLPExporterConfigBase = {}) {\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(\n metrics: MetricRecord[]\n ): otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest {\n return toOTLPExportMetricServiceRequest(\n metrics,\n this._startTime,\n this\n );\n }\n\n getDefaultUrl(config: otlpTypes.OTLPExporterConfigBase): string {\n return typeof config.url === 'string'\n ? config.url\n : getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0\n ? getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT\n : getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0\n ? appendResourcePathToUrlIfNotPresent(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)\n : DEFAULT_COLLECTOR_URL;\n }\n}\n"]}
1
+ {"version":3,"file":"OTLPMetricExporter.js","sourceRoot":"","sources":["../../../../src/platform/browser/OTLPMetricExporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAMH,OAAO,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,cAAc,EAA6B,MAAM,iCAAiC,CAAC;AACxH,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EACL,mCAAmC,EACnC,uBAAuB,EAExB,MAAM,mCAAmC,CAAC;AAE3C,IAAM,+BAA+B,GAAG,aAAa,CAAC;AACtD,IAAM,qBAAqB,GAAG,0BAAwB,+BAAiC,CAAC;AAExF;IAAuC,4CACyC;IAG9E,kCAAY,MAA2E;QAA3E,uBAAA,EAAA,uBAA2E;;QAAvF,YACE,kBAAM,MAAM,CAAC,SAQd;QAPC,KAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,CAC3B,KAAI,CAAC,QAAQ,EACb,YAAY,CAAC,uBAAuB,CAClC,MAAM,EAAE,CAAC,kCAAkC,CAC5C,CACF,CAAC;QACF,KAAI,CAAC,uBAAuB,GAAG,MAAA,MAAM,CAAC,sBAAsB,mCAAI,0BAA0B,CAAC;;IAC7F,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,MAAM,EAAE,CAAC,mCAAmC;gBAC9C,CAAC,CAAC,MAAM,EAAE,CAAC,2BAA2B,CAAC,MAAM,GAAG,CAAC;oBAC/C,CAAC,CAAC,mCAAmC,CAAC,MAAM,EAAE,CAAC,2BAA2B,EAAE,+BAA+B,CAAC;oBAC5G,CAAC,CAAC,qBAAqB,CAAC;IAChC,CAAC;IAED,0CAAO,GAAP,UACE,OAA0B;QAE1B,OAAO,gCAAgC,CACrC,OAAO,CAAC,CAAC,CAAC,EACV,IAAI,CAAC,uBAAuB,EAC5B,IAAI,CACL,CAAC;IACJ,CAAC;IACH,+BAAC;AAAD,CAAC,AAlCD,CAAuC,uBAAuB,GAkC7D;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 { AggregationTemporality, ResourceMetrics } from '@opentelemetry/sdk-metrics-base';\nimport {\n otlpTypes\n} from '@opentelemetry/exporter-trace-otlp-http';\nimport { toOTLPExportMetricServiceRequest } from '../../transformMetrics';\nimport { baggageUtils, getEnv } from '@opentelemetry/core';\nimport { defaultExporterTemporality, defaultOptions, OTLPMetricExporterOptions } from '../../OTLPMetricExporterOptions';\nimport { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';\nimport {\n appendResourcePathToUrlIfNotPresent,\n OTLPExporterBrowserBase,\n OTLPExporterConfigBase\n} from '@opentelemetry/otlp-exporter-base';\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,\n otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest> {\n protected readonly _aggregationTemporality: AggregationTemporality;\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 this._aggregationTemporality = config.aggregationTemporality ?? defaultExporterTemporality;\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 ? getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT\n : getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0\n ? appendResourcePathToUrlIfNotPresent(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)\n : DEFAULT_COLLECTOR_URL;\n }\n\n convert(\n metrics: ResourceMetrics[]\n ): otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest {\n return toOTLPExportMetricServiceRequest(\n metrics[0],\n this._aggregationTemporality,\n this\n );\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,19 @@
1
- import { MetricRecord, MetricExporter } from '@opentelemetry/sdk-metrics-base';
2
- import { OTLPExporterNodeBase, OTLPExporterNodeConfigBase, otlpTypes } from '@opentelemetry/exporter-trace-otlp-http';
1
+ import { ResourceMetrics, AggregationTemporality } from '@opentelemetry/sdk-metrics-base';
2
+ import { otlpTypes } from '@opentelemetry/exporter-trace-otlp-http';
3
+ import { OTLPMetricExporterOptions } from '../../OTLPMetricExporterOptions';
4
+ import { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';
5
+ import { OTLPExporterNodeBase, OTLPExporterNodeConfigBase } from '@opentelemetry/otlp-exporter-base';
6
+ declare class OTLPExporterNodeProxy extends OTLPExporterNodeBase<ResourceMetrics, otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest> {
7
+ protected readonly _aggregationTemporality: AggregationTemporality;
8
+ constructor(config?: OTLPExporterNodeConfigBase & OTLPMetricExporterOptions);
9
+ convert(metrics: ResourceMetrics[]): otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest;
10
+ getDefaultUrl(config: OTLPExporterNodeConfigBase): string;
11
+ }
3
12
  /**
4
13
  * Collector Metric Exporter for Node
5
14
  */
6
- export declare class OTLPMetricExporter extends OTLPExporterNodeBase<MetricRecord, otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest> implements MetricExporter {
7
- protected readonly _startTime: number;
8
- constructor(config?: OTLPExporterNodeConfigBase);
9
- convert(metrics: MetricRecord[]): otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest;
10
- getDefaultUrl(config: OTLPExporterNodeConfigBase): string;
15
+ export declare class OTLPMetricExporter extends OTLPMetricExporterBase<OTLPExporterNodeProxy> {
16
+ constructor(config?: OTLPExporterNodeConfigBase & OTLPMetricExporterOptions);
11
17
  }
18
+ export {};
12
19
  //# sourceMappingURL=OTLPMetricExporter.d.ts.map
@@ -28,28 +28,27 @@ 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
31
  import { toOTLPExportMetricServiceRequest } from '../../transformMetrics';
33
32
  import { getEnv, baggageUtils } from '@opentelemetry/core';
33
+ import { defaultExporterTemporality, defaultOptions } from '../../OTLPMetricExporterOptions';
34
+ import { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';
35
+ import { appendResourcePathToUrlIfNotPresent, OTLPExporterNodeBase } from '@opentelemetry/otlp-exporter-base';
34
36
  var DEFAULT_COLLECTOR_RESOURCE_PATH = '/v1/metrics';
35
- var DEFAULT_COLLECTOR_URL = "http://localhost:55681" + DEFAULT_COLLECTOR_RESOURCE_PATH;
36
- /**
37
- * Collector Metric Exporter for Node
38
- */
39
- var OTLPMetricExporter = /** @class */ (function (_super) {
40
- __extends(OTLPMetricExporter, _super);
41
- function OTLPMetricExporter(config) {
42
- if (config === void 0) { config = {}; }
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; }
42
+ var _a;
43
43
  var _this = _super.call(this, config) || this;
44
- // Converts time to nanoseconds
45
- _this._startTime = new Date().getTime() * 1000000;
46
44
  _this.headers = Object.assign(_this.headers, baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_METRICS_HEADERS));
45
+ _this._aggregationTemporality = (_a = config.aggregationTemporality) !== null && _a !== void 0 ? _a : defaultExporterTemporality;
47
46
  return _this;
48
47
  }
49
- OTLPMetricExporter.prototype.convert = function (metrics) {
50
- return toOTLPExportMetricServiceRequest(metrics, this._startTime, this);
48
+ OTLPExporterNodeProxy.prototype.convert = function (metrics) {
49
+ return toOTLPExportMetricServiceRequest(metrics[0], this._aggregationTemporality, this);
51
50
  };
52
- OTLPMetricExporter.prototype.getDefaultUrl = function (config) {
51
+ OTLPExporterNodeProxy.prototype.getDefaultUrl = function (config) {
53
52
  return typeof config.url === 'string'
54
53
  ? config.url
55
54
  : getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0
@@ -58,7 +57,18 @@ var OTLPMetricExporter = /** @class */ (function (_super) {
58
57
  ? appendResourcePathToUrlIfNotPresent(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
59
58
  : DEFAULT_COLLECTOR_URL;
60
59
  };
61
- return OTLPMetricExporter;
60
+ return OTLPExporterNodeProxy;
62
61
  }(OTLPExporterNodeBase));
62
+ /**
63
+ * Collector Metric Exporter for Node
64
+ */
65
+ var OTLPMetricExporter = /** @class */ (function (_super) {
66
+ __extends(OTLPMetricExporter, _super);
67
+ function OTLPMetricExporter(config) {
68
+ if (config === void 0) { config = defaultOptions; }
69
+ return _super.call(this, new OTLPExporterNodeProxy(config), config) || this;
70
+ }
71
+ return OTLPMetricExporter;
72
+ }(OTLPMetricExporterBase));
63
73
  export { OTLPMetricExporter };
64
74
  //# 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,EACL,oBAAoB,EAGpB,mCAAmC,EACpC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE3D,IAAM,+BAA+B,GAAG,aAAa,CAAC;AACtD,IAAM,qBAAqB,GAAC,2BAAyB,+BAAiC,CAAC;AAEvF;;GAEG;AACH;IACU,sCAGP;IAKD,4BAAY,MAAuC;QAAvC,uBAAA,EAAA,WAAuC;QAAnD,YACE,kBAAM,MAAM,CAAC,SAOd;QAXD,+BAA+B;QACZ,gBAAU,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC;QAI7D,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,oCAAO,GAAP,UACE,OAAuB;QAEvB,OAAO,gCAAgC,CACrC,OAAO,EACP,IAAI,CAAC,UAAU,EACf,IAAI,CACL,CAAC;IACJ,CAAC;IAED,0CAAa,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;gBACzD,CAAC,CAAC,MAAM,EAAE,CAAC,mCAAmC;gBAC9C,CAAC,CAAC,MAAM,EAAE,CAAC,2BAA2B,CAAC,MAAM,GAAG,CAAC;oBACjD,CAAC,CAAC,mCAAmC,CAAC,MAAM,EAAE,CAAC,2BAA2B,EAAE,+BAA+B,CAAC;oBAC5G,CAAC,CAAC,qBAAqB,CAAC;IAC5B,CAAC;IACH,yBAAC;AAAD,CAAC,AAtCD,CACU,oBAAoB,GAqC7B","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 { MetricRecord, MetricExporter } from '@opentelemetry/sdk-metrics-base';\nimport { \n OTLPExporterNodeBase,\n OTLPExporterNodeConfigBase,\n otlpTypes,\n appendResourcePathToUrlIfNotPresent\n} from '@opentelemetry/exporter-trace-otlp-http';\nimport { toOTLPExportMetricServiceRequest } from '../../transformMetrics';\nimport { getEnv, baggageUtils } from '@opentelemetry/core';\n\nconst DEFAULT_COLLECTOR_RESOURCE_PATH = '/v1/metrics';\nconst DEFAULT_COLLECTOR_URL=`http://localhost:55681${DEFAULT_COLLECTOR_RESOURCE_PATH}`;\n\n/**\n * Collector Metric Exporter for Node\n */\nexport class OTLPMetricExporter\n extends OTLPExporterNodeBase<\n MetricRecord,\n otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest\n >\n implements MetricExporter {\n // Converts time to nanoseconds\n protected readonly _startTime = new Date().getTime() * 1000000;\n\n constructor(config: OTLPExporterNodeConfigBase = {}) {\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(\n metrics: MetricRecord[]\n ): otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest {\n return toOTLPExportMetricServiceRequest(\n metrics,\n this._startTime,\n this\n );\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 ? getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT\n : getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0\n ? appendResourcePathToUrlIfNotPresent(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)\n : DEFAULT_COLLECTOR_URL;\n }\n}\n"]}
1
+ {"version":3,"file":"OTLPMetricExporter.js","sourceRoot":"","sources":["../../../../src/platform/node/OTLPMetricExporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAMH,OAAO,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,cAAc,EAA6B,MAAM,iCAAiC,CAAC;AACxH,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EACL,mCAAmC,EACnC,oBAAoB,EAErB,MAAM,mCAAmC,CAAC;AAE3C,IAAM,+BAA+B,GAAG,aAAa,CAAC;AACtD,IAAM,qBAAqB,GAAG,0BAAwB,+BAAiC,CAAC;AAExF;IAAoC,yCAC4C;IAG9E,+BAAY,MAA+E;QAA/E,uBAAA,EAAA,uBAA+E;;QAA3F,YACE,kBAAM,MAAM,CAAC,SAQd;QAPC,KAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAC1B,KAAI,CAAC,OAAO,EACZ,YAAY,CAAC,uBAAuB,CAClC,MAAM,EAAE,CAAC,kCAAkC,CAC5C,CACF,CAAC;QACF,KAAI,CAAC,uBAAuB,GAAG,MAAA,MAAM,CAAC,sBAAsB,mCAAI,0BAA0B,CAAC;;IAC7F,CAAC;IAED,uCAAO,GAAP,UACE,OAA0B;QAE1B,OAAO,gCAAgC,CACrC,OAAO,CAAC,CAAC,CAAC,EACV,IAAI,CAAC,uBAAuB,EAC5B,IAAI,CACL,CAAC;IACJ,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,MAAM,EAAE,CAAC,mCAAmC;gBAC9C,CAAC,CAAC,MAAM,EAAE,CAAC,2BAA2B,CAAC,MAAM,GAAG,CAAC;oBAC/C,CAAC,CAAC,mCAAmC,CAAC,MAAM,EAAE,CAAC,2BAA2B,EAAE,+BAA+B,CAAC;oBAC5G,CAAC,CAAC,qBAAqB,CAAC;IAChC,CAAC;IACH,4BAAC;AAAD,CAAC,AAlCD,CAAoC,oBAAoB,GAkCvD;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, AggregationTemporality } from '@opentelemetry/sdk-metrics-base';\nimport {\n otlpTypes,\n} from '@opentelemetry/exporter-trace-otlp-http';\nimport { toOTLPExportMetricServiceRequest } from '../../transformMetrics';\nimport { getEnv, baggageUtils} from '@opentelemetry/core';\nimport { defaultExporterTemporality, defaultOptions, OTLPMetricExporterOptions } from '../../OTLPMetricExporterOptions';\nimport { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';\nimport {\n appendResourcePathToUrlIfNotPresent,\n OTLPExporterNodeBase,\n OTLPExporterNodeConfigBase\n} from '@opentelemetry/otlp-exporter-base';\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,\n otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest> {\n protected readonly _aggregationTemporality: AggregationTemporality;\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 this._aggregationTemporality = config.aggregationTemporality ?? defaultExporterTemporality;\n }\n\n convert(\n metrics: ResourceMetrics[]\n ): otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest {\n return toOTLPExportMetricServiceRequest(\n metrics[0],\n this._aggregationTemporality,\n this\n );\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 ? getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT\n : getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0\n ? appendResourcePathToUrlIfNotPresent(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"]}
@@ -1,47 +1,38 @@
1
- import { Attributes as Labels } from '@opentelemetry/api-metrics';
2
- import * as core from '@opentelemetry/core';
3
- import { MetricRecord } from '@opentelemetry/sdk-metrics-base';
4
- import { Resource } from '@opentelemetry/resources';
5
- import { OTLPExporterBase, otlpTypes } from '@opentelemetry/exporter-trace-otlp-http';
1
+ import { SpanAttributes } from '@opentelemetry/api';
2
+ import { otlpTypes } from '@opentelemetry/exporter-trace-otlp-http';
3
+ import { OTLPExporterBase, OTLPExporterConfigBase } from '@opentelemetry/otlp-exporter-base';
4
+ import { AggregationTemporality, MetricData, ResourceMetrics } from '@opentelemetry/sdk-metrics-base';
6
5
  /**
7
- * Converts labels
8
- * @param labels
6
+ * Converts {@link SpanAttributes} to a collector-compatible format.
7
+ * @param attributes
9
8
  */
10
- export declare function toCollectorLabels(labels: Labels): otlpTypes.opentelemetryProto.common.v1.StringKeyValue[];
9
+ export declare function toCollectorAttributes(attributes: SpanAttributes): otlpTypes.opentelemetryProto.common.v1.StringKeyValue[];
11
10
  /**
12
- * Given a MetricDescriptor, return its temporality in a compatible format with the collector
13
- * @param descriptor
11
+ * Convert {@link AggregationTemporality} to a collector-compatible format.
12
+ * @param aggregationTemporality
14
13
  */
15
- export declare function toAggregationTemporality(metric: MetricRecord): otlpTypes.opentelemetryProto.metrics.v1.AggregationTemporality;
14
+ export declare function toAggregationTemporality(aggregationTemporality: AggregationTemporality): otlpTypes.opentelemetryProto.metrics.v1.AggregationTemporality;
16
15
  /**
17
- * Returns an DataPoint which can have integers or double values
18
- * @param metric
19
- * @param startTime
16
+ * Convert {@link MetricData} of {@link DataPointType.SINGULAR} to a collector-compatible format.
17
+ * @param metricData
20
18
  */
21
- export declare function toDataPoint(metric: MetricRecord, startTime: number): otlpTypes.opentelemetryProto.metrics.v1.DataPoint;
19
+ export declare function toSingularDataPoints(metricData: MetricData): otlpTypes.opentelemetryProto.metrics.v1.DataPoint[];
22
20
  /**
23
- * Returns a HistogramPoint to the collector
24
- * @param metric
25
- * @param startTime
21
+ * Convert {@link MetricData} of {@link DataPointType.HISTOGRAM} to a collector-compatible format.
22
+ * @param metricData
26
23
  */
27
- export declare function toHistogramPoint(metric: MetricRecord, startTime: number): otlpTypes.opentelemetryProto.metrics.v1.HistogramDataPoint;
24
+ export declare function toHistogramDataPoints(metricData: MetricData): otlpTypes.opentelemetryProto.metrics.v1.HistogramDataPoint[];
28
25
  /**
29
- * Converts a metric to be compatible with the collector
30
- * @param metric
31
- * @param startTime start time in nanoseconds
26
+ * Converts {@link MetricData} to a collector-compatible format.
27
+ * @param metricData
28
+ * @param aggregationTemporality
32
29
  */
33
- export declare function toCollectorMetric(metric: MetricRecord, startTime: number): otlpTypes.opentelemetryProto.metrics.v1.Metric;
30
+ export declare function toCollectorMetric(metricData: MetricData, aggregationTemporality: AggregationTemporality): otlpTypes.opentelemetryProto.metrics.v1.Metric;
34
31
  /**
35
32
  * Prepares metric service request to be sent to collector
36
33
  * @param metrics metrics
37
- * @param startTime start time of the metric in nanoseconds
38
- * @param collectorMetricExporterBase
34
+ * @param aggregationTemporality
35
+ * @param collectorExporterBase
39
36
  */
40
- export declare function toOTLPExportMetricServiceRequest<T extends otlpTypes.OTLPExporterConfigBase>(metrics: MetricRecord[], startTime: number, collectorExporterBase: OTLPExporterBase<T, MetricRecord, otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest>): otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest;
41
- /**
42
- * Takes an array of metrics and groups them by resource and instrumentation
43
- * library
44
- * @param metrics metrics
45
- */
46
- export declare function groupMetricsByResourceAndLibrary(metrics: MetricRecord[]): Map<Resource, Map<core.InstrumentationLibrary, MetricRecord[]>>;
37
+ export declare function toOTLPExportMetricServiceRequest<T extends OTLPExporterConfigBase>(metrics: ResourceMetrics, aggregationTemporality: AggregationTemporality, collectorExporterBase: OTLPExporterBase<T, ResourceMetrics, otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest>): otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest;
47
38
  //# sourceMappingURL=transformMetrics.d.ts.map