Skip to content

Commit

Permalink
Compatible with _ _ call and _ _ callStatic for Trace aspect (#603)
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanyanwow authored Apr 8, 2024
1 parent d138909 commit 713e680
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/sentry/src/Tracing/Aspect/TraceAnnotationAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,26 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint)
if ($this->tagManager->has('annotation.coroutine.id')) {
$data[$this->tagManager->get('annotation.coroutine.id')] = Coroutine::id();
}
if ($this->tagManager->has('annotation.arguments')) {
$data[$this->tagManager->get('annotation.arguments')] = $proceedingJoinPoint->arguments['keys'];

$methodName = $proceedingJoinPoint->methodName;
if (in_array($methodName, ['__call', '__callStatic'])) {
$methodName = $proceedingJoinPoint->arguments['keys']['name'] ?? $proceedingJoinPoint->methodName;

if ($this->tagManager->has('annotation.arguments')) {
$data[$this->tagManager->get('annotation.arguments')] = $proceedingJoinPoint->arguments['keys']['arguments'] ?? $proceedingJoinPoint->arguments['keys'];
}
} else {
if ($this->tagManager->has('annotation.arguments')) {
$data[$this->tagManager->get('annotation.arguments')] = $proceedingJoinPoint->arguments['keys'];
}
}

$span = $this->startSpan(
$annotation->op ?? 'method',
$annotation->description ?? sprintf(
'%s::%s()',
$proceedingJoinPoint->className,
$proceedingJoinPoint->methodName
$methodName
),
true
);
Expand Down

0 comments on commit 713e680

Please sign in to comment.