From fd8e5e6c314acde56b7763e99d886686c5596dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B2=92=E7=B2=92=E6=A9=99?= Date: Mon, 3 Apr 2023 18:15:57 +0800 Subject: [PATCH] feat(exporter-logs-otlp-grpc): adds package --- .../exporter-logs-otlp-grpc/.eslintignore | 1 + .../exporter-logs-otlp-grpc/.eslintrc.js | 8 + .../exporter-logs-otlp-grpc/.npmignore | 4 + .../packages/exporter-logs-otlp-grpc/LICENSE | 201 ++++++++++ .../exporter-logs-otlp-grpc/README.md | 101 +++++ .../exporter-logs-otlp-grpc/package.json | 82 +++++ .../src/OTLPLogsExporter.ts | 77 ++++ .../exporter-logs-otlp-grpc/src/index.ts | 17 + .../test/OTLPLogsExporter.test.ts | 346 ++++++++++++++++++ .../exporter-logs-otlp-grpc/test/certs/ca.crt | 33 ++ .../exporter-logs-otlp-grpc/test/certs/ca.key | 51 +++ .../test/certs/client.crt | 31 ++ .../test/certs/client.csr | 28 ++ .../test/certs/client.key | 51 +++ .../test/certs/regenerate.sh | 22 ++ .../test/certs/server.crt | 31 ++ .../test/certs/server.csr | 28 ++ .../test/certs/server.key | 51 +++ .../test/logsHelper.ts | 173 +++++++++ .../exporter-logs-otlp-grpc/tsconfig.json | 37 ++ .../src/utils/environment.ts | 18 + tsconfig.json | 4 + 22 files changed, 1395 insertions(+) create mode 100644 experimental/packages/exporter-logs-otlp-grpc/.eslintignore create mode 100644 experimental/packages/exporter-logs-otlp-grpc/.eslintrc.js create mode 100644 experimental/packages/exporter-logs-otlp-grpc/.npmignore create mode 100644 experimental/packages/exporter-logs-otlp-grpc/LICENSE create mode 100644 experimental/packages/exporter-logs-otlp-grpc/README.md create mode 100644 experimental/packages/exporter-logs-otlp-grpc/package.json create mode 100644 experimental/packages/exporter-logs-otlp-grpc/src/OTLPLogsExporter.ts create mode 100644 experimental/packages/exporter-logs-otlp-grpc/src/index.ts create mode 100644 experimental/packages/exporter-logs-otlp-grpc/test/OTLPLogsExporter.test.ts create mode 100644 experimental/packages/exporter-logs-otlp-grpc/test/certs/ca.crt create mode 100644 experimental/packages/exporter-logs-otlp-grpc/test/certs/ca.key create mode 100644 experimental/packages/exporter-logs-otlp-grpc/test/certs/client.crt create mode 100644 experimental/packages/exporter-logs-otlp-grpc/test/certs/client.csr create mode 100644 experimental/packages/exporter-logs-otlp-grpc/test/certs/client.key create mode 100755 experimental/packages/exporter-logs-otlp-grpc/test/certs/regenerate.sh create mode 100644 experimental/packages/exporter-logs-otlp-grpc/test/certs/server.crt create mode 100644 experimental/packages/exporter-logs-otlp-grpc/test/certs/server.csr create mode 100644 experimental/packages/exporter-logs-otlp-grpc/test/certs/server.key create mode 100644 experimental/packages/exporter-logs-otlp-grpc/test/logsHelper.ts create mode 100644 experimental/packages/exporter-logs-otlp-grpc/tsconfig.json diff --git a/experimental/packages/exporter-logs-otlp-grpc/.eslintignore b/experimental/packages/exporter-logs-otlp-grpc/.eslintignore new file mode 100644 index 00000000000..378eac25d31 --- /dev/null +++ b/experimental/packages/exporter-logs-otlp-grpc/.eslintignore @@ -0,0 +1 @@ +build diff --git a/experimental/packages/exporter-logs-otlp-grpc/.eslintrc.js b/experimental/packages/exporter-logs-otlp-grpc/.eslintrc.js new file mode 100644 index 00000000000..3ed0fbeba38 --- /dev/null +++ b/experimental/packages/exporter-logs-otlp-grpc/.eslintrc.js @@ -0,0 +1,8 @@ +module.exports = { + "env": { + "mocha": true, + "commonjs": true, + "node": true, + }, + ...require('../../../eslint.config.js') +} diff --git a/experimental/packages/exporter-logs-otlp-grpc/.npmignore b/experimental/packages/exporter-logs-otlp-grpc/.npmignore new file mode 100644 index 00000000000..9505ba9450f --- /dev/null +++ b/experimental/packages/exporter-logs-otlp-grpc/.npmignore @@ -0,0 +1,4 @@ +/bin +/coverage +/doc +/test diff --git a/experimental/packages/exporter-logs-otlp-grpc/LICENSE b/experimental/packages/exporter-logs-otlp-grpc/LICENSE new file mode 100644 index 00000000000..261eeb9e9f8 --- /dev/null +++ b/experimental/packages/exporter-logs-otlp-grpc/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/experimental/packages/exporter-logs-otlp-grpc/README.md b/experimental/packages/exporter-logs-otlp-grpc/README.md new file mode 100644 index 00000000000..fdfed3d38ca --- /dev/null +++ b/experimental/packages/exporter-logs-otlp-grpc/README.md @@ -0,0 +1,101 @@ +# OpenTelemetry Collector Logs Exporter for node with grpc + +[![NPM Published Version][npm-img]][npm-url] +[![Apache License][license-image]][license-image] + +**Note: This is an experimental package under active development. New releases may include breaking changes.** + +This module provides exporter for node to be used with OTLP (`grpc`) compatible receivers. +Compatible with [opentelemetry-collector][opentelemetry-collector-url] versions `>=0.16 <=0.53`. + +## Installation + +```bash +npm install --save @opentelemetry/exporter-logs-otlp-grpc +``` + +## Service Name + +The OpenTelemetry Collector Exporter does not have a service name configuration. +In order to set the service name, use the `service.name` resource attribute as prescribed in the [OpenTelemetry Resource Semantic Conventions][semconv-resource-service-name]. +To see documentation and sample code for the traces exporter, as well as instructions for using TLS, visit the [Collector Trace Exporter for web and node][trace-exporter-url]. +To see documentation and sample code for the metric exporter, see the [exporter-metrics-otlp-grpc package][metrics-exporter-url] + +## Logs in Node - GRPC + +The OTLPLogsExporter in Node expects the URL to only be the hostname. It will not work with `/v1/logs`. All +options that work with trace also work with logs. + +```js +import { + LoggerProvider, + SimpleLogRecordProcessor, +} from '@opentelemetry/sdk-logs'; +import { OTLPLogsExporter } from '@opentelemetry/exporter-logs-otlp-grpc'; + +const collectorOptions = { + // url is optional and can be omitted - default is http://localhost:4317 + url: 'http://:', +}; + +const loggerExpoter = new OTLPLogsExporter(collectorOptions); +const loggerProvider = new LoggerProvider(); + +loggerProvider.addLogRecordProcessor( + new SimpleLogRecordProcessor(loggerExpoter) +); + +['SIGINT', 'SIGTERM'].forEach(signal => { + process.on(signal, () => loggerProvider.shutdown().catch(console.error)); +}); + +// logging +const logger = loggerProvider.getLogger('example-logger'); +logger.emit({ body: 'example-log' }); +``` + +## Environment Variable Configuration + +| Environment variable | Description | +|----------------------|-------------| +| OTEL_EXPORTER_OTLP_LOGS_ENDPOINT | The endpoint to send logs to. By default `localhost:4317` will be used. | +| OTEL_EXPORTER_OTLP_ENDPOINT | The endpoint to send trace, metric, and logs to. By default `localhost:4317` will be used. | +| OTEL_EXPORTER_OTLP_LOGS_COMPRESSION | The compression type to use on OTLP logs requests. Options include gzip. By default no compression will be used. | +| 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. | +| OTEL_EXPORTER_OTLP_LOGS_INSECURE | Whether to enable client transport security for the exporter's gRPC connection for logs 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. | +| 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. | +| OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE | The path to the file containing trusted root certificate to use when verifying an OTLP logs server's TLS credentials. By default the host platform's trusted root certificate is used.| +| 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. | +| OTEL_EXPORTER_OTLP_LOGS_CLIENT_KEY | The path to the file containing private client key to use when verifying an OTLP logs client's TLS credentials. Must provide a client certificate/chain when providing a private client key. By default no client key file is used. | +| 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. | +| OTEL_EXPORTER_OTLP_LOGS_CLIENT_CERTIFICATE | The path to the file containing trusted client certificate/chain for clients private key to use when verifying an OTLP logs server's TLS credentials. Must provide a private client key when providing a certificate/chain. By default no chain file is used. | +| 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. | +| OTEL_EXPORTER_OTLP_LOGS_TIMEOUT | The maximum waiting time, in milliseconds, allowed to send each OTLP logs batch. Default is 10000. | +| OTEL_EXPORTER_OTLP_TIMEOUT | The maximum waiting time, in milliseconds, allowed to send each OTLP trace and metric batch. Default is 10000. | + +> Settings configured programmatically take precedence over environment variables. Per-signal environment variables take precedence over non-per-signal environment variables. + +## Running opentelemetry-collector locally to see the logs + +1. Go to `examples/otlp-exporter-node` +2. Follow the instructions there to view logs. + +## Useful links + +- For more information on OpenTelemetry, visit: +- For more about OpenTelemetry JavaScript: +- For help or feedback on this project, join us in [GitHub Discussions][discussions-url] + +## License + +Apache 2.0 - See [LICENSE][license-url] for more information. + +[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions +[license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/LICENSE +[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat +[npm-url]: https://www.npmjs.com/package/@opentelemetry/exporter-logs-otlp-grpc +[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fexporter-logs-otlp-grpc.svg +[opentelemetry-collector-url]: https://github.com/open-telemetry/opentelemetry-collector +[semconv-resource-service-name]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#service +[trace-exporter-url]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/exporter-trace-otlp-grpc +[metrics-exporter-url]: https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc diff --git a/experimental/packages/exporter-logs-otlp-grpc/package.json b/experimental/packages/exporter-logs-otlp-grpc/package.json new file mode 100644 index 00000000000..e3e9aafafa9 --- /dev/null +++ b/experimental/packages/exporter-logs-otlp-grpc/package.json @@ -0,0 +1,82 @@ +{ + "name": "@opentelemetry/exporter-logs-otlp-grpc", + "version": "0.37.0", + "description": "OpenTelemetry Collector Exporter allows user to send collected log records to the OpenTelemetry Collector", + "main": "build/src/index.js", + "types": "build/src/index.d.ts", + "repository": "open-telemetry/opentelemetry-js", + "scripts": { + "prepublishOnly": "npm run compile", + "compile": "tsc --build", + "clean": "tsc --build --clean", + "lint": "eslint . --ext .ts", + "lint:fix": "eslint . --ext .ts --fix", + "tdd": "npm run test -- --watch-extensions ts --watch", + "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'", + "version": "node ../../../scripts/version-update.js", + "watch": "tsc --watch --build", + "precompile": "lerna run version --scope $(npm pkg get name) --include-dependencies", + "prewatch": "npm run precompile", + "peer-api-check": "node ../../../scripts/peer-api-check.js", + "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../" + }, + "keywords": [ + "opentelemetry", + "nodejs", + "grpc", + "tracing", + "profiling", + "metrics", + "stats", + "logging" + ], + "author": "OpenTelemetry Authors", + "license": "Apache-2.0", + "engines": { + "node": ">=14" + }, + "files": [ + "build/src/**/*.js", + "build/src/**/*.js.map", + "build/src/**/*.d.ts", + "build/protos/**/*.proto", + "doc", + "LICENSE", + "README.md" + ], + "publishConfig": { + "access": "public" + }, + "devDependencies": { + "@babel/core": "7.16.0", + "@grpc/proto-loader": "^0.7.3", + "@opentelemetry/api": "1.4.1", + "@opentelemetry/api-logs": "0.37.0", + "@opentelemetry/otlp-exporter-base": "0.37.0", + "@opentelemetry/resources": "1.11.0", + "@opentelemetry/sdk-logs": "0.37.0", + "@types/mocha": "10.0.0", + "@types/node": "18.6.5", + "@types/sinon": "10.0.13", + "codecov": "3.8.3", + "cpx": "1.5.0", + "mocha": "10.0.0", + "nyc": "15.1.0", + "rimraf": "4.1.2", + "sinon": "15.0.0", + "ts-loader": "8.4.0", + "ts-mocha": "10.0.0", + "typescript": "4.4.4" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.0.0" + }, + "dependencies": { + "@grpc/grpc-js": "^1.7.1", + "@opentelemetry/core": "1.11.0", + "@opentelemetry/otlp-grpc-exporter-base": "0.37.0", + "@opentelemetry/otlp-transformer": "0.37.0" + }, + "homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/exporter-logs-otlp-grpc", + "sideEffects": false +} \ No newline at end of file diff --git a/experimental/packages/exporter-logs-otlp-grpc/src/OTLPLogsExporter.ts b/experimental/packages/exporter-logs-otlp-grpc/src/OTLPLogsExporter.ts new file mode 100644 index 00000000000..e4484fdb396 --- /dev/null +++ b/experimental/packages/exporter-logs-otlp-grpc/src/OTLPLogsExporter.ts @@ -0,0 +1,77 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { LogRecordExporter, ReadableLogRecord } from '@opentelemetry/sdk-logs'; +import { baggageUtils, getEnv } from '@opentelemetry/core'; +import { Metadata } from '@grpc/grpc-js'; +import { + OTLPGRPCExporterConfigNode, + OTLPGRPCExporterNodeBase, + ServiceClientType, + validateAndNormalizeUrl, + DEFAULT_COLLECTOR_URL, +} from '@opentelemetry/otlp-grpc-exporter-base'; +import { + createExportLogsServiceRequest, + IExportLogsServiceRequest, +} from '@opentelemetry/otlp-transformer'; + +/** + * OTLP Logs Exporter for Node + */ +export class OTLPLogsExporter + extends OTLPGRPCExporterNodeBase + implements LogRecordExporter +{ + constructor(config: OTLPGRPCExporterConfigNode = {}) { + super(config); + const headers = baggageUtils.parseKeyPairsIntoRecord( + getEnv().OTEL_EXPORTER_OTLP_LOGS_HEADERS + ); + this.metadata ||= new Metadata(); + for (const [k, v] of Object.entries(headers)) { + this.metadata.set(k, v); + } + } + + convert(logRecords: ReadableLogRecord[]): IExportLogsServiceRequest { + return createExportLogsServiceRequest(logRecords); + } + + getDefaultUrl(config: OTLPGRPCExporterConfigNode) { + return validateAndNormalizeUrl(this.getUrlFromConfig(config)); + } + + getServiceClientType() { + return ServiceClientType.LOGS; + } + + getServiceProtoPath(): string { + return 'opentelemetry/proto/collector/logs/v1/logs_service.proto'; + } + + getUrlFromConfig(config: OTLPGRPCExporterConfigNode): string { + if (typeof config.url === 'string') { + return config.url; + } + + return ( + getEnv().OTEL_EXPORTER_OTLP_LOGS_ENDPOINT || + getEnv().OTEL_EXPORTER_OTLP_ENDPOINT || + DEFAULT_COLLECTOR_URL + ); + } +} diff --git a/experimental/packages/exporter-logs-otlp-grpc/src/index.ts b/experimental/packages/exporter-logs-otlp-grpc/src/index.ts new file mode 100644 index 00000000000..b35d852d902 --- /dev/null +++ b/experimental/packages/exporter-logs-otlp-grpc/src/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from './OTLPLogsExporter'; diff --git a/experimental/packages/exporter-logs-otlp-grpc/test/OTLPLogsExporter.test.ts b/experimental/packages/exporter-logs-otlp-grpc/test/OTLPLogsExporter.test.ts new file mode 100644 index 00000000000..d413b8902d4 --- /dev/null +++ b/experimental/packages/exporter-logs-otlp-grpc/test/OTLPLogsExporter.test.ts @@ -0,0 +1,346 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as protoLoader from '@grpc/proto-loader'; +import { diag } from '@opentelemetry/api'; + +import * as assert from 'assert'; +import * as fs from 'fs'; +import * as grpc from '@grpc/grpc-js'; +import * as path from 'path'; +import * as sinon from 'sinon'; +import { OTLPLogsExporter } from '../src'; + +import { + ensureExportedLogRecordIsCorrect, + ensureMetadataIsCorrect, + ensureResourceIsCorrect, + mockedReadableLogRecord, +} from './logsHelper'; +import * as core from '@opentelemetry/core'; +import { CompressionAlgorithm } from '@opentelemetry/otlp-exporter-base'; +import { GrpcCompressionAlgorithm } from '@opentelemetry/otlp-grpc-exporter-base'; +import { + IExportLogsServiceRequest, + IResourceLogs, +} from '@opentelemetry/otlp-transformer'; + +const logsServiceProtoPath = + 'opentelemetry/proto/collector/logs/v1/logs_service.proto'; +const includeDirs = [ + path.resolve(__dirname, '../../otlp-grpc-exporter-base/protos'), +]; + +const address = 'localhost:1501'; + +type TestParams = { + useTLS?: boolean; + metadata?: grpc.Metadata; +}; + +const metadata = new grpc.Metadata(); +metadata.set('k', 'v'); + +const testCollectorExporter = (params: TestParams) => + describe(`OTLPLogsExporter - node ${ + params.useTLS ? 'with' : 'without' + } TLS, ${params.metadata ? 'with' : 'without'} metadata`, () => { + let collectorExporter: OTLPLogsExporter; + let server: grpc.Server; + let exportedData: IResourceLogs | undefined; + let reqMetadata: grpc.Metadata | undefined; + + before(done => { + server = new grpc.Server(); + protoLoader + .load(logsServiceProtoPath, { + keepCase: false, + longs: String, + enums: String, + defaults: true, + oneofs: true, + includeDirs, + }) + .then((packageDefinition: protoLoader.PackageDefinition) => { + const packageObject: any = + grpc.loadPackageDefinition(packageDefinition); + server.addService( + packageObject.opentelemetry.proto.collector.logs.v1.LogsService + .service, + { + Export: (data: { + request: IExportLogsServiceRequest; + metadata: grpc.Metadata; + }) => { + if (data.request.resourceLogs != null) { + exportedData = data.request.resourceLogs[0]; + } + reqMetadata = data.metadata; + }, + } + ); + const credentials = params.useTLS + ? grpc.ServerCredentials.createSsl( + fs.readFileSync('./test/certs/ca.crt'), + [ + { + cert_chain: fs.readFileSync('./test/certs/server.crt'), + private_key: fs.readFileSync('./test/certs/server.key'), + }, + ] + ) + : grpc.ServerCredentials.createInsecure(); + server.bindAsync(address, credentials, () => { + server.start(); + done(); + }); + }); + }); + + after(() => { + server.forceShutdown(); + }); + + beforeEach(done => { + const credentials = params.useTLS + ? grpc.credentials.createSsl( + fs.readFileSync('./test/certs/ca.crt'), + fs.readFileSync('./test/certs/client.key'), + fs.readFileSync('./test/certs/client.crt') + ) + : grpc.credentials.createInsecure(); + collectorExporter = new OTLPLogsExporter({ + url: 'https://' + address, + credentials, + metadata: params.metadata, + }); + done(); + }); + + afterEach(() => { + exportedData = undefined; + reqMetadata = undefined; + sinon.restore(); + }); + + describe('instance', () => { + it('should warn about headers when using grpc', () => { + // Need to stub/spy on the underlying logger as the 'diag' instance is global + const spyLoggerWarn = sinon.stub(diag, 'warn'); + collectorExporter = new OTLPLogsExporter({ + url: `http://${address}`, + headers: { + foo: 'bar', + }, + }); + const args = spyLoggerWarn.args[0]; + assert.strictEqual(args[0], 'Headers cannot be set when using grpc'); + }); + it('should warn about path in url', () => { + const spyLoggerWarn = sinon.stub(diag, 'warn'); + collectorExporter = new OTLPLogsExporter({ + url: `http://${address}/v1/logs`, + }); + const args = spyLoggerWarn.args[0]; + assert.strictEqual( + args[0], + 'URL path should not be set when using grpc, the path part of the URL will be ignored.' + ); + }); + }); + + describe('export', () => { + it('should export log records', done => { + const responseSpy = sinon.spy(); + const logRecords = [Object.assign({}, mockedReadableLogRecord)]; + collectorExporter.export(logRecords, responseSpy); + setTimeout(() => { + assert.ok( + typeof exportedData !== 'undefined', + 'resource' + " doesn't exist" + ); + + const logs = exportedData.scopeLogs[0].logRecords; + const resource = exportedData.resource; + + assert.ok(typeof logs !== 'undefined', 'log records do not exist'); + + ensureExportedLogRecordIsCorrect(logs[0]); + + assert.ok(typeof resource !== 'undefined', "resource doesn't exist"); + + ensureResourceIsCorrect(resource); + + ensureMetadataIsCorrect(reqMetadata, params?.metadata); + + done(); + }, 500); + }); + it('should log deadline exceeded error', done => { + const credentials = params.useTLS + ? grpc.credentials.createSsl( + fs.readFileSync('./test/certs/ca.crt'), + fs.readFileSync('./test/certs/client.key'), + fs.readFileSync('./test/certs/client.crt') + ) + : grpc.credentials.createInsecure(); + + const collectorExporterWithTimeout = new OTLPLogsExporter({ + url: 'grpcs://' + address, + credentials, + metadata: params.metadata, + timeoutMillis: 100, + }); + + const responseSpy = sinon.spy(); + const logRecords = [Object.assign({}, mockedReadableLogRecord)]; + collectorExporterWithTimeout.export(logRecords, responseSpy); + + setTimeout(() => { + const result = responseSpy.args[0][0] as core.ExportResult; + assert.strictEqual(result.code, core.ExportResultCode.FAILED); + assert.strictEqual( + responseSpy.args[0][0].error.details, + 'Deadline exceeded' + ); + done(); + }, 300); + }); + }); + describe('export - with gzip compression', () => { + beforeEach(() => { + const credentials = params.useTLS + ? grpc.credentials.createSsl( + fs.readFileSync('./test/certs/ca.crt'), + fs.readFileSync('./test/certs/client.key'), + fs.readFileSync('./test/certs/client.crt') + ) + : grpc.credentials.createInsecure(); + collectorExporter = new OTLPLogsExporter({ + url: 'https://' + address, + credentials, + metadata: params.metadata, + compression: CompressionAlgorithm.GZIP, + }); + }); + it('should successfully send the spans', done => { + const responseSpy = sinon.spy(); + const logRecords = [Object.assign({}, mockedReadableLogRecord)]; + collectorExporter.export(logRecords, responseSpy); + setTimeout(() => { + assert.ok( + typeof exportedData !== 'undefined', + 'resource' + " doesn't exist" + ); + const logs = exportedData.scopeLogs[0].logRecords; + const resource = exportedData.resource; + + assert.ok(typeof logs !== 'undefined', 'spans do not exist'); + ensureExportedLogRecordIsCorrect(logs[0]); + + assert.ok(typeof resource !== 'undefined', "resource doesn't exist"); + ensureResourceIsCorrect(resource); + + ensureMetadataIsCorrect(reqMetadata, params.metadata); + + done(); + }, 500); + }); + }); + describe('Logs Exporter with compression', () => { + const envSource = process.env; + it('should return gzip compression algorithm on exporter', () => { + const credentials = params.useTLS + ? grpc.credentials.createSsl( + fs.readFileSync('./test/certs/ca.crt'), + fs.readFileSync('./test/certs/client.key'), + fs.readFileSync('./test/certs/client.crt') + ) + : grpc.credentials.createInsecure(); + + envSource.OTEL_EXPORTER_OTLP_COMPRESSION = 'gzip'; + collectorExporter = new OTLPLogsExporter({ + url: 'https://' + address, + credentials, + metadata: params.metadata, + }); + assert.strictEqual( + collectorExporter.compression, + GrpcCompressionAlgorithm.GZIP + ); + delete envSource.OTEL_EXPORTER_OTLP_COMPRESSION; + }); + }); + }); + +describe('OTLPLogsExporter - node (getDefaultUrl)', () => { + it('should default to localhost', done => { + const collectorExporter = new OTLPLogsExporter({}); + setTimeout(() => { + assert.strictEqual(collectorExporter['url'], 'localhost:4317'); + done(); + }); + }); + it('should keep the URL if included', done => { + const url = 'http://foo.bar.com'; + const collectorExporter = new OTLPLogsExporter({ url }); + setTimeout(() => { + assert.strictEqual(collectorExporter['url'], 'foo.bar.com'); + done(); + }); + }); +}); + +describe('when configuring via environment', () => { + const envSource = process.env; + it('should use url defined in env', () => { + envSource.OTEL_EXPORTER_OTLP_ENDPOINT = 'http://foo.bar'; + const collectorExporter = new OTLPLogsExporter(); + assert.strictEqual(collectorExporter.url, 'foo.bar'); + envSource.OTEL_EXPORTER_OTLP_ENDPOINT = ''; + }); + it('should override global exporter url with signal url defined in env', () => { + envSource.OTEL_EXPORTER_OTLP_ENDPOINT = 'http://foo.bar'; + envSource.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = 'http://foo.logs'; + const collectorExporter = new OTLPLogsExporter(); + assert.strictEqual(collectorExporter.url, 'foo.logs'); + envSource.OTEL_EXPORTER_OTLP_ENDPOINT = ''; + envSource.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = ''; + }); + it('should use headers defined via env', () => { + envSource.OTEL_EXPORTER_OTLP_HEADERS = 'foo=bar'; + const collectorExporter = new OTLPLogsExporter(); + assert.deepStrictEqual(collectorExporter.metadata?.get('foo'), ['bar']); + envSource.OTEL_EXPORTER_OTLP_HEADERS = ''; + }); + it('should override global headers config with signal headers defined via env', () => { + const metadata = new grpc.Metadata(); + metadata.set('foo', 'bar'); + metadata.set('goo', 'lol'); + envSource.OTEL_EXPORTER_OTLP_HEADERS = 'foo=jar,bar=foo'; + envSource.OTEL_EXPORTER_OTLP_LOGS_HEADERS = 'foo=boo'; + const collectorExporter = new OTLPLogsExporter({ metadata }); + assert.deepStrictEqual(collectorExporter.metadata?.get('foo'), ['boo']); + assert.deepStrictEqual(collectorExporter.metadata?.get('bar'), ['foo']); + assert.deepStrictEqual(collectorExporter.metadata?.get('goo'), ['lol']); + envSource.OTEL_EXPORTER_OTLP_LOGS_HEADERS = ''; + envSource.OTEL_EXPORTER_OTLP_HEADERS = ''; + }); +}); + +testCollectorExporter({ useTLS: true }); +testCollectorExporter({ useTLS: false }); +testCollectorExporter({ metadata }); diff --git a/experimental/packages/exporter-logs-otlp-grpc/test/certs/ca.crt b/experimental/packages/exporter-logs-otlp-grpc/test/certs/ca.crt new file mode 100644 index 00000000000..27e1d6826b3 --- /dev/null +++ b/experimental/packages/exporter-logs-otlp-grpc/test/certs/ca.crt @@ -0,0 +1,33 @@ +-----BEGIN CERTIFICATE----- +MIIFozCC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7O/pMq++fJ7Pib9YG93cBNYSRFulWU1rTD8z+Y +BE8Z+cluZD9xAgMBAAGjUzBRMB0GA1UdDgQWBBRZTBtOna2cDAuO5UP1Je85TKsE +CTAfBgNVHSMEGDAWgBRZTBtOna2cDAuO5UP1Je85TKsECTAPBgNVHRMBAf8EBTAD +AQH/MA0GCSqGSIb3DQEBCwUAA4ICAQBWDujXcuCir18SZhm7ipTwRz50KG7x1W5/ +p32hHJlEYh83+7vytsVwO8W6Ugn8R76mIIeevZv5ahxZeNdLNKrF6qjwZp/INY64 +pO2rUiDqkbU8csQZm5mUMmEa06WytAims5e3wNzLlBEKCUArAy6jMctXm054uQiv +VPk79CEonOjvZBh72QAV+wDCm8oq7TGPgmLPYQkdg3ncPjAu1ubPoPupsUZKmO9G +369t/n5JNDM03Ksek3WFRr88xNIeGRwfAPkJH+XKuikM5PawKfkIX1S//C+NKwdG +9I5d+gO40Ap9itUGr4m0E541isW/poFzcEw8P+UV7WvPNJyCvdOxEIvji4SbLl4h +oCS2qNeREuhtfX0jGzxc9pfrj1w14159tpnwQay2Sf6UOSr6OSl46lETAQaWzJz+ +r/FDHy+T7THqvp++JlIkCfvtMZRXdCX6eRghc/03qSpizhDsAB3hMy/Yq3FA95WT +Rx56YJgzvEH1BUxfc/peTr6BGNEaonRvf9i2dnf+Z3jCJAn4WeKfTDmcpSnmcK4s +dOhQOYnupZCu8mYyC5aOPFB/Ovtm5USJDlWujUm+EjIaOUiPDqP7ff2wQX9+ympF +7xjbanad5F3E1gl623VuhGTI6jUiY5TnxVwh67WxIMb2/bP5Ko27/JmWbbJ1/Dar +g2LKPYSY8A== +-----END CERTIFICATE----- diff --git a/experimental/packages/exporter-logs-otlp-grpc/test/certs/ca.key b/experimental/packages/exporter-logs-otlp-grpc/test/certs/ca.key new file mode 100644 index 00000000000..3ca1e8e1491 --- /dev/null +++ b/experimental/packages/exporter-logs-otlp-grpc/test/certs/ca.key @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KE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experimental/packages/exporter-logs-otlp-grpc/test/certs/client.crt b/experimental/packages/exporter-logs-otlp-grpc/test/certs/client.crt new file mode 100644 index 00000000000..cb5c4508d79 --- /dev/null +++ b/experimental/packages/exporter-logs-otlp-grpc/test/certs/client.crt @@ -0,0 +1,31 @@ +-----BEGIN CERTIFICATE----- +MIIFPzCCAycCAQEwDQYJKoZIhvcNAQELBQAwYTELMAkGA1UEBhMCQ0wxCzAJBgNV +BAgMAlJNMRowGAYDVQQHDBFPcGVuVGVsZW1ldHJ5VGVzdDENMAsGA1UECgwEUm9v +dDENMAsGA1UECwwEVGVzdDELMAkGA1UEAwwCY2EwHhcNMjIwNjA4MDk1NDAxWhcN +MjMwNjA4MDk1NDAxWjBqMQswCQYDVQQGEwJDTDELMAkGA1UECAwCUk0xGjAYBgNV +BAcMEU9wZW5UZWxlbWV0cnlUZXN0MQ0wCwYDVQQKDARUZXN0MQ8wDQYDVQQLDAZD +bGllbnQxEjAQBgNVBAMMCWxvY2FsaG9zdDCCAiIwDQYJKoZIhvcNAQEBBQADggIP +ADCCAgoCggIBAMo9AlVbqKk0NI3U4IPhXARrA/9HCtW6TK8bNj+KqBETPJ0OV6Ep +FC1AUG8h6ZpQy1lAVchMOXXzVIxejJ53Wq2aBMELl7KaheEUAzbQNqSBxL7cY61l +sk1rd0ryQ0167j/tNV5h3FH4ZawD7vt2oGte4Dxipj+gFQx/MXD1j2vOKm0SO6xr +IdSWg79HRnMb6mJMCtTc6kvX5XDN3avwrhndsPKZREhs1ei6lhY4ip3N70357MB6 +vNF7euAMQU7KZ0uZZbj0lqINT+6jwEJ6yhkZM9ILKbxC8+IAhCAOsu2bKXtkhDSN +V+3Jr3x8PRWlhlCitGt9a8/DlT0RIfcXQHRmY7hdnMqt+7vJio56oHcyv2+8ap+C +rWr5OfsRuQvSs3ebn1zhDim0AspKOfdwGepPubgM/MuilYIi35L6CbRp+VbSGmIy +GUOGoWa3uykcMOm4hIK6bbFOGUTixbwIjRfxzuPfPLqIK+aQ5kBSUdDhK9LHpNOM +n0RihXBoRfE3VfnuWVcetp/FG7B5PTgCvP0Ss9QivTV/OQmi1juPa1ONmtZodZTz +eV2mDvZLQKFIInOQE/6dxMn+yrmYlQdV2nEiJU1yiKp5601OklqeX0BO1rWQy283 +AUwbAS5ZBmQeF4KmDZtEphdOTEDmu5YTyDhIvSK58Rq+iQq+CLmaYH3BAgMBAAEw +DQYJKoZIhvcNAQELBQADggIBABV90+TvW47WUdsZpy0eZayjWgIZvKqpWVcYI4Px +1zEGMVJvg8TPjPujGIdhkhxbabklqy/+s/im4ev9MnIGG0wckoYaJgH9KvtD/Br9 +3SpexmN9mQMO8/8299TWJBjS1q5UYjktvbuKFGpizs3+y4n88UmcXRh8y2Z1oglZ +WuXn5A5BJkpXONI3U615mXTf0CLnpbU//4z5VQe2AylksOgo3y7DHXz3iPOh15TN +EnDz7Pms0i8tswSbmS+NU2Clv7ACHhstdPoEqiN/V9gpjon1n+fBXaqMhaXI9C9b +NV9l5AW1utBAc/zlzRnKYtw/yrDW00KAN2FJbGefThJWPCYUlBx5hcCl1C8ObjIz +4b2+2TLdnwkMeeb8FV6mzTaQVWQ5Yr+ffQBqDhahEwjGyUOjzqFtGSlujWKLT4g1 +T9XnVr8KKU6UWDeHDp1lz8S9wo2l5DJN/S6u/SB9RXBOgzFVO9EWnbxkpR4YqdwK +WNP+Xhw9AO+DVX+/zK0PHF4f1z85E30R/V/CmvSx07jaXxK+ixcCykfb0DRvyVyr +WyVxz72LeJnsqWBSjBlwGslPsOzucA6RfN2b7/9rTObglKoKbEV/dSKoRZ34hFcV +nuiwRbVjVXH1az8FU8o+nG+anKW/jpVn4NcabYiHWH6qL+W3ZRTcWkyOOsSHHdOS +Hdil +-----END CERTIFICATE----- diff --git a/experimental/packages/exporter-logs-otlp-grpc/test/certs/client.csr b/experimental/packages/exporter-logs-otlp-grpc/test/certs/client.csr new file mode 100644 index 00000000000..30ac376794b --- /dev/null +++ b/experimental/packages/exporter-logs-otlp-grpc/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XfHma +3qPFmMNkXCZ8WRjp6K/l98z9j+lFksN5y2BJCqf8oL1iURPYuHlgRK3LhpR4LOPt +JrJYwAML4hr1g93ejdwGc1LjNx8dyAriCM7h7IwhYGgnT1kYu/shVgT6SH0+ixAq +PNIOekCJH75k9C/QP/hPPARbAzD5of69haLeAcABik/cH/RRuDHTTVxgHFfV/W8r +BWwf7IIxX0iEPCQWxW1Q5SfzOmP9ICLFln4s38MgEGIyGqxgfkSi3nuLkwKTLB1j +NppTiO7Da4Vvso85hdLqNXvE3J6VSiu2c0oDf/ZZYkSizEzt9ESPPp3VcNj2MDbr +CxwhzV018wovlTunUSwKWvRn+syT10bnzZX/+QarZ7mfq57DPfMHNiiPM1ej26eE +Z7A3R3J67H4Ifp5Ua9jdga6x0RfOBRDuZv2N861eVs+9jSIC+hmrvQ1TbTvzHFVB +KYE1UBDRNijuGwsYgZ74vPKLGgA7cFs9X2JXzKc/0Y9opgBltZlNBF97XZSLDw1v +VaPCUVqOU6VKamPX8nVhkpHoUdDSl08T+VKwP5Da4oJHmSZMzxRQLl2TZnIru14+ +uVcP +-----END CERTIFICATE REQUEST----- diff --git a/experimental/packages/exporter-logs-otlp-grpc/test/certs/client.key b/experimental/packages/exporter-logs-otlp-grpc/test/certs/client.key new file mode 100644 index 00000000000..fd649acf54e --- /dev/null +++ b/experimental/packages/exporter-logs-otlp-grpc/test/certs/client.key @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIJKQIBAAKCAgEAyj0CVVuoqTQ0jdTgg+FcBGsD/0cK1bpMrxs2P4qoERM8nQ5X +oSkULUBQbyHpmlDLWUBVyEw5dfNUjF6MnndarZoEwQuXspqF4RQDNtA2pIHEvtxj +rWWyTWt3SvJDTXruP+01XmHcUfhlrAPu+3aga17gPGKmP6AVDH8xcPWPa84qbRI7 +rGsh1JaDv0dGcxvqYkwK1NzqS9flcM3dq/CuGd2w8plESGzV6LqWFjiKnc3vTfns +wHq80Xt64AxBTspnS5lluPSWog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Ya1a1+/M0hVGati4RQqdilbErnP6OpYsgncLrAldLxh8Y +HdTNTQKCAQEAp+ZJ2LKZIOtB2OZxq5pPbWIU1GQyuAG+f+BVUy6D4arYWmirvXO5 +vv3FNmrYVTWKx170c7PfJu7lvjUmlqemVvySH5H1WMBuVlPkoUlJlJnEtM2bLnVs +qd8w5FgDn+kg7YwUV8DOD9/dGG8Rn5Sczz2VXtfbHbCT4zDv4YpCfOZGVfQZZxZa +yfJFc6EXK6oVIUQLnH2N7u+KSHhcmpfpE0CxJHjRHxY/C9IlNsECMO1JunweWkwU +Z+lTX78jyLiKFlweELLBwaUdIwxSpKoQfbucT99K8IFPiEbMwWNmLccViRWLC8g1 +4vgCr6Z79YGoM5EPBZOkBozCdotvu/NpswKCAQAmEKgiBRnupScDQLE31QxSEyHZ +NUnheQ6SMYGjCrneD6LFgr8sK1iS8+PHjC4ngE40yh98speocH8oXgTfUap/7kcn +MEy70yZDGT2wGhcRVO4ivwwCP7NDic7eak22LF9QFn0qn0qAvU2NsdywtSBrRxPE +UF4uaTYs8gLTvlr+5qm5duk+P+hKL/OhOU9GQ3GMYbS/axTU7rkM1Mr+OM3oaKIZ +4Hz9JB0sGgrwpyXRnK4k5mjeUkJ9tx8a5Ky1pyd4Tob492+pdUJBsUXeqii8ZgKi +iCe4lWY9FnS13UC4AViWRaHu793h7xFoibevfXeqErByQ4ByDVPi2QJqIZcd +-----END RSA PRIVATE KEY----- diff --git a/experimental/packages/exporter-logs-otlp-grpc/test/certs/regenerate.sh b/experimental/packages/exporter-logs-otlp-grpc/test/certs/regenerate.sh new file mode 100755 index 00000000000..e1f1af5b54d --- /dev/null +++ b/experimental/packages/exporter-logs-otlp-grpc/test/certs/regenerate.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env sh +# +# Usage: regenerate.sh +# +# regenerate.sh regenerates certificates that are used to test gRPC with TLS +# Make sure you run it in test/certs directory. +# It also serves as a documentation on how existing certificates were generated. + +rm ca.crt ca.key client.crt client.csr client.key server.crt server.csr server.key + +openssl genrsa -nodes -des3 -out ca.key 4096 +openssl req -nodes -new -x509 -days 365 -key ca.key -out ca.crt -subj "/C=CL/ST=RM/L=OpenTelemetryTest/O=Root/OU=Test/CN=ca" + +openssl genrsa -nodes -des3 -out server.key 4096 +openssl req -nodes -new -key server.key -out server.csr -subj "/C=CL/ST=RM/L=OpenTelemetryTest/O=Test/OU=Server/CN=localhost" +openssl x509 -req -nodes -days 365 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt +openssl rsa -nodes -in server.key -out server.key + +openssl genrsa -nodes -des3 -out client.key 4096 +openssl req -nodes -new -key client.key -out client.csr -subj "/C=CL/ST=RM/L=OpenTelemetryTest/O=Test/OU=Client/CN=localhost" +openssl x509 -nodes -req -days 365 -in client.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out client.crt +openssl rsa -nodes -in client.key -out client.key diff --git a/experimental/packages/exporter-logs-otlp-grpc/test/certs/server.crt b/experimental/packages/exporter-logs-otlp-grpc/test/certs/server.crt new file mode 100644 index 00000000000..da8b6beedd7 --- /dev/null +++ b/experimental/packages/exporter-logs-otlp-grpc/test/certs/server.crt @@ -0,0 +1,31 @@ +-----BEGIN CERTIFICATE----- +MIIFPzCCAycCAQEwDQYJKoZIhvcNAQELBQAwYTELMAkGA1UEBhMCQ0wxCzAJBgNV +BAgMAlJNMRowGAYDVQQHDBFPcGVuVGVsZW1ldHJ5VGVzdDENMAsGA1UECgwEUm9v +dDENMAsGA1UECwwEVGVzdDELMAkGA1UEAwwCY2EwHhcNMjIwNjA4MDk1NDAwWhcN +MjMwNjA4MDk1NDAwWjBqMQswCQYDVQQGEwJDTDELMAkGA1UECAwCUk0xGjAYBgNV +BAcMEU9wZW5UZWxlbWV0cnlUZXN0MQ0wCwYDVQQKDARUZXN0MQ8wDQYDVQQLDAZT +ZXJ2ZXIxEjAQBgNVBAMMCWxvY2FsaG9zdDCCAiIwDQYJKoZIhvcNAQEBBQADggIP +ADCCAgoCggIBAK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7VrayO6+ScGchUGN5h1qR4xzWpA +2QKSb7t1oEW/GtrV6AD3jJUjcna4LP6DdpY/0IocgU5KonR0eFUNrZA8hUsXquQ0 +/Cx9d7ktdEDudeS4tJywF1CI3IcIZQ2vExJ+NjdlAFIVFkaqFFLhv/cCcGaBpH7X +6dc5bOoqyOgX97yBJJX9Joz6ZoAp2XO1tvycxj2g84V90lDsbTurmyuoR8yTcBbE +FNseKWNRi4fmsB1etz/HX3h1qUPP1ze+fY4C2zPleIB6uSKM5ZfODpMDejHQRF29 +YshoFbAJ19zOHYY+5LYHoLGJlN34TJ4ouPpAtRIQu4ebQZwMxddU1759sCIIwkHe +V5d5 +-----END CERTIFICATE----- diff --git a/experimental/packages/exporter-logs-otlp-grpc/test/certs/server.csr b/experimental/packages/exporter-logs-otlp-grpc/test/certs/server.csr new file mode 100644 index 00000000000..d8ab7deb4be --- /dev/null +++ b/experimental/packages/exporter-logs-otlp-grpc/test/certs/server.csr @@ -0,0 +1,28 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIErzCCApcCAQAwajELMAkGA1UEBhMCQ0wxCzAJBgNVBAgMAlJNMRowGAYDVQQH +DBFPcGVuVGVsZW1ldHJ5VGVzdDENMAsGA1UECgwEVGVzdDEPMA0GA1UECwwGU2Vy +dmVyMRIwEAYDVQQDDAlsb2NhbGhvc3QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAw +ggIKAoICAQCheMG4Y8E3dOPAnbarjY4blRiLz8aXTWgj120iTfY6EakcKdL7eA50 +Xy1nWt+FM2fX8VzeB04GK8y2JK3TlIb6Lq4Y5Gtpo3LNZDo5XxXhsICXvC01Ruqh +Pi3SRcOMT3ed3WbbDdXUGo+3vxpSuIzSOvaratenZxbMI28wCOtqK/TB3c2OBXxB +UXjK9uZBkqPv5zcCNtT24jIWfjkk7qEoKJseiZl1GBvfrmRWU6xPn5+O4zCuMAb9 +VvlNg9cNgKH9NZcn0EP4IjGOl1ACDxyMgRLxchdbHVPmSc7m5d7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9PEwkSpCm/JyGTm524ok0KyrXo1nSm1WKZqEIQCpp2D +vQFY +-----END CERTIFICATE REQUEST----- diff --git a/experimental/packages/exporter-logs-otlp-grpc/test/certs/server.key b/experimental/packages/exporter-logs-otlp-grpc/test/certs/server.key new file mode 100644 index 00000000000..9147802e7d9 --- /dev/null +++ b/experimental/packages/exporter-logs-otlp-grpc/test/certs/server.key @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIJKAIBAAKCAgEAoXjBuGPBN3TjwJ22q42OG5UYi8/Gl01oI9dtIk32OhGpHCnS ++3gOdF8tZ1rfhTNn1/Fc3gdOBivMtiSt05SG+i6uGORraaNyzWQ6OV8V4bCAl7wt +NUbqoT4t0kXDjE93nd1m2w3V1BqPt78aUriM0jr2q2rXp2cWzCNvMAjraiv0wd3N +jgV8QVF4yvbmQZKj7+c3AjbU9uIyFn45JO6hKCibHomZdRgb365kVlOsT5+fjuMw +rjAG/Vb5TYPXDYCh/TWXJ9BD+CIxjpdQAg8cjIES8XIXWx1T5knO5uXe88bN/zgh +/z7fWJixgSipHe/Bizv5+YBZc5xeeMvw3RCpk9Pft+wosXWX5YLGFYsyVzzH0qrw +Z7OY4lGtHePlSL67HpOlBXdohePfKRQh4MgjBE82wOvDMks0bbxhUxXWvPj5Xb8y +xDgwvUyKU/dkH27FQ3f3Ve6UvGxAjSiW/4tmopieqp4dsUO3rUevhaZ5+oqoHiuU +7WNYfhIsITKTNOgVCkr0xCk+ZQnZRmu503d+UkZnxumca7aADauCp96MHnYPmOll +PNNFT05mnW/olaONGHe9ypVKKfSY8sRdCPXVyko4HMgESOqg+2meMfxJB32Zvuf+ +jmryAtK5Nw6qfeUsfcO8tMGKWyY1whsEi2kLpAZzkRWo+UAkoi8u84ZvoHkCAwEA +AQKCAgB16ox1TgvEpszHVaUXZJk5VUkGmKXqyfFZ8zDUU2CTiWAYnAZh84uCuhqb +FoaSbDbSQIVT8rus0AF/pgt2rklfnAUxUmWKUH0+tom6adC97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mQ704WxUUdcL5uQoRsTqDm32+pN +/DQHvENLDqaDuN9hp7daFKdcq4mLFoXYm5aoA76yhxQI0EBhYjMiHz6PDZ8lzi+F +NduMOC9rcW2StDRyO++BcCexBjTSo7nlYbpO5kWW9VlC5TAabh8JL5+GJ9uT90Vf +GNqYVneFCCnsGeqJIXkzKn7eeygKjf6KCX94OA3O4z4ro/H+Gllv6eKSipc= +-----END RSA PRIVATE KEY----- diff --git a/experimental/packages/exporter-logs-otlp-grpc/test/logsHelper.ts b/experimental/packages/exporter-logs-otlp-grpc/test/logsHelper.ts new file mode 100644 index 00000000000..b57b2682bdc --- /dev/null +++ b/experimental/packages/exporter-logs-otlp-grpc/test/logsHelper.ts @@ -0,0 +1,173 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { HrTime, TraceFlags } from '@opentelemetry/api'; +import { SeverityNumber } from '@opentelemetry/api-logs'; +import { Resource } from '@opentelemetry/resources'; +import * as assert from 'assert'; +import * as grpc from '@grpc/grpc-js'; +import { VERSION } from '@opentelemetry/core'; +import { + IAnyValue, + IKeyValue, + ILogRecord, + IResource, +} from '@opentelemetry/otlp-transformer'; +import { ReadableLogRecord } from '@opentelemetry/sdk-logs'; + +const traceIdArr = [ + 31, 16, 8, 220, 142, 39, 14, 133, 196, 10, 13, 124, 57, 57, 178, 120, +]; +const spanIdArr = [94, 16, 114, 97, 246, 79, 165, 62]; + +export const mockedReadableLogRecord: ReadableLogRecord = { + resource: Resource.default().merge( + new Resource({ + 'resource-attribute': 'some resource-attr value', + }) + ), + instrumentationScope: { + name: 'scope_name_1', + version: '0.1.0', + schemaUrl: 'http://url.to.schema', + }, + hrTime: [1680253513, 123241635] as HrTime, + attributes: { + 'some-attribute': 'some attribute value', + }, + severityNumber: SeverityNumber.ERROR, + severityText: 'error', + body: 'some_log_body', + spanContext: { + traceFlags: TraceFlags.SAMPLED, + traceId: '1f1008dc8e270e85c40a0d7c3939b278', + spanId: '5e107261f64fa53e', + }, +}; + +export function ensureExportedAttributesAreCorrect(attributes: IKeyValue[]) { + assert.deepStrictEqual( + attributes, + [ + { + key: 'some-attribute', + value: { + stringValue: 'some attribute value', + value: 'stringValue', + }, + }, + ], + 'exported attributes are incorrect' + ); +} + +export function ensureExportedBodyIsCorrect(body?: IAnyValue) { + assert.deepStrictEqual( + body, + { stringValue: 'some_log_body', value: 'stringValue' }, + 'exported attributes are incorrect' + ); +} + +export function ensureExportedLogRecordIsCorrect(logRecord: ILogRecord) { + ensureExportedBodyIsCorrect(logRecord.body); + ensureExportedAttributesAreCorrect(logRecord.attributes); + assert.strictEqual( + logRecord.timeUnixNano, + '1680253513123241728', + 'timeUnixNano is wrong' + ); + assert.strictEqual( + logRecord.observedTimeUnixNano, + '1680253513123241728', + 'observedTimeUnixNano is wrong' + ); + assert.strictEqual( + logRecord.severityNumber, + 'SEVERITY_NUMBER_ERROR', + 'severityNumber is wrong' + ); + assert.strictEqual(logRecord.severityText, 'error', 'severityText is wrong'); + assert.strictEqual( + logRecord.droppedAttributesCount, + 0, + 'droppedAttributesCount is wrong' + ); + assert.strictEqual(logRecord.flags, TraceFlags.SAMPLED, 'flags is wrong'); + assert.deepStrictEqual( + logRecord.traceId, + Buffer.from(traceIdArr), + 'traceId is wrong' + ); + assert.deepStrictEqual( + logRecord.spanId, + Buffer.from(spanIdArr), + 'spanId is wrong' + ); +} + +export function ensureResourceIsCorrect(resource: IResource) { + assert.deepStrictEqual(resource, { + attributes: [ + { + key: 'service.name', + value: { + stringValue: `unknown_service:${process.argv0}`, + value: 'stringValue', + }, + }, + { + key: 'telemetry.sdk.language', + value: { + stringValue: 'nodejs', + value: 'stringValue', + }, + }, + { + key: 'telemetry.sdk.name', + value: { + stringValue: 'opentelemetry', + value: 'stringValue', + }, + }, + { + key: 'telemetry.sdk.version', + value: { + stringValue: VERSION, + value: 'stringValue', + }, + }, + { + key: 'resource-attribute', + value: { + stringValue: 'some resource-attr value', + value: 'stringValue', + }, + }, + ], + droppedAttributesCount: 0, + }); +} + +export function ensureMetadataIsCorrect( + actual?: grpc.Metadata, + expected?: grpc.Metadata +) { + //ignore user agent + expected?.remove('user-agent'); + actual?.remove('user-agent'); + assert.deepStrictEqual(actual?.getMap(), expected?.getMap() ?? {}); +} diff --git a/experimental/packages/exporter-logs-otlp-grpc/tsconfig.json b/experimental/packages/exporter-logs-otlp-grpc/tsconfig.json new file mode 100644 index 00000000000..cd64d1ce731 --- /dev/null +++ b/experimental/packages/exporter-logs-otlp-grpc/tsconfig.json @@ -0,0 +1,37 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "build", + "rootDir": "." + }, + "include": [ + "src/**/*.ts", + "test/**/*.ts" + ], + "references": [ + { + "path": "../../../api" + }, + { + "path": "../../../packages/opentelemetry-core" + }, + { + "path": "../../../packages/opentelemetry-resources" + }, + { + "path": "../api-logs" + }, + { + "path": "../otlp-exporter-base" + }, + { + "path": "../otlp-grpc-exporter-base" + }, + { + "path": "../otlp-transformer" + }, + { + "path": "../sdk-logs" + } + ] +} diff --git a/packages/opentelemetry-core/src/utils/environment.ts b/packages/opentelemetry-core/src/utils/environment.ts index 45fd67d9f38..1ab79176da7 100644 --- a/packages/opentelemetry-core/src/utils/environment.ts +++ b/packages/opentelemetry-core/src/utils/environment.ts @@ -58,6 +58,7 @@ const ENVIRONMENT_NUMBERS_KEYS = [ 'OTEL_EXPORTER_OTLP_TIMEOUT', 'OTEL_EXPORTER_OTLP_TRACES_TIMEOUT', 'OTEL_EXPORTER_OTLP_METRICS_TIMEOUT', + 'OTEL_EXPORTER_OTLP_LOGS_TIMEOUT', 'OTEL_EXPORTER_JAEGER_AGENT_PORT', ] as const; @@ -98,9 +99,11 @@ export type ENVIRONMENT = { OTEL_EXPORTER_OTLP_ENDPOINT?: string; OTEL_EXPORTER_OTLP_TRACES_ENDPOINT?: string; OTEL_EXPORTER_OTLP_METRICS_ENDPOINT?: string; + OTEL_EXPORTER_OTLP_LOGS_ENDPOINT?: string; OTEL_EXPORTER_OTLP_HEADERS?: string; OTEL_EXPORTER_OTLP_TRACES_HEADERS?: string; OTEL_EXPORTER_OTLP_METRICS_HEADERS?: string; + OTEL_EXPORTER_OTLP_LOGS_HEADERS?: string; OTEL_EXPORTER_ZIPKIN_ENDPOINT?: string; OTEL_LOG_LEVEL?: DiagLogLevel; OTEL_RESOURCE_ATTRIBUTES?: string; @@ -112,21 +115,27 @@ export type ENVIRONMENT = { OTEL_EXPORTER_OTLP_INSECURE?: string; OTEL_EXPORTER_OTLP_TRACES_INSECURE?: string; OTEL_EXPORTER_OTLP_METRICS_INSECURE?: string; + OTEL_EXPORTER_OTLP_LOGS_INSECURE?: string; OTEL_EXPORTER_OTLP_CERTIFICATE?: string; OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE?: string; OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE?: string; + OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE?: string; OTEL_EXPORTER_OTLP_COMPRESSION?: string; OTEL_EXPORTER_OTLP_TRACES_COMPRESSION?: string; OTEL_EXPORTER_OTLP_METRICS_COMPRESSION?: string; + OTEL_EXPORTER_OTLP_LOGS_COMPRESSION?: string; OTEL_EXPORTER_OTLP_CLIENT_KEY?: string; OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEY?: string; OTEL_EXPORTER_OTLP_METRICS_CLIENT_KEY?: string; + OTEL_EXPORTER_OTLP_LOGS_CLIENT_KEY?: string; OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE?: string; OTEL_EXPORTER_OTLP_TRACES_CLIENT_CERTIFICATE?: string; OTEL_EXPORTER_OTLP_METRICS_CLIENT_CERTIFICATE?: string; + OTEL_EXPORTER_OTLP_LOGS_CLIENT_CERTIFICATE?: string; OTEL_EXPORTER_OTLP_PROTOCOL?: string; OTEL_EXPORTER_OTLP_TRACES_PROTOCOL?: string; OTEL_EXPORTER_OTLP_METRICS_PROTOCOL?: string; + OTEL_EXPORTER_OTLP_LOGS_PROTOCOL?: string; OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE?: string; } & ENVIRONMENT_BOOLEANS & ENVIRONMENT_NUMBERS & @@ -170,12 +179,15 @@ export const DEFAULT_ENVIRONMENT: Required = { OTEL_EXPORTER_OTLP_ENDPOINT: '', OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: '', OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: '', + OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: '', OTEL_EXPORTER_OTLP_HEADERS: '', OTEL_EXPORTER_OTLP_TRACES_HEADERS: '', OTEL_EXPORTER_OTLP_METRICS_HEADERS: '', + OTEL_EXPORTER_OTLP_LOGS_HEADERS: '', OTEL_EXPORTER_OTLP_TIMEOUT: 10000, OTEL_EXPORTER_OTLP_TRACES_TIMEOUT: 10000, OTEL_EXPORTER_OTLP_METRICS_TIMEOUT: 10000, + OTEL_EXPORTER_OTLP_LOGS_TIMEOUT: 10000, OTEL_EXPORTER_ZIPKIN_ENDPOINT: 'http://localhost:9411/api/v2/spans', OTEL_LOG_LEVEL: DiagLogLevel.INFO, OTEL_NO_PATCH_MODULES: [], @@ -202,21 +214,27 @@ export const DEFAULT_ENVIRONMENT: Required = { OTEL_EXPORTER_OTLP_INSECURE: '', OTEL_EXPORTER_OTLP_TRACES_INSECURE: '', OTEL_EXPORTER_OTLP_METRICS_INSECURE: '', + OTEL_EXPORTER_OTLP_LOGS_INSECURE: '', OTEL_EXPORTER_OTLP_CERTIFICATE: '', OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE: '', OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE: '', + OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE: '', OTEL_EXPORTER_OTLP_COMPRESSION: '', OTEL_EXPORTER_OTLP_TRACES_COMPRESSION: '', OTEL_EXPORTER_OTLP_METRICS_COMPRESSION: '', + OTEL_EXPORTER_OTLP_LOGS_COMPRESSION: '', OTEL_EXPORTER_OTLP_CLIENT_KEY: '', OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEY: '', OTEL_EXPORTER_OTLP_METRICS_CLIENT_KEY: '', + OTEL_EXPORTER_OTLP_LOGS_CLIENT_KEY: '', OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE: '', OTEL_EXPORTER_OTLP_TRACES_CLIENT_CERTIFICATE: '', OTEL_EXPORTER_OTLP_METRICS_CLIENT_CERTIFICATE: '', + OTEL_EXPORTER_OTLP_LOGS_CLIENT_CERTIFICATE: '', OTEL_EXPORTER_OTLP_PROTOCOL: 'http/protobuf', OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: 'http/protobuf', OTEL_EXPORTER_OTLP_METRICS_PROTOCOL: 'http/protobuf', + OTEL_EXPORTER_OTLP_LOGS_PROTOCOL: 'http/protobuf', OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: 'cumulative', }; diff --git a/tsconfig.json b/tsconfig.json index e54ecaeff95..e29f43f52e4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,6 +7,7 @@ "api", "experimental/packages/api-events", "experimental/packages/api-logs", + "experimental/packages/exporter-logs-otlp-grpc", "experimental/packages/exporter-trace-otlp-grpc", "experimental/packages/exporter-trace-otlp-http", "experimental/packages/exporter-trace-otlp-proto", @@ -62,6 +63,9 @@ { "path": "experimental/packages/api-logs" }, + { + "path": "experimental/packages/exporter-logs-otlp-grpc" + }, { "path": "experimental/packages/exporter-trace-otlp-grpc" },