@opentelemetry/exporter-metrics-otlp-grpc 0.27.0 → 0.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,11 +1,10 @@
1
1
  # OpenTelemetry Collector Metrics Exporter for node with grpc
2
2
 
3
3
  [![NPM Published Version][npm-img]][npm-url]
4
- [![dependencies][dependencies-image]][dependencies-url]
5
- [![devDependencies][devDependencies-image]][devDependencies-url]
6
4
  [![Apache License][license-image]][license-image]
7
5
 
8
- This module provides exporter for web and node to be used with [opentelemetry-collector][opentelemetry-collector-url] - 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.16 <=0.50`.
9
8
 
10
9
  ## Installation
11
10
 
@@ -21,37 +20,55 @@ To see sample code and documentation for the traces exporter, as well as instruc
21
20
 
22
21
  ## Metrics in Node - GRPC
23
22
 
24
- The OTLPTraceExporter in Node expects the URL to only be the hostname. It will not work with `/v1/metrics`. All options that work with trace also work with metrics.
23
+ The OTLPMetricsExporter in Node expects the URL to only be the hostname. It will not work with `/v1/metrics`. All options that work with trace also work with metrics.
25
24
 
26
25
  ```js
27
- const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
26
+ const { MeterProvider, PeriodicExportingMetricReader } = require('@opentelemetry/sdk-metrics-base');
28
27
  const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-grpc');
29
28
  const collectorOptions = {
30
- // url is optional and can be omitted - default is grpc://localhost:4317
31
- url: 'grpc://<collector-hostname>:<port>',
29
+ // url is optional and can be omitted - default is http://localhost:4317
30
+ url: 'http://<collector-hostname>:<port>',
32
31
  };
32
+
33
33
  const exporter = new OTLPMetricExporter(collectorOptions);
34
+ const meterProvider = new MeterProvider({});
35
+
36
+ meterProvider.addMetricReader(new PeriodicExportingMetricReader({
37
+ exporter: metricExporter,
38
+ exportIntervalMillis: 1000,
39
+ }));
34
40
 
35
- // Register the exporter
36
- const provider = new MeterProvider({
37
- exporter,
38
- interval: 60000,
39
- })
40
41
  ['SIGINT', 'SIGTERM'].forEach(signal => {
41
- process.on(signal, () => provider.shutdown().catch(console.error));
42
+ process.on(signal, () => meterProvider.shutdown().catch(console.error));
42
43
  });
43
44
 
44
45
  // Now, start recording data
45
- const meter = provider.getMeter('example-meter');
46
+ const meter = meterProvider.getMeter('example-meter');
46
47
  const counter = meter.createCounter('metric_name');
47
48
  counter.add(10, { 'key': 'value' });
48
49
  ```
49
50
 
51
+ ## Environment Variable Configuration
52
+
53
+ | Environment variable | Description |
54
+ |----------------------|-------------|
55
+ | OTEL_EXPORTER_OTLP_METRICS_COMPRESSION | The compression type to use on OTLP metric requests. Options include gzip. By default no compression will be used. |
56
+ | OTEL_EXPORTER_OTLP_COMPRESSION | The compression type to use on OTLP trace, metric, and log requests. Options include gzip. By default no compression will be used. |
57
+ | OTEL_EXPORTER_OTLP_METRICS_INSECURE | Whether to enable client transport security for the exporter's gRPC connection for metric requests. This option only applies to OTLP/gRPC when an endpoint is provided without the http or https scheme. Options include true or false. By default insecure is false which creates a secure connection. |
58
+ | OTEL_EXPORTER_OTLP_INSECURE | Whether to enable client transport security for the exporter's gRPC connection for trace, metric and log requests. This option only applies to OTLP/gRPC when an endpoint is provided without the http or https scheme. Options include true or false. By default insecure is false which creates a secure connection. |
59
+ | OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE | The path to the file containing trusted root certificate to use when verifying an OTLP metric server's TLS credentials. By default the host platform's trusted root certificate is used.|
60
+ | OTEL_EXPORTER_OTLP_CERTIFICATE | The path to the file containing trusted root certificate to use when verifying an OTLP trace, metric, or log server's TLS credentials. By default the host platform's trusted root certificate is used. |
61
+ | OTEL_EXPORTER_OTLP_METRICS_CLIENT_KEY | The path to the file containing private client key to use when verifying an OTLP metric client's TLS credentials. Must provide a client certificate/chain when providing a private client key. By default no client key file is used. |
62
+ | OTEL_EXPORTER_OTLP_CLIENT_KEY | The path to the file containing private client key to use when verifying an OTLP trace, metric or log client's TLS credentials. Must provide a client certificate/chain when providing a private client key. By default no client key file is used. |
63
+ | OTEL_EXPORTER_OTLP_METRICS_CLIENT_CERTIFICATE | The path to the file containing trusted client certificate/chain for clients private key to use when verifying an OTLP metric server's TLS credentials. Must provide a private client key when providing a certificate/chain. By default no chain file is used. |
64
+ | OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE | The path to the file containing trusted client certificate/chain for clients private key to use when verifying an OTLP trace, metric and log server's TLS credentials. Must provide a private client key when providing a certificate/chain. By default no chain file is used. |
65
+
66
+ > Settings configured programmatically take precedence over environment variables. Per-signal environment variables take precedence over non-per-signal environment variables.
67
+
50
68
  ## Running opentelemetry-collector locally to see the metrics
51
69
 
52
- 1. Go to examples/otlp-exporter-node
53
- 2. run `npm run docker:start`
54
- 3. Open page at `http://localhost:9411/zipkin/` to observe the metrics
70
+ 1. Go to `examples/otlp-exporter-node`
71
+ 2. Follow the instructions there to observe the metrics.
55
72
 
