diff --git a/packages/opentelemetry-exporter-collector/README.md b/packages/opentelemetry-exporter-collector/README.md index f03ad15e5a5..71195887a38 100644 --- a/packages/opentelemetry-exporter-collector/README.md +++ b/packages/opentelemetry-exporter-collector/README.md @@ -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'; @@ -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: '' // url is optional and can be omitted - default is http://localhost:55678 + url: '' // url is optional and can be omitted - default is localhost:55678 }; const provider = new BasicTracerProvider(); @@ -58,7 +60,7 @@ const { CollectorExporter } = require('@opentelemetry/exporter-collector'); const collectorOptions = { serviceName: 'basic-service', - url: '', // url is optional and can be omitted - default is http://localhost:55678/v1/trace + url: '', // url is optional and can be omitted - default is localhost:55678 credentials: grpc.credentials.createSsl( fs.readFileSync('./ca.crt'), fs.readFileSync('./client.key'), diff --git a/packages/opentelemetry-exporter-collector/src/CollectorExporterBase.ts b/packages/opentelemetry-exporter-collector/src/CollectorExporterBase.ts index 096a5d3b305..8dff3e58e16 100644 --- a/packages/opentelemetry-exporter-collector/src/CollectorExporterBase.ts +++ b/packages/opentelemetry-exporter-collector/src/CollectorExporterBase.ts @@ -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; } @@ -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; } diff --git a/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorExporter.ts b/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorExporter.ts index e854d358c11..ec2cd5437ff 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorExporter.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorExporter.ts @@ -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; } diff --git a/packages/opentelemetry-exporter-collector/src/platform/node/CollectorExporter.ts b/packages/opentelemetry-exporter-collector/src/platform/node/CollectorExporter.ts index 1207ae2fccb..cb918e6e68c 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/node/CollectorExporter.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/node/CollectorExporter.ts @@ -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 @@ -138,7 +138,7 @@ export class CollectorExporter extends CollectorExporterBase< } } - defaultURL(url: string | undefined): string { + setDefaultUrl(url: string | undefined): string { return url || DEFAULT_COLLECTOR_URL; } } diff --git a/packages/opentelemetry-exporter-collector/test/common/CollectorExporter.test.ts b/packages/opentelemetry-exporter-collector/test/common/CollectorExporter.test.ts index 0a0e9efe935..d14077d7ba5 100644 --- a/packages/opentelemetry-exporter-collector/test/common/CollectorExporter.test.ts +++ b/packages/opentelemetry-exporter-collector/test/common/CollectorExporter.test.ts @@ -30,7 +30,7 @@ class CollectorExporter extends CollectorExporterBase { onInit() {} onShutdown() {} sendSpans() {} - defaultURL(url: string | undefined) { + setDefaultUrl(url: string | undefined) { return url || ''; } }