@opentelemetry/exporter-metrics-otlp-http 0.28.0 → 0.29.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 (65) hide show
  1. package/README.md +22 -21
  2. package/build/esm/OTLPMetricExporterBase.d.ts +7 -5
  3. package/build/esm/OTLPMetricExporterBase.js +23 -5
  4. package/build/esm/OTLPMetricExporterBase.js.map +1 -1
  5. package/build/esm/OTLPMetricExporterOptions.d.ts +2 -2
  6. package/build/esm/OTLPMetricExporterOptions.js +1 -1
  7. package/build/esm/OTLPMetricExporterOptions.js.map +1 -1
  8. package/build/esm/index.d.ts +0 -1
  9. package/build/esm/index.js +0 -1
  10. package/build/esm/index.js.map +1 -1
  11. package/build/esm/platform/browser/OTLPMetricExporter.d.ts +4 -5
  12. package/build/esm/platform/browser/OTLPMetricExporter.js +8 -10
  13. package/build/esm/platform/browser/OTLPMetricExporter.js.map +1 -1
  14. package/build/esm/platform/node/OTLPMetricExporter.d.ts +4 -5
  15. package/build/esm/platform/node/OTLPMetricExporter.js +8 -10
  16. package/build/esm/platform/node/OTLPMetricExporter.js.map +1 -1
  17. package/build/esm/version.d.ts +1 -1
  18. package/build/esm/version.js +1 -1
  19. package/build/esm/version.js.map +1 -1
  20. package/build/esnext/OTLPMetricExporterBase.d.ts +7 -5
  21. package/build/esnext/OTLPMetricExporterBase.js +23 -5
  22. package/build/esnext/OTLPMetricExporterBase.js.map +1 -1
  23. package/build/esnext/OTLPMetricExporterOptions.d.ts +2 -2
  24. package/build/esnext/OTLPMetricExporterOptions.js +1 -1
  25. package/build/esnext/OTLPMetricExporterOptions.js.map +1 -1
  26. package/build/esnext/index.d.ts +0 -1
  27. package/build/esnext/index.js +0 -1
  28. package/build/esnext/index.js.map +1 -1
  29. package/build/esnext/platform/browser/OTLPMetricExporter.d.ts +4 -5
  30. package/build/esnext/platform/browser/OTLPMetricExporter.js +8 -10
  31. package/build/esnext/platform/browser/OTLPMetricExporter.js.map +1 -1
  32. package/build/esnext/platform/node/OTLPMetricExporter.d.ts +4 -5
  33. package/build/esnext/platform/node/OTLPMetricExporter.js +8 -10
  34. package/build/esnext/platform/node/OTLPMetricExporter.js.map +1 -1
  35. package/build/esnext/version.d.ts +1 -1
  36. package/build/esnext/version.js +1 -1
  37. package/build/esnext/version.js.map +1 -1
  38. package/build/src/OTLPMetricExporterBase.d.ts +7 -5
  39. package/build/src/OTLPMetricExporterBase.js +25 -5
  40. package/build/src/OTLPMetricExporterBase.js.map +1 -1
  41. package/build/src/OTLPMetricExporterOptions.d.ts +2 -2
  42. package/build/src/OTLPMetricExporterOptions.js +1 -1
  43. package/build/src/OTLPMetricExporterOptions.js.map +1 -1
  44. package/build/src/index.d.ts +0 -1
  45. package/build/src/index.js +0 -3
  46. package/build/src/index.js.map +1 -1
  47. package/build/src/platform/browser/OTLPMetricExporter.d.ts +4 -5
  48. package/build/src/platform/browser/OTLPMetricExporter.js +6 -8
  49. package/build/src/platform/browser/OTLPMetricExporter.js.map +1 -1
  50. package/build/src/platform/node/OTLPMetricExporter.d.ts +4 -5
  51. package/build/src/platform/node/OTLPMetricExporter.js +6 -8
  52. package/build/src/platform/node/OTLPMetricExporter.js.map +1 -1
  53. package/build/src/version.d.ts +1 -1
  54. package/build/src/version.js +1 -1
  55. package/build/src/version.js.map +1 -1
  56. package/package.json +9 -9
  57. package/build/esm/transformMetrics.d.ts +0 -38
  58. package/build/esm/transformMetrics.js +0 -184
  59. package/build/esm/transformMetrics.js.map +0 -1
  60. package/build/esnext/transformMetrics.d.ts +0 -38
  61. package/build/esnext/transformMetrics.js +0 -167
  62. package/build/esnext/transformMetrics.js.map +0 -1
  63. package/build/src/transformMetrics.d.ts +0 -38
  64. package/build/src/transformMetrics.js +0 -176
  65. package/build/src/transformMetrics.js.map +0 -1
