From ae3b58c13c34326cf323f664884c087e6a658a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20J=C3=B3=C5=BAwiak?= Date: Wed, 18 Nov 2020 08:02:44 +0100 Subject: [PATCH] IT-3172 | Limit maximum number of spans per one transaction --- config/elastic-apm.php | 3 +++ src/Apm/SpanCollection.php | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/config/elastic-apm.php b/config/elastic-apm.php index afc8e7f..736be8b 100644 --- a/config/elastic-apm.php +++ b/config/elastic-apm.php @@ -51,6 +51,9 @@ ], 'spans' => [ + // Max number of child items displayed when viewing trace details. + 'maxTraceItems' => env('APM_MAXTRACEITEMS', 1000), + // Depth of backtraces 'backtraceDepth'=> env('APM_BACKTRACEDEPTH', 25), diff --git a/src/Apm/SpanCollection.php b/src/Apm/SpanCollection.php index 19bd298..d918343 100644 --- a/src/Apm/SpanCollection.php +++ b/src/Apm/SpanCollection.php @@ -11,5 +11,12 @@ */ class SpanCollection extends Collection { + public function push($value) + { + if ($this->count() >= config('elastic-apm.spans.maxTraceItems')) { + return; + } + parent::push($value); + } } \ No newline at end of file