Skip to content

Commit

Permalink
Add peer.service attribute to symfony http client spans (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
caetanev authored Oct 4, 2024
1 parent 3a66cc8 commit 67ce817
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public static function register(): void
->tracer()
->spanBuilder(\sprintf('%s', $params[0]))
->setSpanKind(SpanKind::KIND_CLIENT)
->setAttribute(TraceAttributes::PEER_SERVICE, parse_url((string) $params[1])['host'] ?? null)
->setAttribute(TraceAttributes::URL_FULL, (string) $params[1])
->setAttribute(TraceAttributes::HTTP_REQUEST_METHOD, $params[0])
->setAttribute(TraceAttributes::CODE_FUNCTION, $function)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public function test_send_request(string $method, string $uri, int $statusCode,
$this->assertNotNull($requestHeaders['HTTP_TRACEPARENT']);
}

$this->assertTrue($span->getAttributes()->has(TraceAttributes::PEER_SERVICE));
$this->assertSame(parse_url($uri)['host'] ?? null, $span->getAttributes()->get(TraceAttributes::PEER_SERVICE));
$this->assertTrue($span->getAttributes()->has(TraceAttributes::URL_FULL));
$this->assertSame($uri, $span->getAttributes()->get(TraceAttributes::URL_FULL));
$this->assertTrue($span->getAttributes()->has(TraceAttributes::HTTP_REQUEST_METHOD));
Expand Down

0 comments on commit 67ce817

Please sign in to comment.