package/README.md CHANGED
@@ -3,7 +3,8 @@
3
3
  [![NPM Published Version][npm-img]][npm-url]
4
4
  [![Apache License][license-image]][license-image]
5
5
 
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**.
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`.
7
8
 
8
9
  ## Installation
9
10
 
@@ -22,7 +23,7 @@ To see sample code and documentation for the traces exporter, visit the [Collect
22
23
  The OTLPMetricExporter in Web expects the endpoint to end in `/v1/metrics`.
23
24
 
24
25
  ```js
25
- import { MeterProvider } from '@opentelemetry/sdk-metrics-base';
26
+ import { MeterProvider, PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics-base';
26
27
  import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';
27
28
  const collectorOptions = {
28
29
  url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:4318/v1/metrics
@@ -30,37 +31,38 @@ const collectorOptions = {
30
31
  concurrencyLimit: 1, // an optional limit on pending requests
31
32
  };
32
33
  const exporter = new OTLPMetricExporter(collectorOptions);
34
+ const meterProvider = new MeterProvider({});
33
35
 
34
- // Register the exporter
35
- const meter = new MeterProvider({
36
- exporter,
37
- interval: 60000,
38
- }).getMeter('example-meter');
36
+ meterProvider.addMetricReader(new PeriodicExportingMetricReader({
37
+ exporter: metricExporter,
38
+ exportIntervalMillis: 1000,
39
+ }));
39
40
 
40
41
  // Now, start recording data
42
+ const meter = meterProvider.getMeter('example-meter');
41
43
  const counter = meter.createCounter('metric_name');
42
44
  counter.add(10, { 'key': 'value' });
43
-
44
45
  ```
45
46
 
46
47
  ## Metrics in Node
47
48
 
48
49
  ```js
49
- const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
50
+ const { MeterProvider, PeriodicExportingMetricReader } = require('@opentelemetry/sdk-metrics-base');
50
51
  const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-http');
51
52
  const collectorOptions = {
52
53
  url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:4318/v1/metrics
53
54
  concurrencyLimit: 1, // an optional limit on pending requests
54
55
  };
55
56
  const exporter = new OTLPMetricExporter(collectorOptions);
57
+ const meterProvider = new MeterProvider({});
56
58
 
57
- // Register the exporter
58
- const meter = new MeterProvider({
59
- exporter,
60
- interval: 60000,
61
- }).getMeter('example-meter');
59
+ meterProvider.addMetricReader(new PeriodicExportingMetricReader({
60
+ exporter: metricExporter,
61
+ exportIntervalMillis: 1000,
62
+ }));
62
63
 
63
64
  // Now, start recording data
65
+ const meter = meterProvider.getMeter('example-meter');
64
66
  const counter = meter.createCounter('metric_name');
65
67
  counter.add(10, { 'key': 'value' });
66
68
 
@@ -79,16 +81,16 @@ For exporting metrics with PROTOBUF please check [exporter-metrics-otlp-proto][n
79
81
  Instead of providing options to `OTLPMetricExporter` and `OTLPTraceExporter` explicitly, environment variables may be provided instead.
80
82
 
81
83
  ```sh
82
- OTEL_EXPORTER_OTLP_ENDPOINT=https://localhost:4317
84
+ OTEL_EXPORTER_OTLP_ENDPOINT=https://localhost:4318
83
85
  # this will automatically append the version and signal path
84
- # e.g. https://localhost:4317/v1/traces for `OTLPTraceExporter` and https://localhost:4317/v1/metrics for `OTLPMetricExporter`
86
+ # e.g. https://localhost:4318/v1/traces for `OTLPTraceExporter` and https://localhost:4318/v1/metrics for `OTLPMetricExporter`
85
87
  ```
86
88
 
87
89
  If the trace and metric exporter endpoints have different providers, the env var for per-signal endpoints are available to use
88
90
 
89
91
  ```sh
90
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://trace-service:4317/v1/traces
91
- OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=https://metric-service:4317/v1/metrics
92
+ OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://trace-service:4318/v1/traces
93
+ OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=https://metric-service:4318/v1/metrics
92
94
  # version and signal needs to be explicit
93
95
  ```
94
96
 
@@ -98,9 +100,8 @@ For more details, see [OpenTelemetry Specification on Protocol Exporter][opentel
98
100
 
99
101
  ## Running opentelemetry-collector locally to see the metrics
100
102
 
101
- 1. Go to examples/otlp-exporter-node
102
- 2. run `npm run docker:start`
103
- 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.
104
105
 
105
106
  ## Useful links
106
107
 
@@ -1,15 +1,17 @@
1
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';
2
+ import { AggregationTemporality, AggregationTemporalitySelector, InstrumentType, PushMetricExporter, ResourceMetrics } from '@opentelemetry/sdk-metrics-base';
4
3
  import { OTLPMetricExporterOptions } from './OTLPMetricExporterOptions';
5
4
  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 {
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 {
7
9
  _otlpExporter: T;
8
- protected _preferredAggregationTemporality: AggregationTemporality;
10
+ protected _aggregationTemporalitySelector: AggregationTemporalitySelector;
9
11
  constructor(exporter: T, config?: OTLPMetricExporterOptions);
10
12
  export(metrics: ResourceMetrics, resultCallback: (result: ExportResult) => void): void;
11
13
  shutdown(): Promise<void>;
12
14
  forceFlush(): Promise<void>;
13
- getPreferredAggregationTemporality(): AggregationTemporality;
15
+ selectAggregationTemporality(instrumentType: InstrumentType): AggregationTemporality;
14
16
  }
15
17
  //# sourceMappingURL=OTLPMetricExporterBase.d.ts.map
@@ -49,14 +49,32 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
49
49
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
50
  }
51
51
  };
52
- import { AggregationTemporality } from '@opentelemetry/sdk-metrics-base';
52
+ import { AggregationTemporality, InstrumentType } from '@opentelemetry/sdk-metrics-base';
53
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
+ }
54
73
  var OTLPMetricExporterBase = /** @class */ (function () {
55
74
  function OTLPMetricExporterBase(exporter, config) {
56
75
  if (config === void 0) { config = defaultOptions; }
57
- var _a;
58
76
  this._otlpExporter = exporter;
59
- this._preferredAggregationTemporality = (_a = config.aggregationTemporality) !== null && _a !== void 0 ? _a : AggregationTemporality.CUMULATIVE;
77
+ this._aggregationTemporalitySelector = chooseTemporalitySelector(config.temporalityPreference);
60
78
  }
61
79
  OTLPMetricExporterBase.prototype.export = function (metrics, resultCallback) {
62
80
  this._otlpExporter.export([metrics], resultCallback);
@@ -76,8 +94,8 @@ var OTLPMetricExporterBase = /** @class */ (function () {
76
94
  OTLPMetricExporterBase.prototype.forceFlush = function () {
77
95
  return Promise.resolve();
78
96
  };
79
- OTLPMetricExporterBase.prototype.getPreferredAggregationTemporality = function () {
80
- return this._preferredAggregationTemporality;
97
+ OTLPMetricExporterBase.prototype.selectAggregationTemporality = function (instrumentType) {
98
+ return this._aggregationTemporalitySelector(instrumentType);
81
99
  };
82
100
  return OTLPMetricExporterBase;
83
101
  }());
@@ -1 +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"]}
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"]}
@@ -1,10 +1,10 @@
1
1
  import { AggregationTemporality } from '@opentelemetry/sdk-metrics-base';
2
2
  import { OTLPExporterConfigBase } from '@opentelemetry/otlp-exporter-base';
3
3
  export interface OTLPMetricExporterOptions extends OTLPExporterConfigBase {
4
- aggregationTemporality?: AggregationTemporality;
4
+ temporalityPreference?: AggregationTemporality;
5
5
  }
6
6
  export declare const defaultExporterTemporality = AggregationTemporality.CUMULATIVE;
7
7
  export declare const defaultOptions: {
8
- aggregationTemporality: AggregationTemporality;
8
+ temporalityPreference: AggregationTemporality;
9
9
  };
10
10
  //# sourceMappingURL=OTLPMetricExporterOptions.d.ts.map
@@ -15,5 +15,5 @@
15
15
  */
16
16
  import { AggregationTemporality } from '@opentelemetry/sdk-metrics-base';
17
17
  export var defaultExporterTemporality = AggregationTemporality.CUMULATIVE;
18
- export var defaultOptions = { aggregationTemporality: defaultExporterTemporality };
18
+ export var defaultOptions = { temporalityPreference: defaultExporterTemporality };
19
19
  //# sourceMappingURL=OTLPMetricExporterOptions.js.map
@@ -1 +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
+ {"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"]}
@@ -1,5 +1,4 @@
1
1
  export * from './platform';
2
2
  export * from './OTLPMetricExporterOptions';
3
3
  export * from './OTLPMetricExporterBase';
4
- export { toOTLPExportMetricServiceRequest } from './transformMetrics';
5
4
  //# sourceMappingURL=index.d.ts.map
@@ -16,5 +16,4 @@
16
16
  export * from './platform';
17
17
  export * from './OTLPMetricExporterOptions';
18
18
  export * from './OTLPMetricExporterBase';
19
- export { toOTLPExportMetricServiceRequest } from './transformMetrics';
20
19
  //# 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,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
+ {"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,13 +1,12 @@
1
- import { AggregationTemporality, ResourceMetrics } from '@opentelemetry/sdk-metrics-base';
2
- import { otlpTypes } from '@opentelemetry/exporter-trace-otlp-http';
1
+ import { ResourceMetrics } from '@opentelemetry/sdk-metrics-base';
3
2
  import { OTLPMetricExporterOptions } from '../../OTLPMetricExporterOptions';
4
3
  import { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';
5
4
  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;
5
+ import { IExportMetricsServiceRequest } from '@opentelemetry/otlp-transformer';
6
+ declare class OTLPExporterBrowserProxy extends OTLPExporterBrowserBase<ResourceMetrics, IExportMetricsServiceRequest> {
8
7
  constructor(config?: OTLPMetricExporterOptions & OTLPExporterConfigBase);
9
8
  getDefaultUrl(config: OTLPExporterConfigBase): string;
10
- convert(metrics: ResourceMetrics[]): otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest;
9
+ convert(metrics: ResourceMetrics[]): IExportMetricsServiceRequest;
11
10
  }
12
11
  /**
13
12
  * Collector Metric Exporter for Web
@@ -28,34 +28,32 @@ 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 { toOTLPExportMetricServiceRequest } from '../../transformMetrics';
32
31
  import { baggageUtils, getEnv } from '@opentelemetry/core';
33
- import { defaultExporterTemporality, defaultOptions } from '../../OTLPMetricExporterOptions';
32
+ import { defaultOptions } from '../../OTLPMetricExporterOptions';
34
33
  import { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';
35
- import { appendResourcePathToUrlIfNotPresent, OTLPExporterBrowserBase } from '@opentelemetry/otlp-exporter-base';
36
- var DEFAULT_COLLECTOR_RESOURCE_PATH = '/v1/metrics';
37
- var DEFAULT_COLLECTOR_URL = "http://localhost:4318" + DEFAULT_COLLECTOR_RESOURCE_PATH;
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
38
  var OTLPExporterBrowserProxy = /** @class */ (function (_super) {
39
39
  __extends(OTLPExporterBrowserProxy, _super);
40
40
  function OTLPExporterBrowserProxy(config) {
41
41
  if (config === void 0) { config = defaultOptions; }
42
- var _a;
43
42
  var _this = _super.call(this, config) || this;
44
43
  _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;
46
44
  return _this;
47
45
  }
48
46
  OTLPExporterBrowserProxy.prototype.getDefaultUrl = function (config) {
49
47
  return typeof config.url === 'string'
50
48
  ? config.url
51
49
  : getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0
52
- ? getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT
50
+ ? appendRootPathToUrlIfNeeded(getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
53
51
  : getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0
54
- ? appendResourcePathToUrlIfNotPresent(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
52
+ ? appendResourcePathToUrl(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
55
53
  : DEFAULT_COLLECTOR_URL;
56
54
  };
57
55
  OTLPExporterBrowserProxy.prototype.convert = function (metrics) {
58
- return toOTLPExportMetricServiceRequest(metrics[0], this._aggregationTemporality, this);
56
+ return createExportMetricsServiceRequest(metrics);
59
57
  };
60
58
  return OTLPExporterBrowserProxy;
61
59
  }(OTLPExporterBrowserBase));
@@ -1 +1 @@
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
+ {"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,11 @@
1
- import { ResourceMetrics, AggregationTemporality } from '@opentelemetry/sdk-metrics-base';
2
- import { otlpTypes } from '@opentelemetry/exporter-trace-otlp-http';
1
+ import { ResourceMetrics } from '@opentelemetry/sdk-metrics-base';
3
2
  import { OTLPMetricExporterOptions } from '../../OTLPMetricExporterOptions';
4
3
  import { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';
5
4
  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;
5
+ import { IExportMetricsServiceRequest } from '@opentelemetry/otlp-transformer';
6
+ declare class OTLPExporterNodeProxy extends OTLPExporterNodeBase<ResourceMetrics, IExportMetricsServiceRequest> {
8
7
  constructor(config?: OTLPExporterNodeConfigBase & OTLPMetricExporterOptions);
9
- convert(metrics: ResourceMetrics[]): otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest;
8
+ convert(metrics: ResourceMetrics[]): IExportMetricsServiceRequest;
10
9
  getDefaultUrl(config: OTLPExporterNodeConfigBase): string;
11
10
  }
12
11
  /**
@@ -28,33 +28,31 @@ 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 { toOTLPExportMetricServiceRequest } from '../../transformMetrics';
32
31
  import { getEnv, baggageUtils } from '@opentelemetry/core';
33
- import { defaultExporterTemporality, defaultOptions } from '../../OTLPMetricExporterOptions';
32
+ import { defaultOptions } from '../../OTLPMetricExporterOptions';
34
33
  import { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';
35
- import { appendResourcePathToUrlIfNotPresent, OTLPExporterNodeBase } from '@opentelemetry/otlp-exporter-base';
36
- var DEFAULT_COLLECTOR_RESOURCE_PATH = '/v1/metrics';
37
- var DEFAULT_COLLECTOR_URL = "http://localhost:4318" + DEFAULT_COLLECTOR_RESOURCE_PATH;
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
38
  var OTLPExporterNodeProxy = /** @class */ (function (_super) {
39
39
  __extends(OTLPExporterNodeProxy, _super);
40
40
  function OTLPExporterNodeProxy(config) {
41
41
  if (config === void 0) { config = defaultOptions; }
42
- var _a;
43
42
  var _this = _super.call(this, config) || this;
44
43
  _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;
46
44
  return _this;
47
45
  }
48
46
  OTLPExporterNodeProxy.prototype.convert = function (metrics) {
49
- return toOTLPExportMetricServiceRequest(metrics[0], this._aggregationTemporality, this);
47
+ return createExportMetricsServiceRequest(metrics);
50
48
  };
51
49
  OTLPExporterNodeProxy.prototype.getDefaultUrl = function (config) {
52
50
  return typeof config.url === 'string'
53
51
  ? config.url
54
52
  : getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0
55
- ? getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT
53
+ ? appendRootPathToUrlIfNeeded(getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
56
54
  : getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0
57
- ? appendResourcePathToUrlIfNotPresent(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
55
+ ? appendResourcePathToUrl(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
58
56
  : DEFAULT_COLLECTOR_URL;
59
57
  };
60
58
  return OTLPExporterNodeProxy;
@@ -1 +1 @@
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
+ {"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"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.28.0";
1
+ export declare const VERSION = "0.29.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -14,5 +14,5 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // this is autogenerated file, see scripts/version-update.js
17
- export var VERSION = '0.28.0';
17
+ export var VERSION = '0.29.0';
18
18
  //# sourceMappingURL=version.js.map
@@ -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.28.0';\n"]}
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.0';\n"]}
@@ -1,15 +1,17 @@
1
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';
2
+ import { AggregationTemporality, AggregationTemporalitySelector, InstrumentType, PushMetricExporter, ResourceMetrics } from '@opentelemetry/sdk-metrics-base';
4
3
  import { OTLPMetricExporterOptions } from './OTLPMetricExporterOptions';
5
4
  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 {
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 {
7
9
  _otlpExporter: T;
8
- protected _preferredAggregationTemporality: AggregationTemporality;
10
+ protected _aggregationTemporalitySelector: AggregationTemporalitySelector;
9
11
  constructor(exporter: T, config?: OTLPMetricExporterOptions);
10
12
  export(metrics: ResourceMetrics, resultCallback: (result: ExportResult) => void): void;
11
13
  shutdown(): Promise<void>;
12
14
  forceFlush(): Promise<void>;
13
- getPreferredAggregationTemporality(): AggregationTemporality;
15
+ selectAggregationTemporality(instrumentType: InstrumentType): AggregationTemporality;
14
16
  }
15
17
  //# sourceMappingURL=OTLPMetricExporterBase.d.ts.map
@@ -13,13 +13,31 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { AggregationTemporality } from '@opentelemetry/sdk-metrics-base';
16
+ import { AggregationTemporality, InstrumentType } from '@opentelemetry/sdk-metrics-base';
17
17
  import { defaultOptions } from './OTLPMetricExporterOptions';
18
+ export const CumulativeTemporalitySelector = () => AggregationTemporality.CUMULATIVE;
19
+ export const DeltaTemporalitySelector = (instrumentType) => {
20
+ switch (instrumentType) {
21
+ case InstrumentType.COUNTER:
22
+ case InstrumentType.OBSERVABLE_COUNTER:
23
+ case InstrumentType.HISTOGRAM:
24
+ case InstrumentType.OBSERVABLE_GAUGE:
25
+ return AggregationTemporality.DELTA;
26
+ case InstrumentType.UP_DOWN_COUNTER:
27
+ case InstrumentType.OBSERVABLE_UP_DOWN_COUNTER:
28
+ return AggregationTemporality.CUMULATIVE;
29
+ }
30
+ };
31
+ function chooseTemporalitySelector(temporalityPreference) {
32
+ if (temporalityPreference === AggregationTemporality.DELTA) {
33
+ return DeltaTemporalitySelector;
34
+ }
35
+ return CumulativeTemporalitySelector;
36
+ }
18
37
  export class OTLPMetricExporterBase {
19
38
  constructor(exporter, config = defaultOptions) {
20
- var _a;
21
39
  this._otlpExporter = exporter;
22
- this._preferredAggregationTemporality = (_a = config.aggregationTemporality) !== null && _a !== void 0 ? _a : AggregationTemporality.CUMULATIVE;
40
+ this._aggregationTemporalitySelector = chooseTemporalitySelector(config.temporalityPreference);
23
41
  }
24
42
  export(metrics, resultCallback) {
25
43
  this._otlpExporter.export([metrics], resultCallback);
@@ -30,8 +48,8 @@ export class OTLPMetricExporterBase {
30
48
  forceFlush() {
31
49
  return Promise.resolve();
32
50
  }
33
- getPreferredAggregationTemporality() {
34
- return this._preferredAggregationTemporality;
51
+ selectAggregationTemporality(instrumentType) {
52
+ return this._aggregationTemporalitySelector(instrumentType);
35
53
  }
36
54
  }
37
55
  //# sourceMappingURL=OTLPMetricExporterBase.js.map
@@ -1 +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,MAAM,OAAO,sBAAsB;IAOjC,YAAY,QAAW,EACX,SAAoC,cAAc;;QAC5D,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC;QAC9B,IAAI,CAAC,gCAAgC,GAAG,MAAA,MAAM,CAAC,sBAAsB,mCAAI,sBAAsB,CAAC,UAAU,CAAC;IAC7G,CAAC;IAED,MAAM,CAAC,OAAwB,EAAE,cAA8C;QAC7E,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;IACtC,CAAC;IAED,UAAU;QACR,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,kCAAkC;QAChC,OAAO,IAAI,CAAC,gCAAgC,CAAC;IAC/C,CAAC;CAEF","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"]}
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,MAAM,6BAA6B,GAAmC,GAAG,EAAE,CAAC,sBAAsB,CAAC,UAAU,CAAC;AAErH,MAAM,CAAC,MAAM,wBAAwB,GAAmC,CAAC,cAA8B,EAAE,EAAE;IACzG,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,MAAM,OAAO,sBAAsB;IAOjC,YAAY,QAAW,EACrB,SAAoC,cAAc;QAClD,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC;QAC9B,IAAI,CAAC,+BAA+B,GAAG,yBAAyB,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;IACjG,CAAC;IAED,MAAM,CAAC,OAAwB,EAAE,cAA8C;QAC7E,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;IACtC,CAAC;IAED,UAAU;QACR,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,4BAA4B,CAAC,cAA8B;QACzD,OAAO,IAAI,CAAC,+BAA+B,CAAC,cAAc,CAAC,CAAC;IAC9D,CAAC;CACF","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"]}
@@ -1,10 +1,10 @@
1
1
  import { AggregationTemporality } from '@opentelemetry/sdk-metrics-base';
2
2
  import { OTLPExporterConfigBase } from '@opentelemetry/otlp-exporter-base';
3
3
  export interface OTLPMetricExporterOptions extends OTLPExporterConfigBase {
4
- aggregationTemporality?: AggregationTemporality;
4
+ temporalityPreference?: AggregationTemporality;
5
5
  }
6
6
  export declare const defaultExporterTemporality = AggregationTemporality.CUMULATIVE;
7
7
  export declare const defaultOptions: {
8
- aggregationTemporality: AggregationTemporality;
8
+ temporalityPreference: AggregationTemporality;
9
9
  };
10
10
  //# sourceMappingURL=OTLPMetricExporterOptions.d.ts.map
@@ -15,5 +15,5 @@
15
15
  */
16
16
  import { AggregationTemporality } from '@opentelemetry/sdk-metrics-base';
17
17
  export const defaultExporterTemporality = AggregationTemporality.CUMULATIVE;
18
- export const defaultOptions = { aggregationTemporality: defaultExporterTemporality };
18
+ export const defaultOptions = { temporalityPreference: defaultExporterTemporality };
19
19
  //# sourceMappingURL=OTLPMetricExporterOptions.js.map
@@ -1 +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,MAAM,0BAA0B,GAAG,sBAAsB,CAAC,UAAU,CAAC;AAC5E,MAAM,CAAC,MAAM,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
+ {"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,MAAM,0BAA0B,GAAG,sBAAsB,CAAC,UAAU,CAAC;AAC5E,MAAM,CAAC,MAAM,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"]}
@@ -1,5 +1,4 @@
1
1
  export * from './platform';
2
2
  export * from './OTLPMetricExporterOptions';
3
3
  export * from './OTLPMetricExporterBase';
4
- export { toOTLPExportMetricServiceRequest } from './transformMetrics';
5
4
  //# sourceMappingURL=index.d.ts.map
@@ -16,5 +16,4 @@
16
16
  export * from './platform';
17
17
  export * from './OTLPMetricExporterOptions';
18
18
  export * from './OTLPMetricExporterBase';
19
- export { toOTLPExportMetricServiceRequest } from './transformMetrics';
20
19
  //# 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,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
+ {"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"]}