Skip to content

Commit

Permalink
tests(span-error): adds ipv6 in json serializer test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcchavezs committed Jul 6, 2020
1 parent 661f995 commit 696516d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/Zipkin/Reporters/JsonV2Serializer.php
Expand Up @@ -38,15 +38,15 @@ private function serializeEndpoint(Endpoint $endpoint): string
if ($endpoint->getIpv4() !== null) {
$endpointStr .= ',"ipv4":"' . $endpoint->getIpv4() . '"';
}

if ($endpoint->getPort() !== null) {
$endpointStr .= ',"port":' . $endpoint->getPort();
}


if ($endpoint->getIpv6() !== null) {
$endpointStr .= ',"ipv6":"' . $endpoint->getIpv6() . '"';
}

if ($endpoint->getPort() !== null) {
$endpointStr .= ',"port":' . $endpoint->getPort();
}

return $endpointStr . '}';
}

Expand Down
5 changes: 3 additions & 2 deletions tests/Unit/Propagation/JsonV2SerializerTest.php
Expand Up @@ -19,7 +19,7 @@ public function testSpanIsSerializedSuccessfully()
$span->start($startTime);
$span->setName('test');
$span->setKind('CLIENT');
$remoteEndpoint = Endpoint::create('service2', '192.168.0.12', null, 3302);
$remoteEndpoint = Endpoint::create('service2', null, '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 3302);
$span->setRemoteEndpoint($remoteEndpoint);
$span->tag('test_key', 'test_value');
$span->annotate($startTime + 100, 'test_annotarion');
Expand All @@ -31,7 +31,8 @@ public function testSpanIsSerializedSuccessfully()
$expectedSerialization = '[{'
. '"id":"186f11b67460db4d","name":"test","traceId":"186f11b67460db4d","timestamp":1594044779509687,'
. '"duration":1000,"localEndpoint":{"serviceName":"service1","ipv4":"192.168.0.11","port":3301},'
. '"debug":"CLIENT","remoteEndpoint":{"serviceName":"service2","ipv4":"192.168.0.12","port":3302},'
. '"debug":"CLIENT",'
.'"remoteEndpoint":{"serviceName":"service2","ipv6":"2001:0db8:85a3:0000:0000:8a2e:0370:7334","port":3302},'
. '"annotations":[{"value":"test_annotarion","timestamp":1594044779509787}],'
. '"tags":{"test_key":"test_value","error":"test_error"}'
. '}]';
Expand Down

0 comments on commit 696516d

Please sign in to comment.