yurishkuro / opentracing-tutorial

A collection of tutorials for the OpenTracing API
Apache License 2.0
1.57k stars 404 forks source link

No step to set environment variables #43

Open veterr opened 5 years ago

veterr commented 5 years ago

After lesson 1 I see no changes in yaeger UI. I think it is because we don't set environment variables that are taken by tracer - JAEGER_SAMPLER_TYPE, JAEGER_SAMPLER_PARAM, JAEGER_SAMPLER_MANAGER_HOST_PORT and they are null. Also, I run docker for Windows and yaeger is Launched on 192.168.99.100 instead of localhost, please provide appropriate data if you edit.

yurishkuro commented 5 years ago

You can try running Jaeger binary instead of Docker image, then it will be on localhost.

But yes, it's a valid point for cases where Docker runs in a VM with a different IP. You don't need to provide sampler params since examples use a Const sampler, but you do need to provide an address of the agent or collector

Would you like to put a pull request adding these instructions? It should go in the top level README.

veterr commented 5 years ago

Hi. For now it simply does not work for me .... I tried to specify Jaeger host and port, but it did not help, and I still don't see my "hello-world" spans. Could you please take a look if I miss something? My yaeger UI is executed on http://192.168.99.100:16686. I added .withManagerHostPort("192.168.99.100:5778") - https://imgur.com/a/syx5aeg

And after I execute first lesson, it shows no events for "hello-world" - https://imgur.com/a/TOqN3fj

What can I be missing?

yurishkuro commented 5 years ago

are you using Java?

veterr commented 5 years ago

Yes

yurishkuro commented 5 years ago

you're using the wrong setting, "manager" is the config manager, not applicable with constant sampler.

You need JAEGER_AGENT_HOST/JAEGER_AGENT_PORT, or JAEGER_ENDPOINT (if you want to bypass the agent and use HTTP to talk directly to collector). See https://github.com/jaegertracing/jaeger-client-java/tree/master/jaeger-core

veterr commented 5 years ago

I tried to run Yaeger binary on localhost, and executed code from lesson01.solution.Hello. But still, even at localhost yaeger, I did not see my "hello-world" span ...

yurishkuro commented 5 years ago

did you reload the UI webpage after running the app? did the app print trace IDs in the logs

veterr commented 5 years ago

Oh. Thanks God, localhost started working! The problem on 192.168.99.100 host, docker on windows still remains.. I see no span. I tried to execute System.setProperty("JAEGER_SAMPLER_MANAGER_HOST_PORT", "192.168.99.100:5778"); before - try (JaegerTracer tracer = Tracing.init("hello-world")) { new Hello(tracer).sayHello(helloTo); }

Is it the right thing to do?

veterr commented 5 years ago

I also tried System.setProperty("JAEGER_AGENT_HOST", "192.168.99.100"); System.setProperty("JAEGER_AGENT_PORT", "5778"); try (JaegerTracer tracer = Tracing.init("hello-world")) { new Hello(tracer).sayHello(helloTo); }

But no result so far..

yurishkuro commented 5 years ago

it sounds more like an issue with your Docker's networking setup. You call shell into the container and run tcpdump on the port to see if it's getting any traffic (although jaeger Docker images don't include any tools, you may need to use staged build to create a container with dev tools.

veterr commented 5 years ago

Thank you! I will let you know, if I find what was the problem...

narendranss commented 4 years ago

Any updates on this for docker deployment? Facing a similar issue despite setting port forwarding in VM.

sysmat commented 4 years ago

Same here, if basic not work

System.setProperty("JAEGER_AGENT_HOST", "localhost");
System.setProperty("JAEGER_AGENT_PORT", "5778");
SamplerConfiguration samplerConfig = SamplerConfiguration.fromEnv()
                .withType(ConstSampler.TYPE)
                .withParam(1);

        ReporterConfiguration reporterConfig = ReporterConfiguration.fromEnv()
                .withLogSpans(true);

        Configuration config = new Configuration("etabla2")
                .withSampler(samplerConfig)
                .withReporter(reporterConfig);

        return config.getTracer();
buzypi commented 4 years ago

Here is a crude solution that worked for me.

Run the code in another Docker container and put both the containers in a single custom bridge network.

docker network create jaeger-net
# Container to run jaeger
docker run \
  --rm -d \
  --net jaeger-net \
  --name jaeger \
  -p 6831:6831/udp \
  -p 6832:6832/udp \
  -p 16686:16686 \
  jaegertracing/all-in-one:1.16 \
  --log-level=debug
# Container to run the examples
docker run \
  -it \
  --rm \
  --net jaeger-net \
  ubuntu:18.04

In this second container, install the required dependencies and run the examples:

apt-get update && apt-get -y install python3 python3-pip git
git clone https://github.com/yurishkuro/opentracing-tutorial/
cd opentracing-tutorial/python
pip3 install -r requirements.txt
export JAEGER_AGENT_HOST=jaeger
python3 -m lesson02.solution.hello Bryan

I have verified all the examples and they work fine. I had to change the examples slightly to make it work with jaeger-client. Here is my forked repo: https://github.com/buzypi/opentracing-tutorial

vimal97 commented 3 years ago

Here is a crude solution that worked for me.

Run the code in another Docker container and put both the containers in a single custom bridge network.

docker network create jaeger-net
# Container to run jaeger
docker run \
  --rm -d \
  --net jaeger-net \
  --name jaeger \
  -p 6831:6831/udp \
  -p 6832:6832/udp \
  -p 16686:16686 \
  jaegertracing/all-in-one:1.16 \
  --log-level=debug
# Container to run the examples
docker run \
  -it \
  --rm \
  --net jaeger-net \
  ubuntu:18.04

In this second container, install the required dependencies and run the examples:

apt-get update && apt-get -y install python3 python3-pip git
git clone https://github.com/yurishkuro/opentracing-tutorial/
cd opentracing-tutorial/python
pip3 install -r requirements.txt
export JAEGER_AGENT_HOST=jaeger
python3 -m lesson02.solution.hello Bryan

I have verified all the examples and they work fine. I had to change the examples slightly to make it work with jaeger-client. Here is my forked repo: https://github.com/buzypi/opentracing-tutorial I have followed the procedure you suggested, it is not working for the Go sample.