What I was trying to achieve:
For my testing on trace processor I wanted to run the Opentelemetry provided demo app along with the collector as a docker container.
Also I wanted the OTEL collector to send data to pulsar topic: otlp_traces
Then using a pulsar consumer I could see the trace data on the topic.
What I did:
Ran Opentelemetry demo application along with collector using link: [https://opentelemetry.io/docs/demo/docker-deployment/]
Ran pulsar locally using the link: Pulsar deployment
Challenge I faced:
In the collector logs I could see the below error:
2024-07-16 17:20:41 time="2024-07-16T11:50:41Z" level=info msg="[Connecting to broker]" remote_addr="pulsar://localhost:6650"
2024-07-16 17:20:46 time="2024-07-16T11:50:46Z" level=warning msg="[Failed to connect to broker.]" error="dial tcp localhost:6650: i/o timeout" remote_addr="pulsar://localhost:6650"
2024-07-16 17:20:47 time="2024-07-16T11:50:47Z" level=info msg="Removed connection from pool key=localhost:665045 0 logical_addr=pulsar://localhost:6650 physical_addr=pulsar://localhost:6650
I tried logging inside the docker container and running the below command to verify if I am able to connect to pulsar and it worked. Command: ./bin/pulsar-client consume persistent://public/default/otlp_spans --subscription-name perftest --num-messages 0 --subscription-mode NonDurable
I am not able to figure out why the connector is not able to connect to pulsar. Need help.
This is my connector config:
exporters:
debug:
pulsar:
endpoint: "pulsar://localhost:6650/"
topic: otlp_spans
encoding: otlp_json
timeout: 10s
tls_allow_insecure_connection: true
2
Answers
The problem was with the pulsar URL. I am not sure why the OTEL collector is not able to connect to pulsar using localhost and 127.0.0.1. Hence I gave the local IP address of my PC and it worked like a charm. endpoint: "pulsar://<--my local PC IP address here-->:6650/"
Explanation
You run OTEL and pulsar in a docker environment. They deployed in different containers and they have various
localhost
destinations.You can read here an answer about the docker connection between containers.
Solutions