File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 1111 */
1212namespace Hyperf \Metric \Middleware ;
1313
14+ use Hyperf \Contract \ConfigInterface ;
1415use Hyperf \HttpServer \Router \Dispatched ;
1516use Hyperf \Metric \Metric ;
1617use Hyperf \Metric \Support \Uri ;
2324
2425class MetricMiddleware implements MiddlewareInterface
2526{
27+ protected array $ config ;
28+
29+ public function __construct (
30+ ConfigInterface $ config ,
31+ ) {
32+ $ this ->config = $ config ->get ('metric ' );
33+ }
34+
2635 /**
2736 * Process an incoming server request.
2837 * Processes an incoming server request in order to produce a response.
@@ -31,6 +40,10 @@ class MetricMiddleware implements MiddlewareInterface
3140 */
3241 public function process (ServerRequestInterface $ request , RequestHandlerInterface $ handler ): ResponseInterface
3342 {
43+ if (! empty ($ this ->config ['ignore_path ' ]) && preg_match ($ this ->config ['ignore_path ' ], $ request ->getUri ()->getPath ())) {
44+ return $ handler ->handle ($ request );
45+ }
46+
3447 $ labels = [
3548 'request_status ' => '500 ' ,
3649 'request_path ' => $ this ->getPath ($ request ),
You can’t perform that action at this time.
0 commit comments