From 99bffbedc1e8fce96bc9db09e7a0829a19fa302e Mon Sep 17 00:00:00 2001 From: Bruno Luiz Silva Date: Wed, 9 Jun 2021 00:40:31 +0100 Subject: [PATCH 1/3] fix(exporter-collector-grpc): incorrect default URL after 0.20.0 update --- packages/opentelemetry-exporter-collector-grpc/README.md | 8 ++++---- .../src/CollectorMetricExporter.ts | 2 +- .../src/CollectorTraceExporter.ts | 2 +- .../test/CollectorTraceExporter.test.ts | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/opentelemetry-exporter-collector-grpc/README.md b/packages/opentelemetry-exporter-collector-grpc/README.md index 03a1bd41c4..1bd6b6a41f 100644 --- a/packages/opentelemetry-exporter-collector-grpc/README.md +++ b/packages/opentelemetry-exporter-collector-grpc/README.md @@ -27,7 +27,7 @@ const { BasicTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/tra const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector-grpc'); const collectorOptions = { - // url is optional and can be omitted - default is localhost:4317 + // url is optional and can be omitted - default is grpc://localhost:4317 url: ':', }; @@ -51,7 +51,7 @@ const { BasicTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/tra const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector-grpc'); const collectorOptions = { - // url is optional and can be omitted - default is localhost:4317 + // url is optional and can be omitted - default is grpc://localhost:4317 url: ':', credentials: grpc.credentials.createSsl(), }; @@ -91,7 +91,7 @@ const metadata = new grpc.Metadata(); metadata.set('k', 'v'); const collectorOptions = { - // url is optional and can be omitted - default is localhost:4317 + // url is optional and can be omitted - default is grpc://localhost:4317 url: ':', metadata, // // an optional grpc.Metadata object to be sent with each request }; @@ -116,7 +116,7 @@ The CollectorTraceExporter in Node expects the URL to only be the hostname. It w const { MeterProvider } = require('@opentelemetry/metrics'); const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector-grpc'); const collectorOptions = { - // url is optional and can be omitted - default is localhost:4317 + // url is optional and can be omitted - default is grpc://localhost:4317 url: ':', }; const exporter = new CollectorMetricExporter(collectorOptions); diff --git a/packages/opentelemetry-exporter-collector-grpc/src/CollectorMetricExporter.ts b/packages/opentelemetry-exporter-collector-grpc/src/CollectorMetricExporter.ts index 84a880c16d..f1c69386a9 100644 --- a/packages/opentelemetry-exporter-collector-grpc/src/CollectorMetricExporter.ts +++ b/packages/opentelemetry-exporter-collector-grpc/src/CollectorMetricExporter.ts @@ -24,7 +24,7 @@ import { CollectorExporterNodeBase } from './CollectorExporterNodeBase'; import { getEnv } from '@opentelemetry/core'; import { validateAndNormalizeUrl } from './util'; -const DEFAULT_COLLECTOR_URL = 'localhost:4317'; +const DEFAULT_COLLECTOR_URL = 'grpc://localhost:4317'; /** * Collector Metric Exporter for Node diff --git a/packages/opentelemetry-exporter-collector-grpc/src/CollectorTraceExporter.ts b/packages/opentelemetry-exporter-collector-grpc/src/CollectorTraceExporter.ts index aae731d10c..1fa1391671 100644 --- a/packages/opentelemetry-exporter-collector-grpc/src/CollectorTraceExporter.ts +++ b/packages/opentelemetry-exporter-collector-grpc/src/CollectorTraceExporter.ts @@ -24,7 +24,7 @@ import { CollectorExporterConfigNode, ServiceClientType } from './types'; import { getEnv } from '@opentelemetry/core'; import { validateAndNormalizeUrl } from './util'; -const DEFAULT_COLLECTOR_URL = 'localhost:4317'; +const DEFAULT_COLLECTOR_URL = 'grpc://localhost:4317'; /** * Collector Trace Exporter for Node diff --git a/packages/opentelemetry-exporter-collector-grpc/test/CollectorTraceExporter.test.ts b/packages/opentelemetry-exporter-collector-grpc/test/CollectorTraceExporter.test.ts index 1c91cae6a7..d0fa04559c 100644 --- a/packages/opentelemetry-exporter-collector-grpc/test/CollectorTraceExporter.test.ts +++ b/packages/opentelemetry-exporter-collector-grpc/test/CollectorTraceExporter.test.ts @@ -204,7 +204,7 @@ describe('CollectorTraceExporter - node (getDefaultUrl)', () => { it('should default to localhost', done => { const collectorExporter = new CollectorTraceExporter({}); setTimeout(() => { - assert.strictEqual(collectorExporter['url'], 'localhost:4317'); + assert.strictEqual(collectorExporter['url'], 'grpc://localhost:4317'); done(); }); }); From db634218cdbc9fbea113ccd83a9264cd94cb3715 Mon Sep 17 00:00:00 2001 From: Bruno Luiz Silva Date: Wed, 9 Jun 2021 12:25:52 +0100 Subject: [PATCH 2/3] fix collector metric exporter test assertion --- .../test/CollectorMetricExporter.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opentelemetry-exporter-collector-grpc/test/CollectorMetricExporter.test.ts b/packages/opentelemetry-exporter-collector-grpc/test/CollectorMetricExporter.test.ts index a0cb218a7e..1564680b8f 100644 --- a/packages/opentelemetry-exporter-collector-grpc/test/CollectorMetricExporter.test.ts +++ b/packages/opentelemetry-exporter-collector-grpc/test/CollectorMetricExporter.test.ts @@ -242,7 +242,7 @@ describe('CollectorMetricExporter - node (getDefaultUrl)', () => { it('should default to localhost', done => { const collectorExporter = new CollectorMetricExporter({}); setTimeout(() => { - assert.strictEqual(collectorExporter['url'], 'localhost:4317'); + assert.strictEqual(collectorExporter['url'], 'grpc://localhost:4317'); done(); }); }); From 3aa9ff3ec0ea6376be0ba5d137d76ed882c36c61 Mon Sep 17 00:00:00 2001 From: Bruno Luiz Silva Date: Wed, 30 Jun 2021 18:03:06 +0100 Subject: [PATCH 3/3] chore: add changes to README and revert other changes --- packages/opentelemetry-exporter-collector-grpc/README.md | 8 ++++---- .../src/CollectorMetricExporter.ts | 2 +- .../src/CollectorTraceExporter.ts | 2 +- .../test/CollectorMetricExporter.test.ts | 2 +- .../test/CollectorTraceExporter.test.ts | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/opentelemetry-exporter-collector-grpc/README.md b/packages/opentelemetry-exporter-collector-grpc/README.md index 1bd6b6a41f..f6bb5c842d 100644 --- a/packages/opentelemetry-exporter-collector-grpc/README.md +++ b/packages/opentelemetry-exporter-collector-grpc/README.md @@ -28,7 +28,7 @@ const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector-g const collectorOptions = { // url is optional and can be omitted - default is grpc://localhost:4317 - url: ':', + url: 'grpc://:', }; const provider = new BasicTracerProvider(); @@ -52,7 +52,7 @@ const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector-g const collectorOptions = { // url is optional and can be omitted - default is grpc://localhost:4317 - url: ':', + url: 'grpc://:', credentials: grpc.credentials.createSsl(), }; @@ -92,7 +92,7 @@ metadata.set('k', 'v'); const collectorOptions = { // url is optional and can be omitted - default is grpc://localhost:4317 - url: ':', + url: 'grpc://:', metadata, // // an optional grpc.Metadata object to be sent with each request }; @@ -117,7 +117,7 @@ const { MeterProvider } = require('@opentelemetry/metrics'); const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector-grpc'); const collectorOptions = { // url is optional and can be omitted - default is grpc://localhost:4317 - url: ':', + url: 'grpc://:', }; const exporter = new CollectorMetricExporter(collectorOptions); diff --git a/packages/opentelemetry-exporter-collector-grpc/src/CollectorMetricExporter.ts b/packages/opentelemetry-exporter-collector-grpc/src/CollectorMetricExporter.ts index f1c69386a9..84a880c16d 100644 --- a/packages/opentelemetry-exporter-collector-grpc/src/CollectorMetricExporter.ts +++ b/packages/opentelemetry-exporter-collector-grpc/src/CollectorMetricExporter.ts @@ -24,7 +24,7 @@ import { CollectorExporterNodeBase } from './CollectorExporterNodeBase'; import { getEnv } from '@opentelemetry/core'; import { validateAndNormalizeUrl } from './util'; -const DEFAULT_COLLECTOR_URL = 'grpc://localhost:4317'; +const DEFAULT_COLLECTOR_URL = 'localhost:4317'; /** * Collector Metric Exporter for Node diff --git a/packages/opentelemetry-exporter-collector-grpc/src/CollectorTraceExporter.ts b/packages/opentelemetry-exporter-collector-grpc/src/CollectorTraceExporter.ts index 1fa1391671..aae731d10c 100644 --- a/packages/opentelemetry-exporter-collector-grpc/src/CollectorTraceExporter.ts +++ b/packages/opentelemetry-exporter-collector-grpc/src/CollectorTraceExporter.ts @@ -24,7 +24,7 @@ import { CollectorExporterConfigNode, ServiceClientType } from './types'; import { getEnv } from '@opentelemetry/core'; import { validateAndNormalizeUrl } from './util'; -const DEFAULT_COLLECTOR_URL = 'grpc://localhost:4317'; +const DEFAULT_COLLECTOR_URL = 'localhost:4317'; /** * Collector Trace Exporter for Node diff --git a/packages/opentelemetry-exporter-collector-grpc/test/CollectorMetricExporter.test.ts b/packages/opentelemetry-exporter-collector-grpc/test/CollectorMetricExporter.test.ts index 1564680b8f..a0cb218a7e 100644 --- a/packages/opentelemetry-exporter-collector-grpc/test/CollectorMetricExporter.test.ts +++ b/packages/opentelemetry-exporter-collector-grpc/test/CollectorMetricExporter.test.ts @@ -242,7 +242,7 @@ describe('CollectorMetricExporter - node (getDefaultUrl)', () => { it('should default to localhost', done => { const collectorExporter = new CollectorMetricExporter({}); setTimeout(() => { - assert.strictEqual(collectorExporter['url'], 'grpc://localhost:4317'); + assert.strictEqual(collectorExporter['url'], 'localhost:4317'); done(); }); }); diff --git a/packages/opentelemetry-exporter-collector-grpc/test/CollectorTraceExporter.test.ts b/packages/opentelemetry-exporter-collector-grpc/test/CollectorTraceExporter.test.ts index d0fa04559c..1c91cae6a7 100644 --- a/packages/opentelemetry-exporter-collector-grpc/test/CollectorTraceExporter.test.ts +++ b/packages/opentelemetry-exporter-collector-grpc/test/CollectorTraceExporter.test.ts @@ -204,7 +204,7 @@ describe('CollectorTraceExporter - node (getDefaultUrl)', () => { it('should default to localhost', done => { const collectorExporter = new CollectorTraceExporter({}); setTimeout(() => { - assert.strictEqual(collectorExporter['url'], 'grpc://localhost:4317'); + assert.strictEqual(collectorExporter['url'], 'localhost:4317'); done(); }); });