From 38b4e0924f00c0b33559231cf2e3f430bd5c1fbb Mon Sep 17 00:00:00 2001 From: "marc.pichler" Date: Wed, 25 May 2022 10:47:18 +0200 Subject: [PATCH 1/4] fix(otlp-transformer): include esm and esnext in package files. --- experimental/packages/otlp-transformer/package.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/experimental/packages/otlp-transformer/package.json b/experimental/packages/otlp-transformer/package.json index 540c5af84f..d25813a328 100644 --- a/experimental/packages/otlp-transformer/package.json +++ b/experimental/packages/otlp-transformer/package.json @@ -38,6 +38,12 @@ "node": ">=8.12.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts", + "build/esnext/**/*.js", + "build/esnext/**/*.js.map", + "build/esnext/**/*.d.ts", "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", From 1486817b4dff528401258f978d197154854cbcd3 Mon Sep 17 00:00:00 2001 From: "marc.pichler" Date: Wed, 25 May 2022 10:47:28 +0200 Subject: [PATCH 2/4] fix(otlp-transformer): update README. --- .../packages/otlp-transformer/README.md | 74 +------------------ 1 file changed, 4 insertions(+), 70 deletions(-) diff --git a/experimental/packages/otlp-transformer/README.md b/experimental/packages/otlp-transformer/README.md index 2c53ce82ca..17afd609e1 100644 --- a/experimental/packages/otlp-transformer/README.md +++ b/experimental/packages/otlp-transformer/README.md @@ -3,9 +3,9 @@ [![NPM Published Version][npm-img]][npm-url] [![Apache License][license-image]][license-image] -This package provides everything needed to serialize [OpenTelemetry SDK][sdk] traces and metrics into the [OpenTelemetry Protocol][otlp] format using [protocol buffers][protobuf] or JSON. -It also contains service clients for exporting traces and metrics to the OpenTelemetry Collector or a compatible receiver using using OTLP over [gRPC][grpc]. -This module uses [`protobufjs`][protobufjs] for serialization and is compatible with [`@grpc/grpc-js`][grpc-js]. +**NOTE: This package is intended for internal use only.** + +This package provides everything needed to serialize [OpenTelemetry SDK][sdk] traces and metrics into the [OpenTelemetry Protocol][otlp] format. ## Quick Start @@ -15,8 +15,7 @@ To get started you will need to install a compatible OpenTelemetry API. ```sh npm install \ - @opentelemetry/api \ - @grpc/grpc-js # only required if you are using gRPC + @opentelemetry/api ``` ### Serialize Traces and Metrics @@ -30,65 +29,6 @@ const serializedSpans = createExportTraceServiceRequest(readableSpans); const serializedMetrics = createExportMetricsServiceRequest(readableMetrics); ``` -### Create gRPC Service Clients - -This module also contains gRPC service clients for exporting traces and metrics to an OpenTelemetry collector or compatible receiver over gRPC. -In order to avoid bundling a gRPC module with this module, it is required to construct an RPC implementation to pass to the constructor of the service clients. -Any RPC implementation compatible with `grpc` or `@grpc/grpc-js` may be used, but `@grpc/grpc-js` is recommended. - -```typescript -import type { RPCImpl } from 'protobufjs'; -import { makeGenericClientConstructor, credentials } from '@gprc/grpc-js'; -import { MetricServiceClient, TraceServiceClient } from "@opentelemetry/otlp-transformer"; - -// Construct a RPC Implementation according to protobufjs docs -const GrpcClientConstructor = makeGenericClientConstructor({}); - -const metricGRPCClient = new GrpcClientConstructor( - "http://localhost:4317/v1/metrics", // default collector metrics endpoint - credentials.createInsecure(), -); - -const traceGRPCClient = new GrpcClientConstructor( - "http://localhost:4317/v1/traces", // default collector traces endpoint - credentials.createInsecure(), -); - -const metricRpc: RPCImpl = function(method, requestData, callback) { - metricGRPCClient.makeUnaryRequest( - method.name, - arg => arg, - arg => arg, - requestData, - callback - ); -} - -const traceRpc: RPCImpl = function(method, requestData, callback) { - traceGRPCClient.makeUnaryRequest( - method.name, - arg => arg, - arg => arg, - requestData, - callback - ); -} - -// Construct service clients to use RPC Implementations -const metricServiceClient = new MetricServiceClient({ - rpcImpl: metricRpc, - startTime: Date.now(), // exporter start time in milliseconds -}); - -const traceServiceClient = new TraceServiceClient({ - rpcImpl: traceRpc, -}); - -// Export ReadableSpan[] and ReadableMetric[] over gRPC -await metricServiceClient.export(readableMetrics); -await traceServiceClient.export(readableSpans); -``` - ## Useful links - For more information on OpenTelemetry, visit: @@ -107,9 +47,3 @@ Apache 2.0 - See [LICENSE][license-url] for more information. [sdk]: https://github.com/open-telemetry/opentelemetry-js [otlp]: https://github.com/open-telemetry/opentelemetry-proto - -[protobuf]: https://developers.google.com/protocol-buffers -[grpc]: https://grpc.io/ - -[protobufjs]: https://www.npmjs.com/package/protobufjs -[grpc-js]: https://www.npmjs.com/package/@grpc/grpc-js From 58c659ea09751967fb701508cac915ed1d347335 Mon Sep 17 00:00:00 2001 From: "marc.pichler" Date: Wed, 25 May 2022 11:08:51 +0200 Subject: [PATCH 3/4] fix(changelog): add changelog entry. --- experimental/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/experimental/CHANGELOG.md b/experimental/CHANGELOG.md index 027a58898f..60443a6693 100644 --- a/experimental/CHANGELOG.md +++ b/experimental/CHANGELOG.md @@ -26,6 +26,7 @@ All notable changes to experimental packages in this project will be documented * fix(opentelemetry-instrumentation-http): use correct origin when port is `null` #2948 @danielgblanco * fix(otlp-exporter-base): include esm and esnext in package files #2952 @dyladan * fix(otlp-http-exporter): update endpoint to match spec #2895 @svetlanabrennan +* fix(otlp-transformer): include esm and esnext in package files and update README #2992 @pichlermarc ### :books: (Refine Doc) From aaac721a626b95acdac6b74f00035768ef0cac80 Mon Sep 17 00:00:00 2001 From: "marc.pichler" Date: Wed, 25 May 2022 13:16:52 +0200 Subject: [PATCH 4/4] fix(otlp-transformer): inline 'npm install' in README.md --- experimental/packages/otlp-transformer/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/experimental/packages/otlp-transformer/README.md b/experimental/packages/otlp-transformer/README.md index 17afd609e1..fc5c13af9e 100644 --- a/experimental/packages/otlp-transformer/README.md +++ b/experimental/packages/otlp-transformer/README.md @@ -14,8 +14,7 @@ To get started you will need to install a compatible OpenTelemetry API. ### Install Peer Dependencies ```sh -npm install \ - @opentelemetry/api +npm install @opentelemetry/api ``` ### Serialize Traces and Metrics