diff --git a/app/Http/Middleware/MeasureRequest.php b/app/Http/Middleware/MeasureRequest.php index 2e3e89aa..c93ceba5 100644 --- a/app/Http/Middleware/MeasureRequest.php +++ b/app/Http/Middleware/MeasureRequest.php @@ -26,6 +26,17 @@ public function handle(Request $request, Closure $next): Response if ($name === null) { $name = $request->getRequestUri(); } + + $blacklist = config('open-telemetry.traces.disabledroutes', []); + if (in_array($name, $blacklist)) { + return $next($request); + } + + $blacklist = config('open-telemetry.traces.disabledpaths', []); + if (in_array($request->getRequestUri(), $blacklist)) { + return $next($request); + } + $trace = $request->header('traceparent'); $state = $request->header('tracestate'); $span = OpenTelemetry::startSpan(name: "{$request->getMethod()} {$name}", parentTrace: $trace, parentState: $state); diff --git a/config/open-telemetry.php b/config/open-telemetry.php index 5c00acc1..13f93df7 100644 --- a/config/open-telemetry.php +++ b/config/open-telemetry.php @@ -13,4 +13,11 @@ 'version' => env('OPENTELEMETRY_SERVICE_VERSION', '1.0.0'), ], 'environment' => env('OPENTELEMETRY_ENVIRONMENT', config('app.env')), + 'traces' => [ + 'disabledroutes' => [ + ], + 'disabledpaths' => [ + '/' . env('PROMETHEUS_PATH', 'prometheus'), + ] + ], ];