title: How to correctly use OpenTelemetry exporter with OpenTelemetry collector in client and server?
body: <p>I am trying to make OpenTelemetry exporter to work with OpenTelemetry collector.</p>
  <p>I found this <a href="https://github.com/open-telemetry/opentelemetry-collector/tree/master/examples/demo" rel="noreferrer">OpenTelemetry collector demo</a>.</p>
  <p>So I copied these four config files</p>
  <ul>
  <li>docker-compose.yml (In my app, I removed generators part and prometheus which I currently having issue running)</li>
  <li>otel-agent-config.yaml</li>
  <li>otel-collector-config.yaml</li>
  <li>.env</li>
  </ul>
  <p>to my app.</p>
  <p>Also based on these two demos in open-telemetry/opentelemetry-js repo:</p>
  <ul>
  <li><a href="https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-exporter-collector#traces-in-web" rel="noreferrer">Traces in Web demo</a></li>
  <li><a href="https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-exporter-collector#traces-in-node---grpc" rel="noreferrer">Traces in Node - GRPC demo</a></li>
  </ul>
  <p>I came up with my version (sorry for a bit long, really hard to set up a minimum working version due to the lack of docs):</p>
  <p><strong>.env</strong></p>
  <pre><code>OTELCOL_IMG=otel/opentelemetry-collector-dev:latest
  OTELCOL_ARGS=
  </code></pre>
  <p><strong>docker-compose.yml</strong></p>
  <pre><code>version: '3.7'
  services:
    # Jaeger
    jaeger-all-in-one:
      image: jaegertracing/all-in-one:latest
      ports:
        - &quot;16686:16686&quot;
        - &quot;14268&quot;
        - &quot;14250&quot;
  
    # Zipkin
    zipkin-all-in-one:
      image: openzipkin/zipkin:latest
      ports:
        - &quot;9411:9411&quot;
  
    # Collector
    otel-collector:
      image: ${OTELCOL_IMG}
      command: [&quot;--config=/etc/otel-collector-config.yaml&quot;, &quot;${OTELCOL_ARGS}&quot;]
      volumes:
        - ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
      ports:
        - &quot;1888:1888&quot;   # pprof extension
        - &quot;8888:8888&quot;   # Prometheus metrics exposed by the collector
        - &quot;8889:8889&quot;   # Prometheus exporter metrics
        - &quot;13133:13133&quot; # health_check extension
        - &quot;55678&quot;       # OpenCensus receiver
        - &quot;55680:55679&quot; # zpages extension
      depends_on:
        - jaeger-all-in-one
        - zipkin-all-in-one
  
    # Agent
    otel-agent:
      image: ${OTELCOL_IMG}
      command: [&quot;--config=/etc/otel-agent-config.yaml&quot;, &quot;${OTELCOL_ARGS}&quot;]
      volumes:
        - ./otel-agent-config.yaml:/etc/otel-agent-config.yaml
      ports:
        - &quot;1777:1777&quot;   # pprof extension
        - &quot;8887:8888&quot;   # Prometheus metrics exposed by the agent
        - &quot;14268&quot;       # Jaeger receiver
        - &quot;55678&quot;       # OpenCensus receiver
        - &quot;55679:55679&quot; # zpages extension
        - &quot;13133&quot;       # health_check
      depends_on:
        - otel-collector
  </code></pre>
  <p><strong>otel-agent-config.yaml</strong></p>
  <pre><code>receivers:
    opencensus:
    zipkin:
      endpoint: :9411
    jaeger:
      protocols:
        thrift_http:
  
  exporters:
    opencensus:
      endpoint: &quot;otel-collector:55678&quot;
      insecure: true
    logging:
      loglevel: debug
  
  processors:
    batch:
    queued_retry:
  
  extensions:
    pprof:
      endpoint: :1777
    zpages:
      endpoint: :55679
    health_check:
  
  service:
    extensions: [health_check, pprof, zpages]
    pipelines:
      traces:
        receivers: [opencensus, jaeger, zipkin]
        processors: [batch, queued_retry]
        exporters: [opencensus, logging]
      metrics:
        receivers: [opencensus]
        processors: [batch]
        exporters: [logging,opencensus]
  </code></pre>
  <p><strong>otel-collector-config.yaml</strong></p>
  <pre><code>receivers:
    opencensus:
  
  exporters:
    prometheus:
      endpoint: &quot;0.0.0.0:8889&quot;
      namespace: promexample
      const_labels:
        label1: value1
    logging:
  
    zipkin:
      endpoint: &quot;http://zipkin-all-in-one:9411/api/v2/spans&quot;
      format: proto
  
    jaeger:
      endpoint: jaeger-all-in-one:14250
      insecure: true
  
  processors:
    batch:
    queued_retry:
  
  extensions:
    health_check:
    pprof:
      endpoint: :1888
    zpages:
      endpoint: :55679
  
  service:
    extensions: [pprof, zpages, health_check]
    pipelines:
      traces:
        receivers: [opencensus]
        processors: [batch, queued_retry]
        exporters: [logging, zipkin, jaeger]
      metrics:
        receivers: [opencensus]
        processors: [batch]
        exporters: [logging]
  </code></pre>
  <p>After running <code>docker-compose up -d</code>, I can open Jaeger (http://localhost:16686) and Zipkin UI (http://localhost:9411).</p>
  <p>And my <code>ConsoleSpanExporter</code> works in both web client and Express.js server.</p>
  <p>However, I tried this OpenTelemetry exporter code in both client and server, I am still having issue to connect OpenTelemetry collector.</p>
  <p>Please see my comment about URL inside of the code</p>
  <pre class="lang-js prettyprint-override"><code>import { CollectorTraceExporter } from '@opentelemetry/exporter-collector';
  
  // ...
  tracerProvider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
  tracerProvider.addSpanProcessor(
    new SimpleSpanProcessor(
      new CollectorTraceExporter({
        serviceName: 'my-service',
        // url: 'http://localhost:55680/v1/trace', // Return error 404.
        // url: 'http://localhost:55681/v1/trace', // No response, not exists.
        // url: 'http://localhost:14268/v1/trace', // No response, not exists.
      })
    )
  );
  </code></pre>
  <p>Any idea? Thanks</p>