Skip to content

Commit

Permalink
Addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwitten committed Jun 15, 2020
1 parent f983d37 commit fa10cb3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions packages/opentelemetry-exporter-collector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ npm install --save @opentelemetry/exporter-collector
```

## Usage in Web
The CollectorExporter in Web expects the endpoint to end in `/v1/trace`.
```js
import { SimpleSpanProcessor } from '@opentelemetry/tracing';
import { WebTracerProvider } from '@opentelemetry/web';
Expand All @@ -32,13 +33,14 @@ provider.register();
```

## Usage in Node
The CollectorExporter in Node expects the URL to only be the endpoint. It will not work with `/v1/trace`.
```js
const { BasicTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { CollectorExporter } = require('@opentelemetry/exporter-collector');

const collectorOptions = {
serviceName: 'basic-service',
url: '<opentelemetry-collector-url>' // url is optional and can be omitted - default is http://localhost:55678
url: '<opentelemetry-collector-url>' // url is optional and can be omitted - default is localhost:55678
};

const provider = new BasicTracerProvider();
Expand All @@ -58,7 +60,7 @@ const { CollectorExporter } = require('@opentelemetry/exporter-collector');

const collectorOptions = {
serviceName: 'basic-service',
url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:55678/v1/trace
url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is localhost:55678
credentials: grpc.credentials.createSsl(
fs.readFileSync('./ca.crt'),
fs.readFileSync('./client.key'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export abstract class CollectorExporterBase<
*/
constructor(config: T = {} as T) {
this.serviceName = config.serviceName || DEFAULT_SERVICE_NAME;
this.url = this.defaultURL(config.url);
this.url = this.setDefaultUrl(config.url);
if (typeof config.hostName === 'string') {
this.hostName = config.hostName;
}
Expand Down Expand Up @@ -134,5 +134,5 @@ export abstract class CollectorExporterBase<
onSuccess: () => void,
onError: (error: CollectorExporterError) => void
): void;
abstract defaultURL(url: string | undefined): string;
abstract setDefaultUrl(url: string | undefined): string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class CollectorExporter extends CollectorExporterBase<
window.removeEventListener('unload', this.shutdown);
}

defaultURL(url: string | undefined) {
setDefaultUrl(url: string | undefined) {
return url || DEFAULT_COLLECTOR_URL;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { toCollectorExportTraceServiceRequest } from '../../transform';
import { GRPCQueueItem, TraceServiceClient } from './types';
import { removeProtocol } from './util';

const DEFAULT_COLLECTOR_URL = 'http://localhost:55678';
const DEFAULT_COLLECTOR_URL = 'localhost:55678';

/**
* Collector Exporter Config for Node
Expand Down Expand Up @@ -138,7 +138,7 @@ export class CollectorExporter extends CollectorExporterBase<
}
}

defaultURL(url: string | undefined): string {
setDefaultUrl(url: string | undefined): string {
return url || DEFAULT_COLLECTOR_URL;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CollectorExporter extends CollectorExporterBase<CollectorExporterConfig> {
onInit() {}
onShutdown() {}
sendSpans() {}
defaultURL(url: string | undefined) {
setDefaultUrl(url: string | undefined) {
return url || '';
}
}
Expand Down

0 comments on commit fa10cb3

Please sign in to comment.