From 538aa073d6ef989939c5524ec6cac8ef8b509d03 Mon Sep 17 00:00:00 2001 From: Shueh Chou Lu Date: Fri, 10 Sep 2021 11:02:28 +0800 Subject: [PATCH] fix: set status, error or falut, after response (#17) --- src/Collectors/SegmentCollector.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Collectors/SegmentCollector.php b/src/Collectors/SegmentCollector.php index f2d74d1..acd3f14 100644 --- a/src/Collectors/SegmentCollector.php +++ b/src/Collectors/SegmentCollector.php @@ -156,8 +156,12 @@ public function submitHttpTracer($response): void if (app()->bound(Auth::class) && Auth::check()) { $tracer->setUser((string) Auth::user()->getAuthIdentifier()); } + + $statusCode = $response->getStatusCode(); $tracer->end() - ->setResponseCode($response->getStatusCode()) + ->setResponseCode($statusCode) + ->setError($statusCode >= 400 && $statusCode < 500) + ->setFault($statusCode >= 500 && $statusCode < 600) ->submit(new $submitterClass()); }