From 503b38f15c669c652f57cca3f0501719a58795d0 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Thu, 24 Sep 2020 09:20:01 +0200 Subject: [PATCH] feat: Counterpart to PHP polish apm pr --- src/Sentry/Laravel/EventHandler.php | 8 +++--- src/Sentry/Laravel/Tracing/Middleware.php | 28 +++++++++---------- .../Laravel/Tracing/ViewEngineDecorator.php | 4 +-- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Sentry/Laravel/EventHandler.php b/src/Sentry/Laravel/EventHandler.php index 326c506f..6018b03e 100644 --- a/src/Sentry/Laravel/EventHandler.php +++ b/src/Sentry/Laravel/EventHandler.php @@ -281,10 +281,10 @@ private function addQueryBreadcrumb($query, $bindings, $time, $connectionName) $transaction = SentrySdk::getCurrentHub()->getTransaction(); if (null !== $transaction) { $context = new SpanContext(); - $context->op = 'sql.query'; - $context->description = $query; - $context->startTimestamp = microtime(true) - $time / 1000; - $context->endTimestamp = $context->startTimestamp + $time / 1000; + $context->setOp('sql.query'); + $context->setDescription($query); + $context->setStartTimestamp(microtime(true) - $time / 1000); + $context->setEndTimestamp($context->getStartTimestamp() + $time / 1000); $transaction->startChild($context); } diff --git a/src/Sentry/Laravel/Tracing/Middleware.php b/src/Sentry/Laravel/Tracing/Middleware.php index ebb6f06f..41fd27d4 100644 --- a/src/Sentry/Laravel/Tracing/Middleware.php +++ b/src/Sentry/Laravel/Tracing/Middleware.php @@ -60,13 +60,13 @@ private function startTransaction(Request $request, Hub $sentry): void ? TransactionContext::fromTraceparent($sentryTraceHeader) : new TransactionContext; - $context->op = 'http.server'; - $context->name = $path; - $context->data = [ + $context->setOp('http.server'); + $context->setName($path); + $context->setData([ 'url' => $path, 'method' => strtoupper($request->method()), - ]; - $context->startTimestamp = $request->server('REQUEST_TIME_FLOAT', $fallbackTime); + ]); + $context->setStartTimestamp($request->server('REQUEST_TIME_FLOAT', $fallbackTime)); $this->transaction = $sentry->startTransaction($context); @@ -77,9 +77,9 @@ private function startTransaction(Request $request, Hub $sentry): void // @TODO: We might want to move this together with the `RouteMatches` listener to some central place and or do this from the `EventHandler` app()->booted(function () use ($request, $fallbackTime): void { $spanContextStart = new SpanContext(); - $spanContextStart->op = 'app.bootstrap'; - $spanContextStart->startTimestamp = defined('LARAVEL_START') ? LARAVEL_START : $request->server('REQUEST_TIME_FLOAT', $fallbackTime); - $spanContextStart->endTimestamp = microtime(true); + $spanContextStart->setOp('app.bootstrap'); + $spanContextStart->setStartTimestamp(defined('LARAVEL_START') ? LARAVEL_START : $request->server('REQUEST_TIME_FLOAT', $fallbackTime)); + $spanContextStart->setEndTimestamp(microtime(true)); $this->transaction->startChild($spanContextStart); }); } @@ -100,15 +100,15 @@ private function addBootTimeSpans(): bool } $spanContextStart = new SpanContext(); - $spanContextStart->op = 'autoload'; - $spanContextStart->startTimestamp = LARAVEL_START; - $spanContextStart->endTimestamp = SENTRY_AUTOLOAD; + $spanContextStart->setOp('autoload'); + $spanContextStart->setStartTimestamp(LARAVEL_START); + $spanContextStart->setEndTimestamp(SENTRY_AUTOLOAD); $this->transaction->startChild($spanContextStart); $spanContextStart = new SpanContext(); - $spanContextStart->op = 'bootstrap'; - $spanContextStart->startTimestamp = SENTRY_AUTOLOAD; - $spanContextStart->endTimestamp = SENTRY_BOOTSTRAP; + $spanContextStart->setOp('bootstrap'); + $spanContextStart->setStartTimestamp(SENTRY_AUTOLOAD); + $spanContextStart->setEndTimestamp(SENTRY_BOOTSTRAP); $this->transaction->startChild($spanContextStart); return true; diff --git a/src/Sentry/Laravel/Tracing/ViewEngineDecorator.php b/src/Sentry/Laravel/Tracing/ViewEngineDecorator.php index c059273c..cc715bd7 100644 --- a/src/Sentry/Laravel/Tracing/ViewEngineDecorator.php +++ b/src/Sentry/Laravel/Tracing/ViewEngineDecorator.php @@ -37,8 +37,8 @@ public function get($path, array $data = []): string } $context = new SpanContext(); - $context->op = 'view.render'; - $context->description = $this->viewFactory->shared(self::SHARED_KEY, basename($path)); + $context->setOp('view.render'); + $context->setDescription($this->viewFactory->shared(self::SHARED_KEY, basename($path))); $span = $parentSpan->startChild($context);