opentelemetry-rust icon indicating copy to clipboard operation
opentelemetry-rust copied to clipboard

"with_collector_endpoint" only exports spans to localhost?

Open piano-man opened this issue 2 years ago • 6 comments

So I'm using with_collector_endpoint to specify the jaeger collector I want to export the spans to. The collector is running on a different host than the one I'm exporting the spans from. My sample code looks something as such:

opentelemetry_jaeger::new_pipeline()
            .with_collector_endpoint("http://10.10.10.100:14268")
            .with_service_name("test")
            .install_simple()
            .unwrap();

The issue I'm observing is that no matter what endpoint I specify, the spans are always exported to a collector running on localhost. For instance, even though I specify the endpoint as http://10.10.10.100:14268, I do not see any spans exported to this collector. I ran a collector on http://localhost:14268 and could see the spans being exported to this local collector instead. I did make sure that the 10.10.10.100 collector was reachable from my machine and that there were no packet drops occurring.

Is there something I'm misunderstanding about the with_collector_endpoint function? Is it only supposed to export spans to collectors running locally?

piano-man avatar Apr 12 '22 05:04 piano-man

Thanks for the report. Could you also share what version you are using?

TommyCpp avatar Apr 13 '22 13:04 TommyCpp

I think https://github.com/open-telemetry/opentelemetry-rust/pull/706 may explain this. In short, the install_simple method is not compatible with the collector now. However, in this case, it should fall back to agent mode that sends spans to 127.0.0.1:6831. Could you check if you opened the 6831 on the collector too?

TommyCpp avatar Apr 13 '22 13:04 TommyCpp

Thanks for the response. I think you're right. I was using the following command to run my Jaeger collector: docker run -d -p6831:6831/udp -p6832:6832/udp -p16686:16686 -p14268:14268 jaegertracing/all-in-one:latest

So it's possible that the collector was receiving the spans on port 6831.

I tried using the updated example mentioned in the docs. My code now looks as such:

        let tracer = opentelemetry_jaeger::new_pipeline()
            .with_collector_endpoint(http://localhost:14268)
            .install_batch(opentelemetry::runtime::Tokio)
            .unwrap();

However, even though I have the following listed as a dependency: opentelemetry-jaeger = {version = "0.15.0", features = ["collector_client", "isahc", "rt-tokio"]}

I see a `Err` value: ExportFailed(NoHttpClient)' error on executing the script. Is there something I'm missing here? Do we need to explicitly use with_http_client as well?

piano-man avatar Apr 14 '22 10:04 piano-man

Hmm you shouldn't need to on 0.15. We did change the behavior to require a explicily call to use http client in master but it hasn't been released

TommyCpp avatar Apr 18 '22 04:04 TommyCpp

Hey folks ... after far too much difficulty and random troubleshooting, I am happy to report that I've got this thing working as it should with the following constraints:

opentelemetry = { version = "0.17", default-features = false, features = ["rt-tokio", "trace"]}
opentelemetry-jaeger = { version = "0.16", default-features = false, features = ["rt-tokio", "reqwest_collector_client"] }
// Pulling in from env because it seems required (not being detected/loaded automatically).
let endpoint = std::env::var("OTEL_EXPORTER_JAEGER_ENDPOINT")
    .context("could not find env var OTEL_EXPORTER_JAEGER_ENDPOINT")?;
let tracer = opentelemetry_jaeger::new_pipeline()
    .with_service_name("foo")
    .with_collector_endpoint(&endpoint) // Manually specify collector endpoint.
    .install_batch(opentelemetry::runtime::Tokio) // MUST use install batch, not install_simple.
    .context("error building Jaeger tracing pipeline")?;
let telem = tracing_opentelemetry::layer().with_tracer(tracer);
# This address is a kubernetes service in the same namespace,
# not localhost, not sidecar, but an actual separate networked service.
OTEL_EXPORTER_JAEGER_ENDPOINT="http://tracing-collector:14268/api/traces"
OTEL_EXPORTER_JAEGER_PROTOCOL="udp/thrift.binary"
OTEL_SERVICE_NAME="foo"
OTEL_TRACES_SAMPLER="always_on"

To help with discoverability, I was getting errors like: OpenTelemetry trace error occurred. Exporter jaeger encountered the following error(s): thrift agent failed with not open and other similar variations.

thedodd avatar Jun 10 '22 20:06 thedodd

Thanks for the details. The jaeger exporter was always trying to set up agent before trying to send to the collector. It has caused some confusion. I hope once we release #748 it will be better

TommyCpp avatar Jun 13 '22 03:06 TommyCpp