openzipkin-attic / docker-zipkin

Docker images for OpenZipkin
Apache License 2.0
689 stars 330 forks source link

ZipKin in Docker-Compose not accepting requests from docker network #208

Closed andrei-dascalu closed 5 years ago

andrei-dascalu commented 5 years ago

Hello,

This may be a stupid question related to my poor understanding of the ZipKin server but I have a simple docker-compose file with zipkin (exposing port 9411) and a test service in PHP that maps a folder with some very basic code.

If I login into the container and run the code, passing the IP of the zipkin running container to Endpoint::create (this ip being 192.168.176.7) then traces don't go in. If I run the same code on my local machine (passing 127.0.0.1 to Endpoint::create), then traces do go in.

Are there some default restrictions when using the container, eg (where requests may come from) ?

Thanks!

jcchavezs commented 5 years ago

Did you try the php example https://github.com/openzipkin/zipkin-php-example? Does this still happen with the sample?

fre. 17. mai 2019, 16:57 skrev Andrei Dascalu notifications@github.com:

Hello,

This may be a stupid question related to my poor understanding of the ZipKin server but I have a simple docker-compose file with zipkin (exposing port 9411) and a test service in PHP that maps a folder with some very basic code.

If I login into the container and run the code, passing the IP of the zipkin running container to Endpoint::create (this ip being 192.168.176.7) then traces don't go in. If I run the same code on my local machine (passing 127.0.0.1 to Endpoint::create), then traces do go in.

Are there some default restrictions when using the container, eg (where requests may come from) ?

Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/openzipkin/docker-zipkin/issues/208?email_source=notifications&email_token=AAXOYATVCMZBEDJPPFDE5GTPV3BUDA5CNFSM4HNWAOI2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GUNRLYA, or mute the thread https://github.com/notifications/unsubscribe-auth/AAXOYAVRPX7E4LT4LUIDUNLPV3BUDANCNFSM4HNWAOIQ .

andrei-dascalu commented 5 years ago

Hi,

Yes, basically I copied the code from there, with the difference that instead of separate functions.php I only have one file that also contains the function definition and there's no backend to call, I replaced it with a 2s sleep.

If I use 127.0.0.1 from my local it works, but if I execute it in the container and use the container IP, then it doesn't.

I can put together a repo for reproduction, it may be more clear.

Thanks

jcchavezs commented 5 years ago

So if you run code inside a container and zipkin is in another container then you need to create a network so both containers can see each other. If you run the code insider the zipkin container then, zipkin is running under localhost:9411. Seeing the code in a repo would be easier.

fre. 17. mai 2019, 17:39 skrev Andrei Dascalu notifications@github.com:

Hi,

Yes, basically I copied the code from there, with the difference that instead of separate functions.php I only have one file that also contains the function definition and there's no backend to call, I replaced it with a 2s sleep.

If I use 127.0.0.1 from my local it works, but if I execute it in the container and use the container IP, then it doesn't.

I can put together a repo for reproduction, it may be more clear.

Thanks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/openzipkin/docker-zipkin/issues/208?email_source=notifications&email_token=AAXOYAT5VVUADFM27UEFPS3PV3GSHA5CNFSM4HNWAOI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVVDJIQ#issuecomment-493499554, or mute the thread https://github.com/notifications/unsubscribe-auth/AAXOYAXK2UBDL4EAHMNWK5DPV3GSHANCNFSM4HNWAOIQ .

andrei-dascalu commented 5 years ago

Hi,

Thanks a lot for your time, here is my test repo: https://github.com/andrei-dascalu/zipking-php-testing

Cheers

andrei-dascalu commented 5 years ago

Hello,

I may have found the issue and it seems it's related to php library rather than docker, as I initially assumed.

I changed the builder function to:

` function create_tracing($endpointName, $ipv4, $port) { $endpoint = Endpoint::create($endpointName, $ipv4, null, $port); $http = \Zipkin\Reporters\Http\CurlFactory::create();

    $reporter = new Zipkin\Reporters\Http($http, [
        'endpoint_url' => sprintf('http://%s:%s/api/v2/spans', $ipv4, $port)
    ]);
    $sampler = BinarySampler::createAsAlwaysSample();
    $tracing = TracingBuilder::create()
    ->havingLocalEndpoint($endpoint)
    ->havingSampler($sampler)
    ->havingReporter($reporter)
    ->build();

    return $tracing;

} `

And now it's working. It seems that the ip/port provided to the Endpoint don't have an impact as to where requests are being made. For the HTTP reporter, all that matters are the parameters reaching the build method of the ClientFactory object.

I'm not entirely sure what to do about it, I believe it's indeed an issue but whether it's something that requires a code fix or just a doc updated, that's a question.

Thanks

andrei-dascalu commented 5 years ago

closing as it's PHP library related