Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 34c1c16

Browse files
bpotchingor13
authored andcommitted
ZipkinExporter: localEndpoint.port should be an int (#118)
1 parent cd0b41e commit 34c1c16

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Trace/Exporter/ZipkinExporter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function __construct($name, $host, $port, $endpoint = '/api/v2/spans', $s
7676
'serviceName' => $name
7777
];
7878
if (array_key_exists('SERVER_PORT', $server)) {
79-
$this->localEndpoint['port'] = $server['SERVER_PORT'];
79+
$this->localEndpoint['port'] = intval($server['SERVER_PORT']);
8080
}
8181
}
8282

tests/unit/Trace/Exporter/ZipkinExporterTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,17 @@ public function testSetsIpv6()
177177
$this->assertArrayHasKey('ipv6', $endpoint);
178178
$this->assertEquals('2001:db8:85a3::8a2e:370:7334', $endpoint['ipv6']);
179179
}
180+
181+
public function testSetsLocalEndpointPort()
182+
{
183+
$spanContext = new SpanContext('testtraceid', 12345);
184+
$tracer = new ContextTracer($spanContext);
185+
$tracer->inSpan(['name' => 'main'], function () {});
186+
187+
$reporter = new ZipkinExporter('myapp', 'localhost', 9411, '/api/v2/spans', ['SERVER_PORT' => "80"]);
188+
$spans = $reporter->convertSpans($tracer);
189+
$endpoint = $spans[0]['localEndpoint'];
190+
$this->assertArrayHasKey('port', $endpoint);
191+
$this->assertEquals(80, $endpoint['port']);
192+
}
180193
}

0 commit comments

Comments
 (0)