Skip to content

Commit

Permalink
Change default URL
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwitten committed Jun 15, 2020
1 parent 478f074 commit ac9f12f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/opentelemetry-exporter-collector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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 http://localhost:55678
};

const provider = new BasicTracerProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export interface CollectorExporterConfigBase {
}

const DEFAULT_SERVICE_NAME = 'collector-exporter';
const DEFAULT_COLLECTOR_URL = 'http://localhost:55678/v1/trace';

/**
* Collector Exporter abstract base class
Expand All @@ -51,7 +50,7 @@ export abstract class CollectorExporterBase<
*/
constructor(config: T = {} as T) {
this.serviceName = config.serviceName || DEFAULT_SERVICE_NAME;
this.url = config.url || DEFAULT_COLLECTOR_URL;
this.url = this.defaultURL(config.url);
if (typeof config.hostName === 'string') {
this.hostName = config.hostName;
}
Expand Down Expand Up @@ -135,4 +134,5 @@ export abstract class CollectorExporterBase<
onSuccess: () => void,
onError: (error: CollectorExporterError) => void
): void;
abstract defaultURL(url: string | undefined): string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import * as collectorTypes from '../../types';

export type CollectorExporterConfig = CollectorExporterConfigBase;

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

/**
* Collector Exporter for Web
*/
Expand All @@ -38,6 +40,10 @@ export class CollectorExporter extends CollectorExporterBase<
window.removeEventListener('unload', this.shutdown);
}

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

sendSpans(
spans: ReadableSpan[],
onSuccess: () => void,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import { toCollectorExportTraceServiceRequest } from '../../transform';
import { GRPCQueueItem, TraceServiceClient } from './types';
import { removeProtocol } from './util';

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

/**
* Collector Exporter Config for Node
*/
Expand Down Expand Up @@ -135,4 +137,8 @@ export class CollectorExporter extends CollectorExporterBase<
});
}
}

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

0 comments on commit ac9f12f

Please sign in to comment.