Skip to content

Commit 7149f6c

Browse files
pichlermarcdyladan
andauthored
fix(otlp-transformer): include esm and esnext in package files and update README (#2992)
Co-authored-by: Daniel Dyla <[email protected]>
1 parent bfd04b0 commit 7149f6c

File tree

3 files changed

+11
-71
lines changed

3 files changed

+11
-71
lines changed

experimental/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ All notable changes to experimental packages in this project will be documented
2626
* fix(opentelemetry-instrumentation-http): use correct origin when port is `null` #2948 @danielgblanco
2727
* fix(otlp-exporter-base): include esm and esnext in package files #2952 @dyladan
2828
* fix(otlp-http-exporter): update endpoint to match spec #2895 @svetlanabrennan
29+
* fix(otlp-transformer): include esm and esnext in package files and update README #2992 @pichlermarc
2930

3031
### :books: (Refine Doc)
3132

experimental/packages/otlp-transformer/README.md

Lines changed: 4 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
[![NPM Published Version][npm-img]][npm-url]
44
[![Apache License][license-image]][license-image]
55

6-
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.
7-
It also contains service clients for exporting traces and metrics to the OpenTelemetry Collector or a compatible receiver using using OTLP over [gRPC][grpc].
8-
This module uses [`protobufjs`][protobufjs] for serialization and is compatible with [`@grpc/grpc-js`][grpc-js].
6+
**NOTE: This package is intended for internal use only.**
7+
8+
This package provides everything needed to serialize [OpenTelemetry SDK][sdk] traces and metrics into the [OpenTelemetry Protocol][otlp] format.
99

1010
## Quick Start
1111

@@ -14,9 +14,7 @@ To get started you will need to install a compatible OpenTelemetry API.
1414
### Install Peer Dependencies
1515

1616
```sh
17-
npm install \
18-
@opentelemetry/api \
19-
@grpc/grpc-js # only required if you are using gRPC
17+
npm install @opentelemetry/api
2018
```
2119

2220
### Serialize Traces and Metrics
@@ -30,65 +28,6 @@ const serializedSpans = createExportTraceServiceRequest(readableSpans);
3028
const serializedMetrics = createExportMetricsServiceRequest(readableMetrics);
3129
```
3230

33-
### Create gRPC Service Clients
34-
35-
This module also contains gRPC service clients for exporting traces and metrics to an OpenTelemetry collector or compatible receiver over gRPC.
36-
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.
37-
Any RPC implementation compatible with `grpc` or `@grpc/grpc-js` may be used, but `@grpc/grpc-js` is recommended.
38-
39-
```typescript
40-
import type { RPCImpl } from 'protobufjs';
41-
import { makeGenericClientConstructor, credentials } from '@gprc/grpc-js';
42-
import { MetricServiceClient, TraceServiceClient } from "@opentelemetry/otlp-transformer";
43-
44-
// Construct a RPC Implementation according to protobufjs docs
45-
const GrpcClientConstructor = makeGenericClientConstructor({});
46-
47-
const metricGRPCClient = new GrpcClientConstructor(
48-
"http://localhost:4317/v1/metrics", // default collector metrics endpoint
49-
credentials.createInsecure(),
50-
);
51-
52-
const traceGRPCClient = new GrpcClientConstructor(
53-
"http://localhost:4317/v1/traces", // default collector traces endpoint
54-
credentials.createInsecure(),
55-
);
56-
57-
const metricRpc: RPCImpl = function(method, requestData, callback) {
58-
metricGRPCClient.makeUnaryRequest(
59-
method.name,
60-
arg => arg,
61-
arg => arg,
62-
requestData,
63-
callback
64-
);
65-
}
66-
67-
const traceRpc: RPCImpl = function(method, requestData, callback) {
68-
traceGRPCClient.makeUnaryRequest(
69-
method.name,
70-
arg => arg,
71-
arg => arg,
72-
requestData,
73-
callback
74-
);
75-
}
76-
77-
// Construct service clients to use RPC Implementations
78-
const metricServiceClient = new MetricServiceClient({
79-
rpcImpl: metricRpc,
80-
startTime: Date.now(), // exporter start time in milliseconds
81-
});
82-
83-
const traceServiceClient = new TraceServiceClient({
84-
rpcImpl: traceRpc,
85-
});
86-
87-
// Export ReadableSpan[] and ReadableMetric[] over gRPC
88-
await metricServiceClient.export(readableMetrics);
89-
await traceServiceClient.export(readableSpans);
90-
```
91-
9231
## Useful links
9332

9433
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
@@ -107,9 +46,3 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
10746

10847
[sdk]: https://github.com/open-telemetry/opentelemetry-js
10948
[otlp]: https://github.com/open-telemetry/opentelemetry-proto
110-
111-
[protobuf]: https://developers.google.com/protocol-buffers
112-
[grpc]: https://grpc.io/
113-
114-
[protobufjs]: https://www.npmjs.com/package/protobufjs
115-
[grpc-js]: https://www.npmjs.com/package/@grpc/grpc-js

experimental/packages/otlp-transformer/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
"node": ">=8.12.0"
3939
},
4040
"files": [
41+
"build/esm/**/*.js",
42+
"build/esm/**/*.js.map",
43+
"build/esm/**/*.d.ts",
44+
"build/esnext/**/*.js",
45+
"build/esnext/**/*.js.map",
46+
"build/esnext/**/*.d.ts",
4147
"build/src/**/*.js",
4248
"build/src/**/*.js.map",
4349
"build/src/**/*.d.ts",

0 commit comments

Comments
 (0)