56
73
  ## Useful links
57
74
 
@@ -66,12 +83,8 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
66
83
  [discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
67
84
  [license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/LICENSE
68
85
  [license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
69
- [dependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=experimental%2Fpackages%2Fopentelemetry-exporter-metrics-otlp-grpc
70
- [dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=experimental%2Fpackages%2Fopentelemetry-exporter-metrics-otlp-grpc
71
- [devDependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=experimental%2Fpackages%2Fopentelemetry-exporter-metrics-otlp-grpc&type=dev
72
- [devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=experimental%2Fpackages%2Fopentelemetry-exporter-metrics-otlp-grpc&type=dev
73
86
  [npm-url]: https://www.npmjs.com/package/@opentelemetry/exporter-metrics-otlp-grpc
74
87
  [npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fexporter-metrics-otlp-grpc.svg
75
88
  [opentelemetry-collector-url]: https://github.com/open-telemetry/opentelemetry-collector
76
89
  [semconv-resource-service-name]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#service
77
- [trace-exporter-url]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-exporter-trace-otlp-grpc
90
+ [trace-exporter-url]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/exporter-trace-otlp-grpc
@@ -1,15 +1,19 @@
1
- import { otlpTypes } from '@opentelemetry/exporter-trace-otlp-http';
2
- import { MetricRecord, MetricExporter } from '@opentelemetry/sdk-metrics-base';
3
- import { OTLPExporterConfigNode, OTLPExporterNodeBase, ServiceClientType } from '@opentelemetry/exporter-trace-otlp-grpc';
1
+ import { OTLPMetricExporterBase, OTLPMetricExporterOptions } from '@opentelemetry/exporter-metrics-otlp-http';
2
+ import { ResourceMetrics } from '@opentelemetry/sdk-metrics-base';
3
+ import { OTLPGRPCExporterConfigNode, OTLPGRPCExporterNodeBase, ServiceClientType } from '@opentelemetry/otlp-grpc-exporter-base';
4
+ import { IExportMetricsServiceRequest } from '@opentelemetry/otlp-transformer';
5
+ declare class OTLPMetricExporterProxy extends OTLPGRPCExporterNodeBase<ResourceMetrics, IExportMetricsServiceRequest> {
6
+ constructor(config?: OTLPGRPCExporterConfigNode & OTLPMetricExporterOptions);
7
+ getServiceProtoPath(): string;
8
+ getServiceClientType(): ServiceClientType;
9
+ getDefaultUrl(config: OTLPGRPCExporterConfigNode): string;
10
+ convert(metrics: ResourceMetrics[]): IExportMetricsServiceRequest;
11
+ }
4
12
  /**
5
- * OTLP Metric Exporter for Node
13
+ * OTLP-gRPC metric exporter
6
14
  */
7
- export declare class OTLPMetricExporter extends OTLPExporterNodeBase<MetricRecord, otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest> implements MetricExporter {
8
- protected readonly _startTime: number;
9
- constructor(config?: OTLPExporterConfigNode);
10
- convert(metrics: MetricRecord[]): otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest;
11
- getDefaultUrl(config: OTLPExporterConfigNode): string;
12
- getServiceClientType(): ServiceClientType;
13
- getServiceProtoPath(): string;
15
+ export declare class OTLPMetricExporter extends OTLPMetricExporterBase<OTLPMetricExporterProxy> {
16
+ constructor(config?: OTLPGRPCExporterConfigNode & OTLPMetricExporterOptions);
14
17
  }
18
+ export {};
15
19
  //# sourceMappingURL=OTLPMetricExporter.d.ts.map
@@ -17,41 +17,44 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.OTLPMetricExporter = void 0;
19
19
  const exporter_metrics_otlp_http_1 = require("@opentelemetry/exporter-metrics-otlp-http");
20
- const exporter_trace_otlp_grpc_1 = require("@opentelemetry/exporter-trace-otlp-grpc");
20
+ const otlp_grpc_exporter_base_1 = require("@opentelemetry/otlp-grpc-exporter-base");
21
21
  const core_1 = require("@opentelemetry/core");
22
22
  const grpc_js_1 = require("@grpc/grpc-js");
23
- const DEFAULT_COLLECTOR_URL = 'localhost:4317';
24
- /**
25
- * OTLP Metric Exporter for Node
26
- */
27
- class OTLPMetricExporter extends exporter_trace_otlp_grpc_1.OTLPExporterNodeBase {
28
- constructor(config = {}) {
23
+ const otlp_transformer_1 = require("@opentelemetry/otlp-transformer");
24
+ class OTLPMetricExporterProxy extends otlp_grpc_exporter_base_1.OTLPGRPCExporterNodeBase {
25
+ constructor(config = exporter_metrics_otlp_http_1.defaultOptions) {
29
26
  super(config);
30
- // Converts time to nanoseconds
31
- this._startTime = new Date().getTime() * 1000000;
32
- const headers = core_1.baggageUtils.parseKeyPairsIntoRecord(core_1.getEnv().OTEL_EXPORTER_OTLP_METRICS_HEADERS);
27
+ const headers = core_1.baggageUtils.parseKeyPairsIntoRecord((0, core_1.getEnv)().OTEL_EXPORTER_OTLP_METRICS_HEADERS);
33
28
  this.metadata || (this.metadata = new grpc_js_1.Metadata());
34
29
  for (const [k, v] of Object.entries(headers)) {
35
30
  this.metadata.set(k, v);
36
31
  }
37
32
  }
38
- convert(metrics) {
39
- return exporter_metrics_otlp_http_1.toOTLPExportMetricServiceRequest(metrics, this._startTime, this);
33
+ getServiceProtoPath() {
34
+ return 'opentelemetry/proto/collector/metrics/v1/metrics_service.proto';
35
+ }
36
+ getServiceClientType() {
37
+ return otlp_grpc_exporter_base_1.ServiceClientType.METRICS;
40
38
  }
41
39
  getDefaultUrl(config) {
42
40
  return typeof config.url === 'string'
43
- ? exporter_trace_otlp_grpc_1.validateAndNormalizeUrl(config.url)
44
- : core_1.getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0
45
- ? exporter_trace_otlp_grpc_1.validateAndNormalizeUrl(core_1.getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT)
46
- : core_1.getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0
47
- ? exporter_trace_otlp_grpc_1.validateAndNormalizeUrl(core_1.getEnv().OTEL_EXPORTER_OTLP_ENDPOINT)
48
- : DEFAULT_COLLECTOR_URL;
41
+ ? (0, otlp_grpc_exporter_base_1.validateAndNormalizeUrl)(config.url)
42
+ : (0, core_1.getEnv)().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0
43
+ ? (0, otlp_grpc_exporter_base_1.validateAndNormalizeUrl)((0, core_1.getEnv)().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT)
44
+ : (0, core_1.getEnv)().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0
45
+ ? (0, otlp_grpc_exporter_base_1.validateAndNormalizeUrl)((0, core_1.getEnv)().OTEL_EXPORTER_OTLP_ENDPOINT)
46
+ : (0, otlp_grpc_exporter_base_1.validateAndNormalizeUrl)(otlp_grpc_exporter_base_1.DEFAULT_COLLECTOR_URL);
49
47
  }
50
- getServiceClientType() {
51
- return exporter_trace_otlp_grpc_1.ServiceClientType.METRICS;
48
+ convert(metrics) {
49
+ return (0, otlp_transformer_1.createExportMetricsServiceRequest)(metrics);
52
50
  }
53
- getServiceProtoPath() {
54
- return 'opentelemetry/proto/collector/metrics/v1/metrics_service.proto';
51
+ }
52
+ /**
53
+ * OTLP-gRPC metric exporter
54
+ */
55
+ class OTLPMetricExporter extends exporter_metrics_otlp_http_1.OTLPMetricExporterBase {
56
+ constructor(config = exporter_metrics_otlp_http_1.defaultOptions) {
57
+ super(new OTLPMetricExporterProxy(config), config);
55
58
  }
56
59
  }
57
60
  exports.OTLPMetricExporter = OTLPMetricExporter;
@@ -1 +1 @@
1
- {"version":3,"file":"OTLPMetricExporter.js","sourceRoot":"","sources":["../../src/OTLPMetricExporter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH,0FAA4F;AAE5F,sFAKiD;AACjD,8CAA2D;AAC3D,2CAAyC;AAEzC,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAE/C;;GAEG;AACH,MAAa,kBACX,SAAQ,+CAGP;IAKD,YAAY,SAAiC,EAAE;QAC7C,KAAK,CAAC,MAAM,CAAC,CAAC;QAJhB,+BAA+B;QACZ,eAAU,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC;QAI7D,MAAM,OAAO,GAAG,mBAAY,CAAC,uBAAuB,CAAC,aAAM,EAAE,CAAC,kCAAkC,CAAC,CAAC;QAClG,IAAI,CAAC,QAAQ,KAAb,IAAI,CAAC,QAAQ,GAAK,IAAI,kBAAQ,EAAE,EAAC;QACjC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAC5C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;SACxB;IACH,CAAC;IAED,OAAO,CACL,OAAuB;QAEvB,OAAO,6DAAgC,CACrC,OAAO,EACP,IAAI,CAAC,UAAU,EACf,IAAI,CACL,CAAC;IACJ,CAAC;IAED,aAAa,CAAC,MAA8B;QAC1C,OAAO,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ;YACnC,CAAC,CAAC,kDAAuB,CAAC,MAAM,CAAC,GAAG,CAAC;YACrC,CAAC,CAAC,aAAM,EAAE,CAAC,mCAAmC,CAAC,MAAM,GAAG,CAAC;gBACzD,CAAC,CAAC,kDAAuB,CAAC,aAAM,EAAE,CAAC,mCAAmC,CAAC;gBACvE,CAAC,CAAC,aAAM,EAAE,CAAC,2BAA2B,CAAC,MAAM,GAAG,CAAC;oBACjD,CAAC,CAAC,kDAAuB,CAAC,aAAM,EAAE,CAAC,2BAA2B,CAAC;oBAC/D,CAAC,CAAC,qBAAqB,CAAC;IAC5B,CAAC;IAED,oBAAoB;QAClB,OAAO,4CAAiB,CAAC,OAAO,CAAC;IACnC,CAAC;IAED,mBAAmB;QACjB,OAAO,gEAAgE,CAAC;IAC1E,CAAC;CACF;AA7CD,gDA6CC","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 { otlpTypes } from '@opentelemetry/exporter-trace-otlp-http';\nimport { toOTLPExportMetricServiceRequest } from '@opentelemetry/exporter-metrics-otlp-http'\nimport { MetricRecord, MetricExporter } from '@opentelemetry/sdk-metrics-base';\nimport {\n OTLPExporterConfigNode,\n OTLPExporterNodeBase,\n ServiceClientType,\n validateAndNormalizeUrl\n} from '@opentelemetry/exporter-trace-otlp-grpc';\nimport { baggageUtils, getEnv } from '@opentelemetry/core';\nimport { Metadata } from '@grpc/grpc-js';\n\nconst DEFAULT_COLLECTOR_URL = 'localhost:4317';\n\n/**\n * OTLP 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: OTLPExporterConfigNode = {}) {\n super(config);\n const headers = baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_METRICS_HEADERS);\n this.metadata ||= new Metadata();\n for (const [k, v] of Object.entries(headers)) {\n this.metadata.set(k, v)\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: OTLPExporterConfigNode): string {\n return typeof config.url === 'string'\n ? validateAndNormalizeUrl(config.url)\n : getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0\n ? validateAndNormalizeUrl(getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT)\n : getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0\n ? validateAndNormalizeUrl(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT)\n : DEFAULT_COLLECTOR_URL;\n }\n\n getServiceClientType(): ServiceClientType {\n return ServiceClientType.METRICS;\n }\n\n getServiceProtoPath(): string {\n return 'opentelemetry/proto/collector/metrics/v1/metrics_service.proto';\n }\n}\n"]}
1
+ {"version":3,"file":"OTLPMetricExporter.js","sourceRoot":"","sources":["../../src/OTLPMetricExporter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,0FAImD;AAEnD,oFAMgD;AAChD,8CAA2D;AAC3D,2CAAyC;AACzC,sEAAkH;AAElH,MAAM,uBAAwB,SAAQ,kDAAuE;IAE3G,YAAY,SAAgE,2CAAc;QACxF,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,MAAM,OAAO,GAAG,mBAAY,CAAC,uBAAuB,CAAC,IAAA,aAAM,GAAE,CAAC,kCAAkC,CAAC,CAAC;QAClG,IAAI,CAAC,QAAQ,KAAb,IAAI,CAAC,QAAQ,GAAK,IAAI,kBAAQ,EAAE,EAAC;QACjC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAC5C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACzB;IACH,CAAC;IAED,mBAAmB;QACjB,OAAO,gEAAgE,CAAC;IAC1E,CAAC;IAED,oBAAoB;QAClB,OAAO,2CAAiB,CAAC,OAAO,CAAC;IACnC,CAAC;IAED,aAAa,CAAC,MAAkC;QAC9C,OAAO,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ;YACnC,CAAC,CAAC,IAAA,iDAAuB,EAAC,MAAM,CAAC,GAAG,CAAC;YACrC,CAAC,CAAC,IAAA,aAAM,GAAE,CAAC,mCAAmC,CAAC,MAAM,GAAG,CAAC;gBACvD,CAAC,CAAC,IAAA,iDAAuB,EAAC,IAAA,aAAM,GAAE,CAAC,mCAAmC,CAAC;gBACvE,CAAC,CAAC,IAAA,aAAM,GAAE,CAAC,2BAA2B,CAAC,MAAM,GAAG,CAAC;oBAC/C,CAAC,CAAC,IAAA,iDAAuB,EAAC,IAAA,aAAM,GAAE,CAAC,2BAA2B,CAAC;oBAC/D,CAAC,CAAC,IAAA,iDAAuB,EAAC,+CAAqB,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,CAAC,OAA0B;QAChC,OAAO,IAAA,oDAAiC,EAAC,OAAO,CAAC,CAAC;IACpD,CAAC;CACF;AAED;;GAEG;AACH,MAAa,kBAAmB,SAAQ,mDAA+C;IACrF,YAAY,SAAiE,2CAAc;QACzF,KAAK,CAAC,IAAI,uBAAuB,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;CACF;AAJD,gDAIC","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 {\n defaultOptions,\n OTLPMetricExporterBase,\n OTLPMetricExporterOptions\n} from '@opentelemetry/exporter-metrics-otlp-http';\nimport { ResourceMetrics } from '@opentelemetry/sdk-metrics-base';\nimport {\n OTLPGRPCExporterConfigNode,\n OTLPGRPCExporterNodeBase,\n ServiceClientType,\n validateAndNormalizeUrl,\n DEFAULT_COLLECTOR_URL\n} from '@opentelemetry/otlp-grpc-exporter-base';\nimport { baggageUtils, getEnv } from '@opentelemetry/core';\nimport { Metadata } from '@grpc/grpc-js';\nimport { createExportMetricsServiceRequest, IExportMetricsServiceRequest } from '@opentelemetry/otlp-transformer';\n\nclass OTLPMetricExporterProxy extends OTLPGRPCExporterNodeBase<ResourceMetrics, IExportMetricsServiceRequest> {\n\n constructor(config: OTLPGRPCExporterConfigNode & OTLPMetricExporterOptions= defaultOptions) {\n super(config);\n const headers = baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_METRICS_HEADERS);\n this.metadata ||= new Metadata();\n for (const [k, v] of Object.entries(headers)) {\n this.metadata.set(k, v);\n }\n }\n\n getServiceProtoPath(): string {\n return 'opentelemetry/proto/collector/metrics/v1/metrics_service.proto';\n }\n\n getServiceClientType(): ServiceClientType {\n return ServiceClientType.METRICS;\n }\n\n getDefaultUrl(config: OTLPGRPCExporterConfigNode): string {\n return typeof config.url === 'string'\n ? validateAndNormalizeUrl(config.url)\n : getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0\n ? validateAndNormalizeUrl(getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT)\n : getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0\n ? validateAndNormalizeUrl(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT)\n : validateAndNormalizeUrl(DEFAULT_COLLECTOR_URL);\n }\n\n convert(metrics: ResourceMetrics[]): IExportMetricsServiceRequest {\n return createExportMetricsServiceRequest(metrics);\n }\n}\n\n/**\n * OTLP-gRPC metric exporter\n */\nexport class OTLPMetricExporter extends OTLPMetricExporterBase<OTLPMetricExporterProxy>{\n constructor(config: OTLPGRPCExporterConfigNode & OTLPMetricExporterOptions = defaultOptions) {\n super(new OTLPMetricExporterProxy(config), config);\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.27.0";
1
+ export declare const VERSION = "0.29.1";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -17,5 +17,5 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.VERSION = void 0;
19
19
  // this is autogenerated file, see scripts/version-update.js
20
- exports.VERSION = '0.27.0';
20
+ exports.VERSION = '0.29.1';
21
21
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,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.27.0';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.29.1';\n"]}
package/package.json CHANGED
@@ -1,24 +1,24 @@
1
1
  {
2
2
  "name": "@opentelemetry/exporter-metrics-otlp-grpc",
3
- "version": "0.27.0",
3
+ "version": "0.29.1",
4
4
  "description": "OpenTelemetry Collector Metrics Exporter allows user to send collected metrics to the OpenTelemetry Collector",
5
5
  "main": "build/src/index.js",
6
6
  "types": "build/src/index.d.ts",
7
7
  "repository": "open-telemetry/opentelemetry-js",
8
8
  "scripts": {
9
+ "prepublishOnly": "npm run compile",
9
10
  "compile": "tsc --build",
10
11
  "clean": "tsc --build --clean",
11
12
  "lint": "eslint . --ext .ts",
12
13
  "lint:fix": "eslint . --ext .ts --fix",
13
- "postcompile": "npm run submodule && npm run protos:copy",
14
- "protos:copy": "cpx protos/opentelemetry/**/*.* build/protos/opentelemetry",
15
- "submodule": "git submodule sync --recursive && git submodule update --init --recursive",
16
14
  "tdd": "npm run test -- --watch-extensions ts --watch",
17
15
  "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
18
16
  "version": "node ../../../scripts/version-update.js",
19
- "watch": "npm run protos:copy && tsc -w",
20
- "precompile": "lerna run version --scope $(npm pkg get name) --include-filtered-dependencies",
21
- "prewatch": "npm run precompile"
17
+ "watch": "tsc -w",
18
+ "precompile": "lerna run version --scope $(npm pkg get name) --include-dependencies",
19
+ "prewatch": "npm run precompile",
20
+ "peer-api-check": "node ../../../scripts/peer-api-check.js",
21
+ "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../"
22
22
  },
23
23
  "keywords": [
24
24
  "opentelemetry",
@@ -32,7 +32,7 @@
32
32
  "author": "OpenTelemetry Authors",
33
33
  "license": "Apache-2.0",
34
34
  "engines": {
35
- "node": ">=8.0.0"
35
+ "node": ">=8.12.0"
36
36
  },
37
37
  "files": [
38
38
  "build/src/**/*.js",
@@ -47,12 +47,12 @@
47
47
  "access": "public"
48
48
  },
49
49
  "devDependencies": {
50
- "@babel/core": "7.15.0",
51
- "@opentelemetry/api": "^1.0.3",
52
- "@opentelemetry/api-metrics": "0.27.0",
50
+ "@babel/core": "7.16.0",
51
+ "@opentelemetry/api": "^1.0.0",
52
+ "@opentelemetry/api-metrics": "0.29.1",
53
53
  "@types/mocha": "8.2.3",
54
- "@types/node": "14.17.11",
55
- "@types/sinon": "10.0.2",
54
+ "@types/node": "14.17.33",
55
+ "@types/sinon": "10.0.6",
56
56
  "codecov": "3.8.3",
57
57
  "cpx": "1.5.0",
58
58
  "mocha": "7.2.0",
@@ -60,21 +60,21 @@
60
60
  "rimraf": "3.0.2",
61
61
  "sinon": "12.0.1",
62
62
  "ts-loader": "8.3.0",
63
- "ts-mocha": "8.0.0",
64
- "typescript": "4.3.5"
63
+ "ts-mocha": "9.0.2",
64
+ "typescript": "4.4.4"
65
65
  },
66
66
  "peerDependencies": {
67
- "@opentelemetry/api": "^1.0.3"
67
+ "@opentelemetry/api": "^1.0.0"
68
68
  },
69
69
  "dependencies": {
70
- "@grpc/grpc-js": "^1.3.7",
71
- "@grpc/proto-loader": "^0.6.4",
72
- "@opentelemetry/core": "1.0.1",
73
- "@opentelemetry/exporter-metrics-otlp-http": "0.27.0",
74
- "@opentelemetry/exporter-trace-otlp-grpc": "0.27.0",
75
- "@opentelemetry/exporter-trace-otlp-http": "0.27.0",
76
- "@opentelemetry/resources": "1.0.1",
77
- "@opentelemetry/sdk-metrics-base": "0.27.0"
70
+ "@grpc/grpc-js": "^1.5.9",
71
+ "@grpc/proto-loader": "^0.6.9",
72
+ "@opentelemetry/core": "1.3.0",
73
+ "@opentelemetry/exporter-metrics-otlp-http": "0.29.1",
74
+ "@opentelemetry/otlp-grpc-exporter-base": "0.29.1",
75
+ "@opentelemetry/otlp-transformer": "0.29.1",
76
+ "@opentelemetry/resources": "1.3.0",
77
+ "@opentelemetry/sdk-metrics-base": "0.29.1"
78
78
  },
79
- "gitHead": "f5e227f0cb829df1ca2dc220a3e0e8ae0e607405"
79
+ "gitHead": "094f016ac6697fc45ba5d7b5765f5c3e56f18d1e"
80
80
  }
@@ -1,9 +0,0 @@
1
- # OpenTelemetry Collector Proto
2
-
3
- This package describes the OpenTelemetry collector protocol.
4
-
5
- ## Packages
6
-
7
- 1. `common` package contains the common messages shared between different services.
8
- 2. `trace` package contains the Trace Service protos.
9
- 3. `metrics` package contains the Metrics Service protos.
@@ -1,48 +0,0 @@
1
- // Copyright 2020, OpenTelemetry Authors
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- syntax = "proto3";
16
-
17
- // NOTE: This proto is experimental and is subject to change at this point.
18
- // Please do not use it at the moment.
19
-
20
- package opentelemetry.proto.collector.logs.v1;
21
-
22
- import "opentelemetry/proto/logs/v1/logs.proto";
23
-
24
- option java_multiple_files = true;
25
- option java_package = "io.opentelemetry.proto.collector.logs.v1";
26
- option java_outer_classname = "LogsServiceProto";
27
- option go_package = "github.com/open-telemetry/opentelemetry-proto/gen/go/collector/logs/v1";
28
-
29
- // Service that can be used to push logs between one Application instrumented with
30
- // OpenTelemetry and an collector, or between an collector and a central collector (in this
31
- // case logs are sent/received to/from multiple Applications).
32
- service LogsService {
33
- // For performance reasons, it is recommended to keep this RPC
34
- // alive for the entire life of the application.
35
- rpc Export(ExportLogsServiceRequest) returns (ExportLogsServiceResponse) {}
36
- }
37
-
38
- message ExportLogsServiceRequest {
39
- // An array of ResourceLogs.
40
- // For data coming from a single resource this array will typically contain one
41
- // element. Intermediary nodes (such as OpenTelemetry Collector) that receive
42
- // data from multiple origins typically batch the data before forwarding further and
43
- // in that case this array will contain multiple elements.
44
- repeated opentelemetry.proto.logs.v1.ResourceLogs resource_logs = 1;
45
- }
46
-
47
- message ExportLogsServiceResponse {
48
- }
@@ -1,45 +0,0 @@
1
- // Copyright 2019, OpenTelemetry Authors
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- syntax = "proto3";
16
-
17
- package opentelemetry.proto.collector.metrics.v1;
18
-
19
- import "opentelemetry/proto/metrics/v1/metrics.proto";
20
-
21
- option java_multiple_files = true;
22
- option java_package = "io.opentelemetry.proto.collector.metrics.v1";
23
- option java_outer_classname = "MetricsServiceProto";
24
- option go_package = "github.com/open-telemetry/opentelemetry-proto/gen/go/collector/metrics/v1";
25
-
26
- // Service that can be used to push metrics between one Application
27
- // instrumented with OpenTelemetry and a collector, or between a collector and a
28
- // central collector.
29
- service MetricsService {
30
- // For performance reasons, it is recommended to keep this RPC
31
- // alive for the entire life of the application.
32
- rpc Export(ExportMetricsServiceRequest) returns (ExportMetricsServiceResponse) {}
33
- }
34
-
35
- message ExportMetricsServiceRequest {
36
- // An array of ResourceMetrics.
37
- // For data coming from a single resource this array will typically contain one
38
- // element. Intermediary nodes (such as OpenTelemetry Collector) that receive
39
- // data from multiple origins typically batch the data before forwarding further and
40
- // in that case this array will contain multiple elements.
41
- repeated opentelemetry.proto.metrics.v1.ResourceMetrics resource_metrics = 1;
42
- }
43
-
44
- message ExportMetricsServiceResponse {
45
- }
@@ -1,45 +0,0 @@
1
- // Copyright 2019, OpenTelemetry Authors
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- syntax = "proto3";
16
-
17
- package opentelemetry.proto.collector.trace.v1;
18
-
19
- import "opentelemetry/proto/trace/v1/trace.proto";
20
-
21
- option java_multiple_files = true;
22
- option java_package = "io.opentelemetry.proto.collector.trace.v1";
23
- option java_outer_classname = "TraceServiceProto";
24
- option go_package = "github.com/open-telemetry/opentelemetry-proto/gen/go/collector/trace/v1";
25
-
26
- // Service that can be used to push spans between one Application instrumented with
27
- // OpenTelemetry and an collector, or between an collector and a central collector (in this
28
- // case spans are sent/received to/from multiple Applications).
29
- service TraceService {
30
- // For performance reasons, it is recommended to keep this RPC
31
- // alive for the entire life of the application.
32
- rpc Export(ExportTraceServiceRequest) returns (ExportTraceServiceResponse) {}
33
- }
34
-
35
- message ExportTraceServiceRequest {
36
- // An array of ResourceSpans.
37
- // For data coming from a single resource this array will typically contain one
38
- // element. Intermediary nodes (such as OpenTelemetry Collector) that receive
39
- // data from multiple origins typically batch the data before forwarding further and
40
- // in that case this array will contain multiple elements.
41
- repeated opentelemetry.proto.trace.v1.ResourceSpans resource_spans = 1;
42
- }
43
-
44
- message ExportTraceServiceResponse {
45
- }
@@ -1,77 +0,0 @@
1
- // Copyright 2019, OpenTelemetry Authors
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- syntax = "proto3";
16
-
17
- package opentelemetry.proto.common.v1;
18
-
19
- option java_multiple_files = true;
20
- option java_package = "io.opentelemetry.proto.common.v1";
21
- option java_outer_classname = "CommonProto";
22
- option go_package = "github.com/open-telemetry/opentelemetry-proto/gen/go/common/v1";
23
-
24
- // AnyValue is used to represent any type of attribute value. AnyValue may contain a
25
- // primitive value such as a string or integer or it may contain an arbitrary nested
26
- // object containing arrays, key-value lists and primitives.
27
- message AnyValue {
28
- // The value is one of the listed fields. It is valid for all values to be unspecified
29
- // in which case this AnyValue is considered to be "null".
30
- oneof value {
31
- string string_value = 1;
32
- bool bool_value = 2;
33
- int64 int_value = 3;
34
- double double_value = 4;
35
- ArrayValue array_value = 5;
36
- KeyValueList kvlist_value = 6;
37
- }
38
- }
39
-
40
- // ArrayValue is a list of AnyValue messages. We need ArrayValue as a message
41
- // since oneof in AnyValue does not allow repeated fields.
42
- message ArrayValue {
43
- // Array of values. The array may be empty (contain 0 elements).
44
- repeated AnyValue values = 1;
45
- }
46
-
47
- // KeyValueList is a list of KeyValue messages. We need KeyValueList as a message
48
- // since `oneof` in AnyValue does not allow repeated fields. Everywhere else where we need
49
- // a list of KeyValue messages (e.g. in Span) we use `repeated KeyValue` directly to
50
- // avoid unnecessary extra wrapping (which slows down the protocol). The 2 approaches
51
- // are semantically equivalent.
52
- message KeyValueList {
53
- // A collection of key/value pairs of key-value pairs. The list may be empty (may
54
- // contain 0 elements).
55
- repeated KeyValue values = 1;
56
- }
57
-
58
- // KeyValue is a key-value pair that is used to store Span attributes, Link
59
- // attributes, etc.
60
- message KeyValue {
61
- string key = 1;
62
- AnyValue value = 2;
63
- }
64
-
65
- // StringKeyValue is a pair of key/value strings. This is the simpler (and faster) version
66
- // of KeyValue that only supports string values.
67
- message StringKeyValue {
68
- string key = 1;
69
- string value = 2;
70
- }
71
-
72
- // InstrumentationLibrary is a message representing the instrumentation library information
73
- // such as the fully qualified name and version.
74
- message InstrumentationLibrary {
75
- string name = 1;
76
- string version = 2;
77
- }