@opentelemetry/exporter-metrics-otlp-grpc 0.28.0 → 0.29.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -15
- package/build/src/OTLPMetricExporter.d.ts +4 -5
- package/build/src/OTLPMetricExporter.js +4 -6
- package/build/src/OTLPMetricExporter.js.map +1 -1
- package/build/src/version.d.ts +1 -1
- package/build/src/version.js +1 -1
- package/build/src/version.js.map +1 -1
- package/package.json +10 -10
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]
|
|
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`.
|
|
7
8
|
|
|
8
9
|
## Installation
|
|
9
10
|
|
|
@@ -19,37 +20,55 @@ To see sample code and documentation for the traces exporter, as well as instruc
|
|
|
19
20
|
|
|
20
21
|
## Metrics in Node - GRPC
|
|
21
22
|
|
|
22
|
-
The
|
|
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.
|
|
23
24
|
|
|
24
25
|
```js
|
|
25
|
-
const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
|
|
26
|
+
const { MeterProvider, PeriodicExportingMetricReader } = require('@opentelemetry/sdk-metrics-base');
|
|
26
27
|
const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-grpc');
|
|
27
28
|
const collectorOptions = {
|
|
28
|
-
// url is optional and can be omitted - default is
|
|
29
|
-
url: '
|
|
29
|
+
// url is optional and can be omitted - default is http://localhost:4317
|
|
30
|
+
url: 'http://<collector-hostname>:<port>',
|
|
30
31
|
};
|
|
32
|
+
|
|
31
33
|
const exporter = new OTLPMetricExporter(collectorOptions);
|
|
34
|
+
const meterProvider = new MeterProvider({});
|
|
35
|
+
|
|
36
|
+
meterProvider.addMetricReader(new PeriodicExportingMetricReader({
|
|
37
|
+
exporter: metricExporter,
|
|
38
|
+
exportIntervalMillis: 1000,
|
|
39
|
+
}));
|
|
32
40
|
|
|
33
|
-
// Register the exporter
|
|
34
|
-
const provider = new MeterProvider({
|
|
35
|
-
exporter,
|
|
36
|
-
interval: 60000,
|
|
37
|
-
})
|
|
38
41
|
['SIGINT', 'SIGTERM'].forEach(signal => {
|
|
39
|
-
process.on(signal, () =>
|
|
42
|
+
process.on(signal, () => meterProvider.shutdown().catch(console.error));
|
|
40
43
|
});
|
|
41
44
|
|
|
42
45
|
// Now, start recording data
|
|
43
|
-
const meter =
|
|
46
|
+
const meter = meterProvider.getMeter('example-meter');
|
|
44
47
|
const counter = meter.createCounter('metric_name');
|
|
45
48
|
counter.add(10, { 'key': 'value' });
|
|
46
49
|
```
|
|
47
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
|
+
|
|
48
68
|
## Running opentelemetry-collector locally to see the metrics
|
|
49
69
|
|
|
50
|
-
1. Go to examples/otlp-exporter-node
|
|
51
|
-
2.
|
|
52
|
-
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.
|
|
53
72
|
|
|
54
73
|
## Useful links
|
|
55
74
|
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { otlpTypes } from '@opentelemetry/exporter-trace-otlp-http';
|
|
2
1
|
import { OTLPMetricExporterBase, OTLPMetricExporterOptions } from '@opentelemetry/exporter-metrics-otlp-http';
|
|
3
|
-
import {
|
|
2
|
+
import { ResourceMetrics } from '@opentelemetry/sdk-metrics-base';
|
|
4
3
|
import { OTLPGRPCExporterConfigNode, OTLPGRPCExporterNodeBase, ServiceClientType } from '@opentelemetry/otlp-grpc-exporter-base';
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { IExportMetricsServiceRequest } from '@opentelemetry/otlp-transformer';
|
|
5
|
+
declare class OTLPMetricExporterProxy extends OTLPGRPCExporterNodeBase<ResourceMetrics, IExportMetricsServiceRequest> {
|
|
7
6
|
constructor(config?: OTLPGRPCExporterConfigNode & OTLPMetricExporterOptions);
|
|
8
7
|
getServiceProtoPath(): string;
|
|
9
8
|
getServiceClientType(): ServiceClientType;
|
|
10
9
|
getDefaultUrl(config: OTLPGRPCExporterConfigNode): string;
|
|
11
|
-
convert(metrics: ResourceMetrics[]):
|
|
10
|
+
convert(metrics: ResourceMetrics[]): IExportMetricsServiceRequest;
|
|
12
11
|
}
|
|
13
12
|
/**
|
|
14
13
|
* OTLP-gRPC metric exporter
|
|
@@ -20,17 +20,15 @@ const exporter_metrics_otlp_http_1 = require("@opentelemetry/exporter-metrics-ot
|
|
|
20
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
|
|
23
|
+
const otlp_transformer_1 = require("@opentelemetry/otlp-transformer");
|
|
24
24
|
class OTLPMetricExporterProxy extends otlp_grpc_exporter_base_1.OTLPGRPCExporterNodeBase {
|
|
25
25
|
constructor(config = exporter_metrics_otlp_http_1.defaultOptions) {
|
|
26
|
-
var _a;
|
|
27
26
|
super(config);
|
|
28
|
-
this.metadata || (this.metadata = new grpc_js_1.Metadata());
|
|
29
27
|
const headers = core_1.baggageUtils.parseKeyPairsIntoRecord((0, core_1.getEnv)().OTEL_EXPORTER_OTLP_METRICS_HEADERS);
|
|
28
|
+
this.metadata || (this.metadata = new grpc_js_1.Metadata());
|
|
30
29
|
for (const [k, v] of Object.entries(headers)) {
|
|
31
30
|
this.metadata.set(k, v);
|
|
32
31
|
}
|
|
33
|
-
this._aggregationTemporality = (_a = config.aggregationTemporality) !== null && _a !== void 0 ? _a : exporter_metrics_otlp_http_1.defaultExporterTemporality;
|
|
34
32
|
}
|
|
35
33
|
getServiceProtoPath() {
|
|
36
34
|
return 'opentelemetry/proto/collector/metrics/v1/metrics_service.proto';
|
|
@@ -45,10 +43,10 @@ class OTLPMetricExporterProxy extends otlp_grpc_exporter_base_1.OTLPGRPCExporter
|
|
|
45
43
|
? (0, otlp_grpc_exporter_base_1.validateAndNormalizeUrl)((0, core_1.getEnv)().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT)
|
|
46
44
|
: (0, core_1.getEnv)().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0
|
|
47
45
|
? (0, otlp_grpc_exporter_base_1.validateAndNormalizeUrl)((0, core_1.getEnv)().OTEL_EXPORTER_OTLP_ENDPOINT)
|
|
48
|
-
: DEFAULT_COLLECTOR_URL;
|
|
46
|
+
: (0, otlp_grpc_exporter_base_1.validateAndNormalizeUrl)(otlp_grpc_exporter_base_1.DEFAULT_COLLECTOR_URL);
|
|
49
47
|
}
|
|
50
48
|
convert(metrics) {
|
|
51
|
-
return (0,
|
|
49
|
+
return (0, otlp_transformer_1.createExportMetricsServiceRequest)(metrics);
|
|
52
50
|
}
|
|
53
51
|
}
|
|
54
52
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OTLPMetricExporter.js","sourceRoot":"","sources":["../../src/OTLPMetricExporter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;
|
|
1
|
+
{"version":3,"file":"OTLPMetricExporter.js","sourceRoot":"","sources":["../../src/OTLPMetricExporter.ts"],"names":[],"mappings":";AAAA;;;;;;;;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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"]}
|
package/build/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.29.2";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/src/version.js
CHANGED
package/build/src/version.js.map
CHANGED
|
@@ -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.
|
|
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.2';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentelemetry/exporter-metrics-otlp-grpc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.2",
|
|
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",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@babel/core": "7.16.0",
|
|
51
51
|
"@opentelemetry/api": "^1.0.0",
|
|
52
|
-
"@opentelemetry/api-metrics": "0.
|
|
52
|
+
"@opentelemetry/api-metrics": "0.29.2",
|
|
53
53
|
"@types/mocha": "8.2.3",
|
|
54
54
|
"@types/node": "14.17.33",
|
|
55
55
|
"@types/sinon": "10.0.6",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"rimraf": "3.0.2",
|
|
61
61
|
"sinon": "12.0.1",
|
|
62
62
|
"ts-loader": "8.3.0",
|
|
63
|
-
"ts-mocha": "
|
|
63
|
+
"ts-mocha": "9.0.2",
|
|
64
64
|
"typescript": "4.4.4"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
@@ -69,12 +69,12 @@
|
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@grpc/grpc-js": "^1.5.9",
|
|
71
71
|
"@grpc/proto-loader": "^0.6.9",
|
|
72
|
-
"@opentelemetry/core": "1.
|
|
73
|
-
"@opentelemetry/exporter-metrics-otlp-http": "0.
|
|
74
|
-
"@opentelemetry/
|
|
75
|
-
"@opentelemetry/otlp-
|
|
76
|
-
"@opentelemetry/resources": "1.
|
|
77
|
-
"@opentelemetry/sdk-metrics-base": "0.
|
|
72
|
+
"@opentelemetry/core": "1.3.1",
|
|
73
|
+
"@opentelemetry/exporter-metrics-otlp-http": "0.29.2",
|
|
74
|
+
"@opentelemetry/otlp-grpc-exporter-base": "0.29.2",
|
|
75
|
+
"@opentelemetry/otlp-transformer": "0.29.2",
|
|
76
|
+
"@opentelemetry/resources": "1.3.1",
|
|
77
|
+
"@opentelemetry/sdk-metrics-base": "0.29.2"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "51afd54bd63e46d5d530266761144c7be2f6b3a7"
|
|
80
80
|
}
|