Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/sentry/src/Tracing/Aspect/AmqpProducerAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use FriendsOfHyperf\Sentry\Util\Carrier;
use Hyperf\Amqp\Annotation\Producer;
use Hyperf\Amqp\Message\ProducerMessage;
use Hyperf\Coroutine\Coroutine;
use Hyperf\Di\Annotation\AnnotationCollector;
use Hyperf\Di\Aop\AbstractAspect;
use Hyperf\Di\Aop\ProceedingJoinPoint;
Expand Down Expand Up @@ -101,7 +100,6 @@ function (Scope $scope) use ($proceedingJoinPoint, $producerMessage, $messageId,
->setDescription(sprintf('%s::%s()', $proceedingJoinPoint->className, $proceedingJoinPoint->methodName))
->setOrigin('auto.amqp')
->setData([
'coroutine.id' => Coroutine::id(),
'messaging.system' => 'amqp',
'messaging.operation' => 'publish',
'messaging.message.id' => $messageId,
Expand Down
2 changes: 0 additions & 2 deletions src/sentry/src/Tracing/Aspect/AsyncQueueJobMessageAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use FriendsOfHyperf\Sentry\Util\Carrier;
use Hyperf\AsyncQueue\Driver\RedisDriver;
use Hyperf\Context\Context;
use Hyperf\Coroutine\Coroutine;
use Hyperf\Di\Aop\AbstractAspect;
use Hyperf\Di\Aop\ProceedingJoinPoint;
use Sentry\State\Scope;
Expand Down Expand Up @@ -81,7 +80,6 @@ public function handlePush(ProceedingJoinPoint $proceedingJoinPoint)
$destinationName = Context::get('sentry.messaging.destination.name', 'default');
$bodySize = (fn ($job) => strlen($this->packer->pack($job)))->call($driver, $job);
$data = [
'coroutine.id' => Coroutine::id(),
'messaging.system' => 'async_queue',
'messaging.operation' => 'publish',
'messaging.message.id' => $messageId,
Expand Down
2 changes: 0 additions & 2 deletions src/sentry/src/Tracing/Aspect/CacheAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace FriendsOfHyperf\Sentry\Tracing\Aspect;

use FriendsOfHyperf\Sentry\Switcher;
use Hyperf\Coroutine\Coroutine;
use Hyperf\Di\Aop\AbstractAspect;
use Hyperf\Di\Aop\ProceedingJoinPoint;
use Sentry\State\Scope;
Expand Down Expand Up @@ -92,7 +91,6 @@ function (Scope $scope) use ($proceedingJoinPoint, $method) {
->setDescription(implode(', ', $keys))
->setOrigin('auto.cache')
->setData([
'coroutine.id' => Coroutine::id(),
'cache.key' => $keys,
'cache.ttl' => $arguments['ttl'] ?? null,
'item_size' => match (true) {
Expand Down
2 changes: 0 additions & 2 deletions src/sentry/src/Tracing/Aspect/CoordinatorAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use FriendsOfHyperf\Sentry\Switcher;
use Hyperf\Coordinator\Coordinator;
use Hyperf\Coroutine\Coroutine;
use Hyperf\Di\Aop\AbstractAspect;
use Hyperf\Di\Aop\ProceedingJoinPoint;
use Sentry\State\Scope;
Expand Down Expand Up @@ -46,7 +45,6 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint)
->setDescription(sprintf('%s::%s(%s)', $proceedingJoinPoint->className, $proceedingJoinPoint->methodName, $timeout))
->setOrigin('auto.coordinator')
->setData([
'coroutine.id' => Coroutine::id(),
'timeout' => $timeout,
])
);
Expand Down
1 change: 0 additions & 1 deletion src/sentry/src/Tracing/Aspect/CoroutineAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint)
->setOp('coroutine.execute')
->setDescription($callingOnFunction)
->setOrigin('auto.coroutine')
->setData(['coroutine.id' => Co::id()])
);

defer(function () use ($coTransaction) {
Expand Down
2 changes: 0 additions & 2 deletions src/sentry/src/Tracing/Aspect/DbAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use FriendsOfHyperf\Sentry\Switcher;
use FriendsOfHyperf\Sentry\Util\SqlParser;
use Hyperf\Coroutine\Coroutine;
use Hyperf\DB\DB;
use Hyperf\DB\Pool\PoolFactory;
use Hyperf\Di\Aop\AbstractAspect;
Expand Down Expand Up @@ -64,7 +63,6 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint)
$table = $sqlParse['table'];
$operation = $sqlParse['operation'];
$data = [
'coroutine.id' => Coroutine::id(),
'db.system' => $driver,
'db.name' => $database,
'db.collection.name' => $table,
Expand Down
2 changes: 0 additions & 2 deletions src/sentry/src/Tracing/Aspect/ElasticsearchAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace FriendsOfHyperf\Sentry\Tracing\Aspect;

use FriendsOfHyperf\Sentry\Switcher;
use Hyperf\Coroutine\Coroutine;
use Hyperf\Di\Aop\AbstractAspect;
use Hyperf\Di\Aop\ProceedingJoinPoint;
use Sentry\State\Scope;
Expand Down Expand Up @@ -76,7 +75,6 @@ function (Scope $scope) use ($proceedingJoinPoint) {
->setDescription(sprintf('%s::%s()', $proceedingJoinPoint->className, $proceedingJoinPoint->methodName))
->setOrigin('auto.elasticsearch')
->setData([
'coroutine.id' => Coroutine::id(),
'db.system' => 'elasticsearch',
'db.operation.name' => $proceedingJoinPoint->methodName,
'arguments' => (string) json_encode($proceedingJoinPoint->arguments['keys'], JSON_UNESCAPED_UNICODE),
Expand Down
3 changes: 1 addition & 2 deletions src/sentry/src/Tracing/Aspect/FilesystemAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace FriendsOfHyperf\Sentry\Tracing\Aspect;

use FriendsOfHyperf\Sentry\Aspect\FilesystemAspect as BaseFilesystemAspect;
use Hyperf\Coroutine\Coroutine;
use Hyperf\Di\Aop\ProceedingJoinPoint;
use Override;
use Sentry\State\Scope;
Expand All @@ -37,7 +36,7 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint)
->setOp($op)
->setDescription($description)
->setOrigin('auto.filesystem')
->setData(['coroutine.id' => Coroutine::id()] + $data)
->setData($data)
);
}
}
2 changes: 0 additions & 2 deletions src/sentry/src/Tracing/Aspect/GrpcAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace FriendsOfHyperf\Sentry\Tracing\Aspect;

use FriendsOfHyperf\Sentry\Switcher;
use Hyperf\Coroutine\Coroutine;
use Hyperf\Di\Aop\AbstractAspect;
use Hyperf\Di\Aop\ProceedingJoinPoint;
use Sentry\SentrySdk;
Expand Down Expand Up @@ -41,7 +40,6 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint)
$method = $proceedingJoinPoint->arguments['keys']['method'];
$options = $proceedingJoinPoint->arguments['keys']['options'];
$data = [
'coroutine.id' => Coroutine::id(),
'grpc.method' => $method,
'grpc.options' => $options,
];
Expand Down
1 change: 0 additions & 1 deletion src/sentry/src/Tracing/Aspect/GuzzleHttpClientAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ function (Scope $scope) use ($proceedingJoinPoint, $options, $guzzleConfig) {
'http.request.user_agent' => $request->getHeaderLine('User-Agent'), // updated key for consistency
'http.request.headers' => $request->getHeaders(),
// Other
'coroutine.id' => Coroutine::id(),
'http.system' => 'guzzle',
'http.guzzle.config' => $guzzleConfig,
'http.guzzle.options' => $options ?? [],
Expand Down
4 changes: 1 addition & 3 deletions src/sentry/src/Tracing/Aspect/KafkaProducerAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use FriendsOfHyperf\Sentry\Constants;
use FriendsOfHyperf\Sentry\Switcher;
use FriendsOfHyperf\Sentry\Util\Carrier;
use Hyperf\Coroutine\Coroutine;
use Hyperf\Di\Aop\AbstractAspect;
use Hyperf\Di\Aop\ProceedingJoinPoint;
use longlang\phpkafka\Producer\ProduceMessage;
Expand Down Expand Up @@ -84,7 +83,6 @@ function (Scope $scope) use ($proceedingJoinPoint, $messageId, $destinationName,
->setDescription(sprintf('%s::%s()', $proceedingJoinPoint->className, $proceedingJoinPoint->methodName))
->setOrigin('auto.kafka')
->setData([
'coroutine.id' => Coroutine::id(),
'messaging.system' => 'kafka',
'messaging.operation' => 'publish',
'messaging.message.id' => $messageId,
Expand Down Expand Up @@ -124,7 +122,7 @@ function (Scope $scope) use ($proceedingJoinPoint, $messages) {
->setOp('queue.publish')
->setDescription(sprintf('%s::%s()', $proceedingJoinPoint->className, $proceedingJoinPoint->methodName))
->setOrigin('auto.kafka')
->setData(['coroutine.id' => Coroutine::id()])
->setData(['message.count' => count($messages)])
);
}
}
2 changes: 0 additions & 2 deletions src/sentry/src/Tracing/Aspect/RedisAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use FriendsOfHyperf\Sentry\Switcher;
use FriendsOfHyperf\Support\RedisCommand;
use Hyperf\Coroutine\Coroutine;
use Hyperf\Di\Aop\AbstractAspect;
use Hyperf\Di\Aop\ProceedingJoinPoint;
use Hyperf\Redis\Event\CommandExecuted;
Expand Down Expand Up @@ -59,7 +58,6 @@ class_exists(CommandExecuted::class)
$pool = $this->container->get(PoolFactory::class)->getPool($poolName);
$config = (fn () => $this->config ?? [])->call($pool);
$data = [
'coroutine.id' => Coroutine::id(),
'db.system' => 'redis',
'db.statement' => (new RedisCommand($arguments['name'], $arguments['arguments']))->__toString(),
'db.redis.connection' => $poolName,
Expand Down
2 changes: 0 additions & 2 deletions src/sentry/src/Tracing/Aspect/RpcAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use FriendsOfHyperf\Sentry\Util\Carrier;
use Hyperf\Context\Context;
use Hyperf\Contract\ConfigInterface;
use Hyperf\Coroutine\Coroutine;
use Hyperf\Di\Aop\AbstractAspect;
use Hyperf\Di\Aop\ProceedingJoinPoint;
use Hyperf\Rpc;
Expand Down Expand Up @@ -81,7 +80,6 @@ private function handleGenerateRpcPath(ProceedingJoinPoint $proceedingJoinPoint)
->setDescription($path)
->setOrigin('auto.rpc')
->setData([
'coroutine.id' => Coroutine::id(),
'rpc.system' => $system,
'rpc.service' => $service,
'rpc.method' => $proceedingJoinPoint->arguments['keys']['methodName'] ?? '',
Expand Down
3 changes: 1 addition & 2 deletions src/sentry/src/Tracing/Aspect/TraceAnnotationAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use FriendsOfHyperf\Sentry\Switcher;
use FriendsOfHyperf\Sentry\Tracing\Annotation\Trace;
use Hyperf\Coroutine\Coroutine;
use Hyperf\Di\Aop\AbstractAspect;
use Hyperf\Di\Aop\ProceedingJoinPoint;
use Sentry\State\Scope;
Expand Down Expand Up @@ -42,7 +41,7 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint)
return $proceedingJoinPoint->process();
}

$data = ['coroutine.id' => Coroutine::id()];
$data = [];
$methodName = $proceedingJoinPoint->methodName;

if (in_array($methodName, ['__call', '__callStatic'])) {
Expand Down
12 changes: 0 additions & 12 deletions src/sentry/src/Tracing/Listener/EventHandleListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ protected function handleDbQueryExecuted(DbEvent\QueryExecuted $event): void
}

$data = [
'coroutine.id' => Coroutine::id(),
'db.system' => $event->connection->getDriverName(),
'db.name' => $event->connection->getDatabaseName(),
];
Expand Down Expand Up @@ -228,7 +227,6 @@ protected function handleDbTransactionBeginning(DbEvent\TransactionBeginning $ev
->setOrigin('auto.db')
->setStartTimestamp(microtime(true))
->setData([
'coroutine.id' => Coroutine::id(),
'db.system' => $event->connection->getDriverName(),
'db.name' => $event->connection->getDatabaseName(),
'db.pool.name' => $event->connectionName,
Expand Down Expand Up @@ -394,8 +392,6 @@ protected function handleCommandStarting(CommandEvent\BeforeHandle $event): void
->setOp('console.command')
->setDescription($command->getDescription())
->setOrigin('auto.command')
->setSource(TransactionSource::custom())
->setData(['coroutine.id' => Coroutine::id()])
);
}

Expand Down Expand Up @@ -484,7 +480,6 @@ function (Scope $scope) use ($event) {
->setOp('db.redis')
->setDescription($redisStatement)
->setData([
'coroutine.id' => Coroutine::id(),
'db.system' => 'redis',
'db.statement' => $redisStatement,
'db.redis.connection' => $event->connectionName,
Expand Down Expand Up @@ -516,7 +511,6 @@ protected function handleCrontabTaskStarting(CrontabEvent\BeforeExecute $event):
->setDescription($crontab->getMemo())
->setOrigin('auto.crontab')
->setSource(TransactionSource::task())
->setData(['coroutine.id' => Coroutine::id()])
);
}

Expand Down Expand Up @@ -584,8 +578,6 @@ protected function handleAmqpMessageProcessing(AmqpEvent\BeforeConsume $event):
->setOp('queue.process')
->setDescription($message::class)
->setOrigin('auto.amqp')
->setSource(TransactionSource::custom())
->setData(['coroutine.id' => Coroutine::id()])
);
}

Expand Down Expand Up @@ -666,8 +658,6 @@ protected function handleKafkaMessageProcessing(KafkaEvent\BeforeConsume $event)
->setOp('queue.process')
->setDescription($consumer::class)
->setOrigin('auto.kafka')
->setSource(TransactionSource::custom())
->setData(['coroutine.id' => Coroutine::id()])
);
}

Expand Down Expand Up @@ -732,8 +722,6 @@ protected function handleAsyncQueueJobProcessing(AsyncQueueEvent\BeforeHandle $e
->setOp('queue.process')
->setDescription('async_queue: ' . $job::class)
->setOrigin('auto.async_queue')
->setSource(TransactionSource::custom())
->setData(['coroutine.id' => Coroutine::id()])
);
}

Expand Down
18 changes: 18 additions & 0 deletions src/sentry/src/Tracing/Tracer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
namespace FriendsOfHyperf\Sentry\Tracing;

use FriendsOfHyperf\Sentry\Switcher;
use Hyperf\Engine\Coroutine;
use Sentry\SentrySdk;
use Sentry\State\HubInterface;
use Sentry\State\Scope;
use Sentry\Tracing\SpanContext;
use Sentry\Tracing\SpanStatus;
use Sentry\Tracing\Transaction;
use Sentry\Tracing\TransactionContext;
use Sentry\Tracing\TransactionSource;
use Throwable;

use function Hyperf\Tappable\tap;
Expand All @@ -39,6 +41,20 @@ public function startTransaction(TransactionContext $transactionContext, array $
tap(clone SentrySdk::getCurrentHub(), fn (HubInterface $hub) => $hub->pushScope())
);

$transactionContext->setData(['coroutine.id' => Coroutine::id()] + $transactionContext->getData());

if ($transactionContext->getStartTimestamp() === null) {
$transactionContext->setStartTimestamp(microtime(true));
}

if ($transactionContext->getStatus() === null) {
$transactionContext->setStatus(SpanStatus::ok());
}

if ($transactionContext->getMetadata()->getSource() === null) {
$transactionContext->setSource(TransactionSource::custom());
}

$transaction = $hub->startTransaction($transactionContext, $customSamplingContext);

$hub->setSpan($transaction);
Expand Down Expand Up @@ -67,6 +83,8 @@ public function trace(callable $trace, SpanContext $context)
$context->setStartTimestamp(microtime(true));
}

$context->setData(['coroutine.id' => Coroutine::id()] + $context->getData());

return trace(
function (Scope $scope) use ($trace, $isTracingExtraTagEnabled) {
try {
Expand Down
Loading