From 5aa851a155dae3b8a9f11b974dc23f520c9d36a0 Mon Sep 17 00:00:00 2001 From: Julien FABRE Date: Mon, 29 Jun 2020 23:28:58 +0200 Subject: [PATCH] fix: default url for otelcol (#1254) * fix: default url for otelcol * docs: review example from default url otelcol Co-authored-by: Mayur Kale --- .../docker/collector-config.yaml | 3 +-- .../docker/docker-compose.yaml | 15 ++++++++++----- examples/collector-exporter-node/package.json | 2 +- examples/collector-exporter-node/start.js | 5 +++-- .../opentelemetry-exporter-collector/README.md | 8 ++++---- .../platform/browser/CollectorTraceExporter.ts | 2 +- .../src/platform/node/CollectorTraceExporter.ts | 2 +- .../src/platform/node/protos | 2 +- .../test/browser/CollectorTraceExporter.test.ts | 2 +- .../test/node/CollectorTraceExporter.test.ts | 2 +- 10 files changed, 24 insertions(+), 19 deletions(-) diff --git a/examples/collector-exporter-node/docker/collector-config.yaml b/examples/collector-exporter-node/docker/collector-config.yaml index 2f64d8b4fc..8ea773375b 100644 --- a/examples/collector-exporter-node/docker/collector-config.yaml +++ b/examples/collector-exporter-node/docker/collector-config.yaml @@ -1,6 +1,5 @@ receivers: - otlp: - endpoint: 0.0.0.0:55678 + otlp: {} exporters: zipkin: diff --git a/examples/collector-exporter-node/docker/docker-compose.yaml b/examples/collector-exporter-node/docker/docker-compose.yaml index fee8f1aca0..53c635a0f4 100644 --- a/examples/collector-exporter-node/docker/docker-compose.yaml +++ b/examples/collector-exporter-node/docker/docker-compose.yaml @@ -1,19 +1,24 @@ -version: "2" +version: "3" services: - # Collector collector: - image: omnition/opentelemetry-collector-contrib:0.2.8 + image: otel/opentelemetry-collector:0.4.0 + networks: + - otelcol command: ["--config=/conf/collector-config.yaml", "--log-level=DEBUG"] volumes: - ./collector-config.yaml:/conf/collector-config.yaml ports: - - "55678:55678" + - "55680:55680" depends_on: - zipkin-all-in-one - # Zipkin zipkin-all-in-one: image: openzipkin/zipkin:latest + networks: + - otelcol ports: - "9411:9411" + +networks: + otelcol: diff --git a/examples/collector-exporter-node/package.json b/examples/collector-exporter-node/package.json index a10b08b64b..a30ad9a0b4 100644 --- a/examples/collector-exporter-node/package.json +++ b/examples/collector-exporter-node/package.json @@ -6,7 +6,7 @@ "main": "index.js", "scripts": { "start": "node ./start.js", - "docker:start": "cd ./docker && docker-compose down && docker-compose up", + "docker:start": "cd ./docker && docker-compose down && docker-compose up -d", "docker:stop": "cd ./docker && docker-compose down" }, "repository": { diff --git a/examples/collector-exporter-node/start.js b/examples/collector-exporter-node/start.js index 5ff85ec123..637a489cf6 100644 --- a/examples/collector-exporter-node/start.js +++ b/examples/collector-exporter-node/start.js @@ -1,10 +1,10 @@ 'use strict'; const opentelemetry = require('@opentelemetry/api'); -const { BasicTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/tracing'); +const { BasicTracerProvider, ConsoleSpanExporter, SimpleSpanProcessor } = require('@opentelemetry/tracing'); const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector'); -const address = '127.0.0.1:55678'; +const address = '127.0.0.1:55680'; const exporter = new CollectorTraceExporter({ serviceName: 'basic-service', url: address, @@ -12,6 +12,7 @@ const exporter = new CollectorTraceExporter({ const provider = new BasicTracerProvider(); provider.addSpanProcessor(new SimpleSpanProcessor(exporter)); +provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter())); provider.register(); const tracer = opentelemetry.trace.getTracer('example-collector-exporter-node'); diff --git a/packages/opentelemetry-exporter-collector/README.md b/packages/opentelemetry-exporter-collector/README.md index a3d0ecd6a3..7d198e2392 100644 --- a/packages/opentelemetry-exporter-collector/README.md +++ b/packages/opentelemetry-exporter-collector/README.md @@ -24,7 +24,7 @@ import { WebTracerProvider } from '@opentelemetry/web'; import { CollectorTraceExporter } from '@opentelemetry/exporter-collector'; const collectorOptions = { - 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 http://localhost:55680/v1/trace headers: {}, //an optional object containing custom headers to be sent with each request }; @@ -46,7 +46,7 @@ const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector') const collectorOptions = { serviceName: 'basic-service', - url: '' // url is optional and can be omitted - default is localhost:55678 + url: '' // url is optional and can be omitted - default is localhost:55680 }; const provider = new BasicTracerProvider(); @@ -67,7 +67,7 @@ const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector') const collectorOptions = { serviceName: 'basic-service', - url: '', // url is optional and can be omitted - default is localhost:55678 + url: '', // url is optional and can be omitted - default is localhost:55680 credentials: grpc.credentials.createSsl( fs.readFileSync('./ca.crt'), fs.readFileSync('./client.key'), @@ -96,7 +96,7 @@ metadata.set('k', 'v'); const collectorOptions = { serviceName: 'basic-service', - url: '', // url is optional and can be omitted - default is localhost:55678 + url: '', // url is optional and can be omitted - default is localhost:55680 metadata, // // an optional grpc.Metadata object to be sent with each request }; diff --git a/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorTraceExporter.ts b/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorTraceExporter.ts index 2d0a337f2b..b6d0e66f84 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorTraceExporter.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorTraceExporter.ts @@ -20,7 +20,7 @@ import { toCollectorExportTraceServiceRequest } from '../../transform'; import { CollectorExporterConfigBrowser } from '../../types'; import * as collectorTypes from '../../types'; -const DEFAULT_COLLECTOR_URL = 'http://localhost:55678/v1/trace'; +const DEFAULT_COLLECTOR_URL = 'http://localhost:55680/v1/trace'; /** * Collector Exporter for Web diff --git a/packages/opentelemetry-exporter-collector/src/platform/node/CollectorTraceExporter.ts b/packages/opentelemetry-exporter-collector/src/platform/node/CollectorTraceExporter.ts index 8659a97b71..3895389981 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/node/CollectorTraceExporter.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/node/CollectorTraceExporter.ts @@ -29,7 +29,7 @@ import { toCollectorExportTraceServiceRequest } from '../../transform'; import { GRPCSpanQueueItem, ServiceClient } from './types'; import { removeProtocol } from './util'; -const DEFAULT_COLLECTOR_URL = 'localhost:55678'; +const DEFAULT_COLLECTOR_URL = 'localhost:55680'; /** * Collector Trace Exporter for Node diff --git a/packages/opentelemetry-exporter-collector/src/platform/node/protos b/packages/opentelemetry-exporter-collector/src/platform/node/protos index b546885691..e6c3c4a74d 160000 --- a/packages/opentelemetry-exporter-collector/src/platform/node/protos +++ b/packages/opentelemetry-exporter-collector/src/platform/node/protos @@ -1 +1 @@ -Subproject commit b54688569186e0b862bf7462a983ccf2c50c0547 +Subproject commit e6c3c4a74d57f870a0d781bada02cb2b2c497d14 diff --git a/packages/opentelemetry-exporter-collector/test/browser/CollectorTraceExporter.test.ts b/packages/opentelemetry-exporter-collector/test/browser/CollectorTraceExporter.test.ts index b5621a3ee5..58a778547b 100644 --- a/packages/opentelemetry-exporter-collector/test/browser/CollectorTraceExporter.test.ts +++ b/packages/opentelemetry-exporter-collector/test/browser/CollectorTraceExporter.test.ts @@ -332,7 +332,7 @@ describe('CollectorExporter - browser (getDefaultUrl)', () => { setTimeout(() => { assert.strictEqual( collectorExporter['url'], - 'http://localhost:55678/v1/trace' + 'http://localhost:55680/v1/trace' ); done(); }); diff --git a/packages/opentelemetry-exporter-collector/test/node/CollectorTraceExporter.test.ts b/packages/opentelemetry-exporter-collector/test/node/CollectorTraceExporter.test.ts index aaa534986a..537bd8eee4 100644 --- a/packages/opentelemetry-exporter-collector/test/node/CollectorTraceExporter.test.ts +++ b/packages/opentelemetry-exporter-collector/test/node/CollectorTraceExporter.test.ts @@ -176,7 +176,7 @@ describe('CollectorExporter - node (getDefaultUrl)', () => { it('should default to localhost', done => { const collectorExporter = new CollectorTraceExporter({}); setTimeout(() => { - assert.strictEqual(collectorExporter['url'], 'localhost:55678'); + assert.strictEqual(collectorExporter['url'], 'localhost:55680'); done(); }); });