Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: rename collector exporters #2476

Merged
merged 4 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "packages/opentelemetry-exporter-collector-grpc/protos"]
path = packages/opentelemetry-exporter-collector-grpc/protos
[submodule "packages/opentelemetry-exporter-otlp-grpc/protos"]
path = packages/opentelemetry-exporter-otlp-grpc/protos
url = https://github.com/open-telemetry/opentelemetry-proto.git
[submodule "packages/opentelemetry-exporter-collector-proto/protos"]
path = packages/opentelemetry-exporter-collector-proto/protos
[submodule "packages/opentelemetry-exporter-otlp-proto/protos"]
path = packages/opentelemetry-exporter-otlp-proto/protos
url = https://github.com/open-telemetry/opentelemetry-proto.git
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ Some types exported from `"@opentelemetry/api"` have been changed to be more spe

### 0.15.0 to 0.16.0

[PR-1863](https://github.com/open-telemetry/opentelemetry-js/pull/1863) removed public attributes `keepAlive` and `httpAgentOptions` from nodejs `CollectorTraceExporter` and `CollectorMetricExporter`
dyladan marked this conversation as resolved.
Show resolved Hide resolved
[PR-1863](https://github.com/open-telemetry/opentelemetry-js/pull/1863) removed public attributes `keepAlive` and `httpAgentOptions` from nodejs `OTLPTraceExporter` and `OTLPMetricExporter`

### 0.14.0 to 0.15.0

Expand All @@ -457,7 +457,7 @@ Some types exported from `"@opentelemetry/api"` have been changed to be more spe

[PR-1725](https://github.com/open-telemetry/opentelemetry-js/pull/1725) Use new gRPC default port

- The default port used by `@opentelemetry/exporter-collector-grpc` is changed from `55680` to `4317`
dyladan marked this conversation as resolved.
Show resolved Hide resolved
- The default port used by `@opentelemetry/exporter-otlp-grpc` is changed from `55680` to `4317`

[PR-1749](https://github.com/open-telemetry/opentelemetry-js/pull/1749) chore: improve naming of span related context APIs

Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use the latest and greatest features, and best practices.
|[http](http/) | HTTP Instrumentation to automatically collect trace data and export them to the backend of choice | Intermediate |
|[https](https/) | HTTPS Instrumentation to automatically collect trace data and export them to the backend of choice | Intermediate |
|[grpc](grpc/) | gRPC Instrumentation to automatically collect trace data and export them to the backend of choice | Intermediate |
|[collector-exporter-node](collector-exporter-node/) | This example shows how to use `@opentelemetry/exporter-collector` to instrument a simple Node.js application | Intermediate |
|[otlp-exporter-node](otlp-exporter-node/) | This example shows how to use `@opentelemetry/exporter-otlp-http` to instrument a simple Node.js application | Intermediate |
|[opentracing-shim](opentracing-shim/) | This is a simple example that demonstrates how existing OpenTracing instrumentation can be integrated with OpenTelemetry | Intermediate |

Additional examples can be found at [@opentelemetry/opentelemetry-js-contrib][opentelemetry-js-contrib-examples]
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-tracer-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ Click on the trace to view its details.

Apache License 2.0

[opentelemetry-collector-url]: https://github.com/open-telemetry/opentelemetry-exporter-collector
[opentelemetry-collector-url]: https://github.com/open-telemetry/opentelemetry-exporter-otlp-http
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Overview

This example shows how to use [@opentelemetry/exporter-collector](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-exporter-collector) to instrument a simple Node.js application.
This example shows how to use [@opentelemetry/exporter-otlp-http](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-exporter-otlp-http) to instrument a simple Node.js application.

This example will export spans data simultaneously using [Exporter Collector](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-exporter-collector) and grpc. It will use [proto format](https://github.com/open-telemetry/opentelemetry-proto).
This example will export spans data simultaneously using [Exporter Collector](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-exporter-otlp-http) and grpc. It will use [proto format](https://github.com/open-telemetry/opentelemetry-proto).

## Installation

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
'use strict';

const { DiagConsoleLogger, DiagLogLevel, diag } = require('@opentelemetry/api');
const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector');
// const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector-grpc');
// const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector-proto');
const { OTLPMetricExporter } = require('@opentelemetry/exporter-otlp-http');
// const { OTLPMetricExporter } = require('@opentelemetry/exporter-otlp-grpc');
// const { OTLPMetricExporter } = require('@opentelemetry/exporter-otlp-proto');
const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');

// Optional and only needed to see the internal diagnostic logging (during development)
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);

const metricExporter = new CollectorMetricExporter({
const metricExporter = new OTLPMetricExporter({
// url: 'http://localhost:55681/v1/metrics',
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "example-collector-exporter-node",
"name": "example-otlp-exporter-node",
"private": true,
"version": "0.25.0",
"description": "Example of using @opentelemetry/collector-exporter in Node.js",
Expand Down Expand Up @@ -30,9 +30,9 @@
"dependencies": {
"@opentelemetry/api": "^1.0.2",
"@opentelemetry/core": "0.25.0",
"@opentelemetry/exporter-collector": "0.25.0",
"@opentelemetry/exporter-collector-grpc": "0.25.0",
"@opentelemetry/exporter-collector-proto": "0.25.0",
"@opentelemetry/exporter-otlp-http": "0.25.0",
"@opentelemetry/exporter-otlp-grpc": "0.25.0",
"@opentelemetry/exporter-otlp-proto": "0.25.0",
"@opentelemetry/resources": "0.25.0",
"@opentelemetry/semantic-conventions": "0.25.0",
"@opentelemetry/sdk-metrics-base": "0.25.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

const opentelemetry = require('@opentelemetry/api');
const { BasicTracerProvider, ConsoleSpanExporter, SimpleSpanProcessor } = require('@opentelemetry/sdk-trace-base');
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-otlp-http');
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
// const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector-grpc');
// const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector-proto');
// const { OTLPTraceExporter } = require('@opentelemetry/exporter-otlp-grpc');
// const { OTLPTraceExporter } = require('@opentelemetry/exporter-otlp-proto');

// opentelemetry.diag.setLogger(
// new opentelemetry.DiagConsoleLogger(),
// opentelemetry.DiagLogLevel.DEBUG,
// );

const exporter = new CollectorTraceExporter({
const exporter = new OTLPTraceExporter({
// headers: {
// foo: 'bar'
// },
Expand All @@ -28,7 +28,7 @@ provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
provider.register();

const tracer = opentelemetry.trace.getTracer('example-collector-exporter-node');
const tracer = opentelemetry.trace.getTracer('example-otlp-exporter-node');

// Create a span. A span must be closed.
const parentSpan = tracer.startSpan('main');
Expand Down
4 changes: 2 additions & 2 deletions examples/tracer-web/examples/fetch/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
import { context, trace } from '@opentelemetry/api';
import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
import { CollectorTraceExporter } from '@opentelemetry/exporter-collector';
import { OTLPTraceExporter } from '@opentelemetry/exporter-otlp-http';
import { WebTracerProvider } from '@opentelemetry/sdk-trace-web';
import { FetchInstrumentation } from '@opentelemetry/instrumentation-fetch';
import { ZoneContextManager } from '@opentelemetry/context-zone';
Expand All @@ -10,7 +10,7 @@ import { registerInstrumentations } from '@opentelemetry/instrumentation';

const provider = new WebTracerProvider();
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
provider.addSpanProcessor(new SimpleSpanProcessor(new CollectorTraceExporter()));
provider.addSpanProcessor(new SimpleSpanProcessor(new OTLPTraceExporter()));
provider.register({
contextManager: new ZoneContextManager(),
propagator: new B3Propagator(),
Expand Down
2 changes: 1 addition & 1 deletion examples/tracer-web/examples/metrics/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<button id="stopBtn">Stop metrics</button>
<br/>

If you run the collector from example "opentelemetry-exporter-collector" you should see traces at: <br/>
If you run the collector from example "opentelemetry-exporter-otlp-http" you should see traces at: <br/>
<a href="http://localhost:9090/graph?g0.range_input=1m&g0.expr=requests&g0.tab=0/" target="_blank">http://localhost:9090/</a>

</body>
Expand Down
4 changes: 2 additions & 2 deletions examples/tracer-web/examples/metrics/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use strict';

const { DiagConsoleLogger, DiagLogLevel, diag } = require('@opentelemetry/api');
const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector');
const { OTLPMetricExporter } = require('@opentelemetry/exporter-otlp-http');
const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');

// Optional and only needed to see the internal diagnostic logging (during development)
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);

const metricExporter = new CollectorMetricExporter();
const metricExporter = new OTLPMetricExporter();

let interval;
let meter;
Expand Down
4 changes: 2 additions & 2 deletions examples/tracer-web/examples/xml-http-request/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/sdk-tra
import { WebTracerProvider } from '@opentelemetry/sdk-trace-web';
import { XMLHttpRequestInstrumentation } from '@opentelemetry/instrumentation-xml-http-request';
import { ZoneContextManager } from '@opentelemetry/context-zone';
import { CollectorTraceExporter } from '@opentelemetry/exporter-collector';
import { OTLPTraceExporter } from '@opentelemetry/exporter-otlp-http';
import { B3Propagator } from '@opentelemetry/propagator-b3';
import { registerInstrumentations } from '@opentelemetry/instrumentation';

const providerWithZone = new WebTracerProvider();
providerWithZone.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
providerWithZone.addSpanProcessor(new SimpleSpanProcessor(new CollectorTraceExporter()));
providerWithZone.addSpanProcessor(new SimpleSpanProcessor(new OTLPTraceExporter()));

providerWithZone.register({
contextManager: new ZoneContextManager(),
Expand Down
2 changes: 1 addition & 1 deletion examples/tracer-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@opentelemetry/api": "^1.0.2",
"@opentelemetry/context-zone": "0.25.0",
"@opentelemetry/core": "0.25.0",
"@opentelemetry/exporter-collector": "0.25.0",
"@opentelemetry/exporter-otlp-http": "0.25.0",
"@opentelemetry/exporter-zipkin": "0.25.0",
"@opentelemetry/instrumentation": "0.25.0",
"@opentelemetry/instrumentation-fetch": "0.25.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This module provides exporter for web and node to be used with [opentelemetry-co
## Installation

```bash
npm install --save @opentelemetry/exporter-collector-grpc
npm install --save @opentelemetry/exporter-otlp-grpc
```

## Service Name
Expand All @@ -20,19 +20,19 @@ In order to set the service name, use the `service.name` resource attribute as p

## Traces in Node - GRPC

The CollectorTraceExporter in Node expects the URL to only be the hostname. It will not work with `/v1/traces`.
The OTLPTraceExporter in Node expects the URL to only be the hostname. It will not work with `/v1/traces`.

```js
const { BasicTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/sdk-trace-base');
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector-grpc');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-otlp-grpc');

const collectorOptions = {
// url is optional and can be omitted - default is grpc://localhost:4317
url: 'grpc://<collector-hostname>:<port>',
};

const provider = new BasicTracerProvider();
const exporter = new CollectorTraceExporter(collectorOptions);
const exporter = new OTLPTraceExporter(collectorOptions);
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));

provider.register();
Expand All @@ -48,7 +48,7 @@ const fs = require('fs');
const grpc = require('@grpc/grpc-js');

const { BasicTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/sdk-trace-base');
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector-grpc');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-otlp-grpc');

const collectorOptions = {
// url is optional and can be omitted - default is grpc://localhost:4317
Expand All @@ -57,7 +57,7 @@ const collectorOptions = {
};

const provider = new BasicTracerProvider();
const exporter = new CollectorTraceExporter(collectorOptions);
const exporter = new OTLPTraceExporter(collectorOptions);
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));

provider.register();
Expand All @@ -84,7 +84,7 @@ The exporter can be configured to send custom metadata with each request as in t
const grpc = require('@grpc/grpc-js');

const { BasicTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/sdk-trace-base');
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector-grpc');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-otlp-grpc');

const metadata = new grpc.Metadata();
// For instance, an API key or access token might go here.
Expand All @@ -97,7 +97,7 @@ const collectorOptions = {
};

const provider = new BasicTracerProvider();
const exporter = new CollectorTraceExporter(collectorOptions);
const exporter = new OTLPTraceExporter(collectorOptions);
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));

provider.register();
Expand All @@ -110,16 +110,16 @@ Note, that this will only work if TLS is also configured on the server.

## Metrics in Node - GRPC

The CollectorTraceExporter 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.
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.

```js
const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector-grpc');
const { OTLPMetricExporter } = require('@opentelemetry/exporter-otlp-grpc');
const collectorOptions = {
// url is optional and can be omitted - default is grpc://localhost:4317
url: 'grpc://<collector-hostname>:<port>',
};
const exporter = new CollectorMetricExporter(collectorOptions);
const exporter = new OTLPMetricExporter(collectorOptions);

// Register the exporter
const provider = new MeterProvider({
Expand All @@ -138,7 +138,7 @@ counter.add(10, { 'key': 'value' });

## Running opentelemetry-collector locally to see the traces

1. Go to examples/collector-exporter-node
1. Go to examples/otlp-exporter-node
2. run `npm run docker:start`
3. Open page at `http://localhost:9411/zipkin/` to observe the traces

Expand All @@ -155,11 +155,11 @@ 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
[dependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=packages%2Fopentelemetry-exporter-collector-grpc
[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-exporter-collector-grpc
[devDependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=packages%2Fopentelemetry-exporter-collector-grpc&type=dev
[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-exporter-collector-grpc&type=dev
[npm-url]: https://www.npmjs.com/package/@opentelemetry/exporter-collector-grpc
[dependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=packages%2Fopentelemetry-exporter-otlp-grpc
[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-exporter-otlp-grpc
[devDependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=packages%2Fopentelemetry-exporter-otlp-grpc&type=dev
[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-exporter-otlp-grpc&type=dev
[npm-url]: https://www.npmjs.com/package/@opentelemetry/exporter-otlp-grpc
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fexporter-collector-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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@opentelemetry/exporter-collector-grpc",
"name": "@opentelemetry/exporter-otlp-grpc",
"version": "0.25.0",
"description": "OpenTelemetry Collector Exporter allows user to send collected traces to the OpenTelemetry Collector",
"main": "build/src/index.js",
Expand Down Expand Up @@ -70,7 +70,7 @@
"@grpc/grpc-js": "^1.3.7",
"@grpc/proto-loader": "^0.6.4",
"@opentelemetry/core": "0.25.0",
"@opentelemetry/exporter-collector": "0.25.0",
"@opentelemetry/exporter-otlp-http": "0.25.0",
"@opentelemetry/sdk-metrics-base": "0.25.0",
"@opentelemetry/resources": "0.25.0",
"@opentelemetry/sdk-trace-base": "0.25.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@

import { diag } from '@opentelemetry/api';
import {
CollectorExporterBase,
OTLPExporterBase,
collectorTypes,
} from '@opentelemetry/exporter-collector';
} from '@opentelemetry/exporter-otlp-http';
import { Metadata } from '@grpc/grpc-js';
import {
CollectorExporterConfigNode,
OTLPExporterConfigNode,
GRPCQueueItem,
ServiceClientType,
} from './types';
import { ServiceClient } from './types';
import { getEnv, baggageUtils } from '@opentelemetry/core';

/**
* Collector Metric Exporter abstract base class
* OTLP Metric Exporter abstract base class
*/
export abstract class CollectorExporterNodeBase<
export abstract class OTLPExporterNodeBase<
ExportItem,
ServiceRequest
> extends CollectorExporterBase<
CollectorExporterConfigNode,
> extends OTLPExporterBase<
OTLPExporterConfigNode,
ExportItem,
ServiceRequest
> {
Expand All @@ -44,7 +44,7 @@ export abstract class CollectorExporterNodeBase<
serviceClient?: ServiceClient = undefined;
private _send!: Function;

constructor(config: CollectorExporterConfigNode = {}) {
constructor(config: OTLPExporterConfigNode = {}) {
super(config);
if (config.headers) {
diag.warn('Headers cannot be set when using grpc');
Expand Down Expand Up @@ -74,7 +74,7 @@ export abstract class CollectorExporterNodeBase<
promise.then(popPromise, popPromise);
}

onInit(config: CollectorExporterConfigNode): void {
onInit(config: OTLPExporterConfigNode): void {
this._isShutdown = false;
// defer to next tick and lazy load to avoid loading grpc too early
// and making this impossible to be instrumented
Expand Down
Loading