{"id":345462,"date":"2023-02-15T15:02:34","date_gmt":"2023-02-15T15:02:34","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=345462"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=345462","title":{"rendered":"<span>Spring Boot. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0437\u0430\u0434\u0430\u0447 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0443\u0447\u0430\u0441\u0442\u043a\u043e\u0432 \u043a\u043e\u0434\u0430 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043b\u043e\u0432\u0438\u0442\u044c \u0443\u0437\u043a\u0438\u0435 \u043c\u0435\u0441\u0442\u0430 \u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u0443 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/p>\n<p>\u0422.\u043a. \u0440\u0435\u0447\u044c \u0448\u043b\u0430 \u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u0430\u0432\u043d\u043e, \u0438 \u0432 \u043d\u0435\u0433\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u043c\u0435\u0441\u044f\u0446\u044b \u043d\u0435 \u0432\u043d\u043e\u0441\u0438\u043b\u0438\u0441\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043f\u043e\u0432\u0438\u043d\u0443\u044f\u0441\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u201c\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 &#8212; \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0439\u201d, \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0442\u044c\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e, \u043d\u0435 \u043f\u0440\u0438\u043a\u0430\u0441\u0430\u044f\u0441\u044c \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 \u0441\u0435\u0440\u0432\u0438\u0441\u0430.<\/p>\n<p>\u0414\u043b\u044f \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441\u0430\u043c\u044b\u043c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0432\u0438\u0434\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 AOP \u043f\u043e\u0434\u0445\u043e\u0434\u0430. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 Spring \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 AOP \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 <a href=\"https:\/\/docs.spring.io\/spring-framework\/docs\/current\/reference\/html\/core.html#aop\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<p>\u0412 \u0441\u0435\u0442\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u043e\u0432 \u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 Spring Boot \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u0445 AOP \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, <a href=\"https:\/\/www.baeldung.com\/spring-performance-logging\">\u043e\u0434\u0438\u043d \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445<\/a> \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d \u0437\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435: Java, Spring Boot 2.5.6., Maven 3.6.3.<br \/>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438:<\/p>\n<pre><code class=\"xml\">&lt;parent>       &lt;groupId>org.springframework.boot&lt;\/groupId>       &lt;artifactId>spring-boot-starter-parent&lt;\/artifactId>       &lt;version>2.5.6&lt;\/version> &lt;\/parent><\/code><\/pre>\n<pre><code class=\"xml\">&lt;dependency>       &lt;groupId>org.springframework.boot&lt;\/groupId>       &lt;artifactId>spring-boot-starter-web&lt;\/artifactId>   &lt;\/dependency><\/code><\/pre>\n<pre><code class=\"xml\">&lt;dependency>       &lt;groupId>org.springframework.boot&lt;\/groupId>       &lt;artifactId>spring-boot-starter-aop&lt;\/artifactId>   &lt;\/dependency><\/code><\/pre>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0438 \u043f\u0430\u0440\u0443 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432:<\/p>\n<pre><code class=\"java\">package ru.alfastrah.profilingdemo.controller;      import org.springframework.web.bind.annotation.GetMapping;   import org.springframework.web.bind.annotation.RestController;   import ru.alfastrah.profilingdemo.service.SomeService;      @RestController   public class SomeController {          private final SomeService service;          public SomeController(SomeService service) {           this.service = service;       }          @GetMapping(path = \"\/something\")       public String doSomething() throws InterruptedException {           return service.doSomething();       }   }  <\/code><\/pre>\n<pre><code class=\"java\">package ru.alfastrah.profilingdemo.service;      import org.springframework.stereotype.Service;   import java.util.concurrent.TimeUnit;      @Service   public class SomeService {          private final SomeAnotherService anotherService;          public SomeService(SomeAnotherService anotherService) {           this.anotherService = anotherService;       }          public String doSomething() throws InterruptedException {           TimeUnit.SECONDS.sleep(1);           String somethingElse = anotherService.doSomethingElse();           return \"did something and \" + somethingElse;       }   }  <\/code><\/pre>\n<p>\u0422\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f AOP \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"java\">package ru.alfastrah.profilingdemo;      import org.aspectj.lang.annotation.Pointcut;   import org.springframework.aop.Advisor;   import org.springframework.aop.aspectj.AspectJExpressionPointcut;   import org.springframework.aop.interceptor.PerformanceMonitorInterceptor;   import org.springframework.aop.support.DefaultPointcutAdvisor;   import org.springframework.context.annotation.Bean;   import org.springframework.context.annotation.Configuration;   import org.springframework.context.annotation.EnableAspectJAutoProxy;      @Configuration   @EnableAspectJAutoProxy   public class ProfilingConfiguration {          @Pointcut(\"execution(public String ru.alfastrah.profilingdemo.service.SomeService.doSomething(..))\")       public void monitor() { }          @Bean       public PerformanceMonitorInterceptor interceptor() {           return new PerformanceMonitorInterceptor();       }          @Bean       public Advisor performanceMonitorAdvisor() {           var pointcut = new AspectJExpressionPointcut();           pointcut.setExpression(\"ru.alfastrah.ProfilingConfiguration .monitor()\");           return new DefaultPointcutAdvisor(pointcut, interceptor());       }   }  <\/code><\/pre>\n<p>\u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f <em>PerformanceMonitorInterceptor<\/em> \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 <em>TRACE<\/em>:<\/p>\n<pre><code class=\"java\">logging.level.org.springframework.aop.interceptor.PerformanceMonitorInterceptor=TRACE<\/code><\/pre>\n<p>\u0418 \u0432\u0441\u0451 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0432 \u043b\u043e\u0433\u0430\u0445 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 doSomething:<\/p>\n<pre><code class=\"java\">o.s.a.i.PerformanceMonitorInterceptor : StopWatch 'ru.alfastrah.profilingdemo.service.SomeService.doSomething': running time = 3022447900 ns<\/code><\/pre>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c, \u0446\u0435\u043b\u044c \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u0430, \u043d\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043d\u0435 \u0431\u044b \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c (\u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434) \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c.<\/p>\n<p><strong>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445<\/strong>, \u0441\u043c\u0443\u0449\u0430\u0435\u0442 \u0432\u044b\u0432\u043e\u0434 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432 \u043d\u0430\u043d\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445. \u0422\u0430\u043a\u0430\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0438 \u043a \u0447\u0435\u043c\u0443, \u0430 \u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043b\u043e\u0433\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f <em>AbstractMonitoringInterceptor<\/em> &#8212; <em>PerformanceMonitorInterceptor<\/em>. \u042f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0451 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u044e:<\/p>\n<pre><code class=\"java\">public class CustomPerformanceMonitorInterceptor extends AbstractMonitoringInterceptor {        @Override     protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {           String name = this.createInvocationTraceName(invocation);           var stopWatch = new StopWatch(name);           stopWatch.start(name);              Object result;           try {               result = invocation.proceed();           } finally {               stopWatch.stop();               this.writeToLog(logger, String.format(\"Profiling: %s. Running time: %f sec\", name, stopWatch.getTotalTimeSeconds()));           }              return result;       }   }  <\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0448 \u0438\u043d\u0442\u0435\u0440\u0441\u0435\u043f\u0442\u043e\u0440 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e, \u043f\u043e\u043f\u0443\u0442\u043d\u043e \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u044f\u0441\u044c \u043e\u0442 \u0438\u0437\u043b\u0438\u0448\u043d\u0435\u0433\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0435\u0433\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0438\u043d\u0430:<\/p>\n<pre><code class=\"java\">@Bean   public Advisor performanceMonitorAdvisor() {       var pointcut = new AspectJExpressionPointcut();       pointcut.setExpression(\"ru.alfastrah.profilingdemo.ProfilingConfiguration.monitor()\");       return new DefaultPointcutAdvisor(pointcut, new CustomPerformanceMonitorInterceptor());   }   <\/code><\/pre>\n<p>\u0418 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"java\">logging.level.ru.alfastrah.profilingdemo.config.CustomPerformanceMonitorInterceptor=TRACE<\/code><\/pre>\n<p>\u0418 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u0435 \u043b\u043e\u0433\u0438:<\/p>\n<pre><code class=\"java\">.p.c.CustomPerformanceMonitorInterceptor : Profiling: ru.alfastrah.profilingdemo.service.SomeService.doSomething. Running time: 3,018584 sec<\/code><\/pre>\n<p><strong>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445<\/strong>, \u043c\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u043b\u0438 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u043a\u043e\u0434 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u043d\u043e \u0432\u044b\u0431\u043e\u0440 \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0434 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435, \u0447\u0442\u043e \u0432\u043b\u0435\u0447\u0435\u0442 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438, \u0435\u0441\u043b\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 &#8212; \u0440\u0435\u0432\u044c\u044e, \u043c\u0435\u0440\u0434\u0436, \u0440\u0435\u043b\u0438\u0437 \u0438 \u0442.\u043f. \u041c\u043d\u0435 \u0431\u044b \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u043d\u0444\u0438\u0433-\u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0438 \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c\u0441\u044f &#171;\u043d\u0430 \u043b\u0435\u0442\u0443&#187;. \u041f\u043e \u044d\u0442\u043e\u0439 \u0436\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043c\u043d\u043e\u044e \u043d\u0435 \u0431\u044b\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u043d\u0430\u0434 \u0441\u0430\u043c\u0438\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438\\\u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0411\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e, \u0443 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439 \u0432 \u0444\u0430\u0439\u043b\u0435, \u0430 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438, \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u041d\u043e \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u0431\u044b\u043b\u043e \u0446\u0435\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0439 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u0430 \u043d\u0443\u0436\u0435\u043d \u0431\u044b\u043b \u043b\u0435\u0433\u043a\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c, \u043d\u0435 \u043e\u0441\u0442\u0430\u0432\u0438\u0432 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0441\u043b\u0435\u0434\u043e\u0432 \u0432 \u043a\u043e\u0434\u0435.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u0438\u0437\u0431\u0430\u0432\u0438\u043c\u0441\u044f \u043e\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <em>Pointcut<\/em> \u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 <em>Value<\/em>:<\/p>\n<pre><code class=\"java\">  @Value(\"${profiling.pointcuts}\")     private String pointcuts;        @Bean     public Advisor performanceMonitorAdvisor() {           var pointcut = new AspectJExpressionPointcut();           pointcut.setExpression(pointcuts);           return new DefaultPointcutAdvisor(pointcut, new CustomPerformanceMonitorInterceptor());       }<\/code><\/pre>\n<p>\u0412 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043f\u0440\u043e\u043f\u0438\u0448\u0435\u043c expression (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 <a href=\"https:\/\/docs.spring.io\/spring-framework\/docs\/current\/reference\/html\/core.html#aop-pointcuts\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>):<\/p>\n<pre><code class=\"java\">profiling.pointcuts=execution(public * ru.alfastrah.profilingdemo.service.SomeService.doSomething(..))<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 || :<\/p>\n<pre><code class=\"java\">profiling.pointcuts=execution(public * ru.alfastrah.profilingdemo.service.SomeService.doSomething(..)) || \\   execution(public * ru.alfastrah.profilingdemo.service.SomeAnotherService.doSomethingElse(..))<\/code><\/pre>\n<p>\u043b\u0438\u0431\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u043a \u0446\u0435\u043b\u043e\u043c\u0443 \u043f\u0430\u043a\u0435\u0442\u0443:<\/p>\n<pre><code class=\"java\">profiling.pointcuts=execution(public * ru.alfastrah.profilingdemo..*(..))<\/code><\/pre>\n<p>\u0423\u0436\u0435 \u043b\u0443\u0447\u0448\u0435, \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u043a\u043e\u0434 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c, \u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043c\u0443\u0449\u0430\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 execution-\u043e\u0432, \u043a\u0443\u0447\u0430 \u0441\u043a\u043e\u0431\u043e\u043a, \u0437\u0432\u0435\u0437\u0434\u043e\u0447\u0435\u043a \u0438 \u0442.\u043f. &#8212; \u043b\u0435\u0433\u043a\u043e \u043e\u0448\u0438\u0431\u0438\u0442\u044c\u0441\u044f, \u0434\u0430 \u0438 \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a \u0441\u0435\u0431\u0435.<\/p>\n<p>\u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u043c \u0432\u0440\u044f\u0434 \u043b\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 pointcut expressions, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e &#8212; \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433 \u043a\u043b\u0430\u0441\u0441 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u043a \u043f\u0430\u043a\u0435\u0442\u0443\\\u043a\u043b\u0430\u0441\u0441\u0443\\\u043c\u0435\u0442\u043e\u0434\u0443:<\/p>\n<pre><code class=\"java\">@Value(\"${profiling.pointcuts}\")   private List&lt;String> pointcuts;      @Bean   public Advisor performanceMonitorAdvisor() {       var pointcut = new AspectJExpressionPointcut();       pointcut.setExpression(formExpressions());       return new DefaultPointcutAdvisor(pointcut, new CustomPerformanceMonitorInterceptor());   }      private String formExpressions() {       return pointcuts               .stream()               .map(this::formExpression)               .collect(Collectors.joining(\" || \"));   }    private String formExpression(String pointcut) {       return pointcut.endsWith(\")\") ? execForMethod(pointcut) : execForPackageClass(pointcut);   }      private String execForMethod(String pointcut) {       return String.format(\"execution(public * %s(..))\", pointcut.replace(\"()\", \"\"));   }      private String execForPackageClass(String pointcut) {       return String.format(\"execution(public * %s..*(..))\", pointcut);   }  <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u043a \u043f\u0430\u043a\u0435\u0442\u0443\\\u043a\u043b\u0430\u0441\u0441\u0443\\\u043c\u0435\u0442\u043e\u0434\u0443 \u0432 \u0432\u0438\u0434\u0435 \u0441\u043f\u0438\u0441\u043a\u0430:<\/p>\n<pre><code class=\"java\">profiling.pointcuts=ru.alfastrah.profilingdemo.service.SomeService.doSomething(), \\    ru.alfastrah.profilingdemo.service.SomeAnotherService, \\    ru.alfastrah.profilingdemo.controller <\/code><\/pre>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u0438 \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 \u0442\u0440\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 (\u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u043f\u0430\u043a\u0435\u0442\u0430, \u043a\u043b\u0430\u0441\u0441\u0430, \u043c\u0435\u0442\u043e\u0434\u0430) \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442:<\/p>\n<pre><code class=\"java\">.a.p.CustomPerformanceMonitorInterceptor : Profiling: ru.alfastrah.profilingdemo.service.SomeAnotherService.doSomethingElse. Running time: 2,010053 sec .a.p.CustomPerformanceMonitorInterceptor : Profiling: ru.alfastrah.profilingdemo.service.SomeService.doSomething. Running time: 3,015384 sec .a.p.CustomPerformanceMonitorInterceptor : Profiling: ru.alfastrah.profilingdemo.controller.SomeController.doSomething. Running time: 3,018843 sec<\/code><\/pre>\n<p><strong>\u0412-\u0442\u0440\u0435\u0442\u044c\u0438\u0445<\/strong>, \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0434\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043b\u043b\u0435\u0433\u0430\u043c \u0438 \u0441\u0435\u0431\u0435 \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435\\\u043d\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0443\u0441\u0438\u043b\u0438\u044f\u043c\u0438 \u0438 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043c \u043d\u0430\u0448\u0443 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0432 spring-starter.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 (\u0438\u043b\u0438 \u043c\u043e\u0434\u0443\u043b\u044c) \u0434\u043b\u044f \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0430, pom \u0444\u0430\u0439\u043b \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?>   &lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"     xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 https:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\">       &lt;modelVersion>4.0.0&lt;\/modelVersion>       &lt;parent>           &lt;groupId>org.springframework.boot&lt;\/groupId>           &lt;artifactId>spring-boot-starter-parent&lt;\/artifactId>           &lt;version>2.5.6&lt;\/version>           &lt;relativePath\/> &lt;!-- lookup parent from repository -->     &lt;\/parent>       &lt;groupId>ru.alfastrah&lt;\/groupId>       &lt;artifactId>profiling-demo-starter&lt;\/artifactId>       &lt;version>0.0.1-SNAPSHOT&lt;\/version>       &lt;name>profiling-demo-starter&lt;\/name>       &lt;description>profiling-demo-starter&lt;\/description>       &lt;properties>           &lt;java.version>11&lt;\/java.version>       &lt;\/properties>       &lt;dependencies>           &lt;dependency>               &lt;groupId>org.springframework.boot&lt;\/groupId>               &lt;artifactId>spring-boot-starter&lt;\/artifactId>           &lt;\/dependency>          &lt;\/dependencies>      &lt;\/project><\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043c \u0432 \u0441\u0442\u0430\u0440\u0442\u0435\u0440 <em>ProfilingConfiguration<\/em> \u0438 <em>CustomPerformanceMonitorInterceptor<\/em>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u043f\u0438\u0448\u0435\u043c \u0430\u0432\u0442\u043e\u043a\u043e\u043d\u0444\u0438\u0433 \u0432 \u0444\u0430\u0439\u043b\u0435 <em>resources\/META-INF\/spring.factories<\/em>:<\/p>\n<pre><code class=\"java\">org.springframework.boot.autoconfigure.EnableAutoConfiguration=ru.alfastrah.profilingdemostarter.ProfilingConfiguration<\/code><\/pre>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c, \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0442\u0430\u0440\u0442\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0435\u0449\u0435 \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0443\u0436\u0435\u043d. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <em>ConditionalOnProperty<\/em> \u0441 <em>value<\/em>, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u043c \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0430 <em>profiling.pointcuts<\/em>. \u041d\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0443\u043f\u0430\u0434\u0435\u0442 \u0441 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435 \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0431\u0438\u043d <em>Advisor<\/em> \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0432 <em>profiling.pointcuts<\/em> \u0431\u0443\u0434\u0435\u0442 \u043f\u0443\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430, \u0430 \u043c\u043d\u0435 \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u0430\u0434\u0430\u043b\u043e \u0438\u0437-\u0437\u0430 \u0437\u0430\u0431\u044b\u0442\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c <a href=\"https:\/\/docs.spring.io\/spring-framework\/docs\/current\/reference\/html\/core.html#expressions\">Spring Expression Language<\/a>:<\/p>\n<pre><code class=\"java\">@Configuration   @EnableAspectJAutoProxy   @ConditionalOnExpression(\"T(org.springframework.util.StringUtils).hasText('${profiling.pointcuts:}')\")   public class ProfilingConfiguration {   ... }<\/code><\/pre>\n<p>\u0412 \u0442\u0430\u043a\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0431\u0438\u043d \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438 \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043e\u043d\u0444\u0438\u0433 <em>profiling.pointcuts<\/em>, \u0438 \u043e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0442\u0435\u043a\u0441\u0442.<\/p>\n<p><strong>\u0412 \u0438\u0442\u043e\u0433\u0435<\/strong> \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0441\u0442\u0430\u0440\u0442\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438 \u0433\u0438\u0431\u043a\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432 \u043b\u044e\u0431\u043e\u0439 \u0441\u0435\u0440\u0432\u0438\u0441, \u043d\u0435 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u044f \u0435\u0433\u043e \u043a\u043e\u0434. \u0412\u0441\u0451, \u0447\u0442\u043e \u043e\u0442 \u043d\u0430\u0441 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, &#8212; \u043b\u0438\u0448\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c:<\/p>\n<pre><code class=\"xml\">&lt;dependency>       &lt;groupId>ru.alfastrah&lt;\/groupId>       &lt;artifactId>profiling-demo-starter&lt;\/artifactId>       &lt;version>0.0.1-SNAPSHOT&lt;\/version>   &lt;\/dependency><\/code><\/pre>\n<p>\u0418 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435:<\/p>\n<pre><code class=\"java\">logging.level.ru.alfastrah.profilingdemostarter.CustomPerformanceMonitorInterceptor=TRACE  profiling.pointcuts=ru.alfastrah.profilingdemo.service.SomeService.doSomething(), \\    ru.alfastrah.profilingdemo.service.SomeAnotherService, \\    ru.alfastrah.profilingdemo.controller <\/code><\/pre>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/alfastrah\/blog\/717114\/\"> https:\/\/habr.com\/ru\/company\/alfastrah\/blog\/717114\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0437\u0430\u0434\u0430\u0447 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0443\u0447\u0430\u0441\u0442\u043a\u043e\u0432 \u043a\u043e\u0434\u0430 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043b\u043e\u0432\u0438\u0442\u044c \u0443\u0437\u043a\u0438\u0435 \u043c\u0435\u0441\u0442\u0430 \u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u0443 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/p>\n<p>\u0422.\u043a. \u0440\u0435\u0447\u044c \u0448\u043b\u0430 \u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u0430\u0432\u043d\u043e, \u0438 \u0432 \u043d\u0435\u0433\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u043c\u0435\u0441\u044f\u0446\u044b \u043d\u0435 \u0432\u043d\u043e\u0441\u0438\u043b\u0438\u0441\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043f\u043e\u0432\u0438\u043d\u0443\u044f\u0441\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u201c\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 &#8212; \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0439\u201d, \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0442\u044c\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e, \u043d\u0435 \u043f\u0440\u0438\u043a\u0430\u0441\u0430\u044f\u0441\u044c \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 \u0441\u0435\u0440\u0432\u0438\u0441\u0430.<\/p>\n<p>\u0414\u043b\u044f \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441\u0430\u043c\u044b\u043c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0432\u0438\u0434\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 AOP \u043f\u043e\u0434\u0445\u043e\u0434\u0430. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 Spring \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 AOP \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 <a href=\"https:\/\/docs.spring.io\/spring-framework\/docs\/current\/reference\/html\/core.html#aop\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<p>\u0412 \u0441\u0435\u0442\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u043e\u0432 \u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 Spring Boot \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u0445 AOP \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, <a href=\"https:\/\/www.baeldung.com\/spring-performance-logging\">\u043e\u0434\u0438\u043d \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445<\/a> \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d \u0437\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435: Java, Spring Boot 2.5.6., Maven 3.6.3.<br \/>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438:<\/p>\n<pre><code class=\"xml\">&lt;parent>       &lt;groupId>org.springframework.boot&lt;\/groupId>       &lt;artifactId>spring-boot-starter-parent&lt;\/artifactId>       &lt;version>2.5.6&lt;\/version> &lt;\/parent><\/code><\/pre>\n<pre><code class=\"xml\">&lt;dependency>       &lt;groupId>org.springframework.boot&lt;\/groupId>       &lt;artifactId>spring-boot-starter-web&lt;\/artifactId>   &lt;\/dependency><\/code><\/pre>\n<pre><code class=\"xml\">&lt;dependency>       &lt;groupId>org.springframework.boot&lt;\/groupId>       &lt;artifactId>spring-boot-starter-aop&lt;\/artifactId>   &lt;\/dependency><\/code><\/pre>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0438 \u043f\u0430\u0440\u0443 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432:<\/p>\n<pre><code class=\"java\">package ru.alfastrah.profilingdemo.controller;      import org.springframework.web.bind.annotation.GetMapping;   import org.springframework.web.bind.annotation.RestController;   import ru.alfastrah.profilingdemo.service.SomeService;      @RestController   public class SomeController {          private final SomeService service;          public SomeController(SomeService service) {           this.service = service;       }          @GetMapping(path = \"\/something\")       public String doSomething() throws InterruptedException {           return service.doSomething();       }   }  <\/code><\/pre>\n<pre><code class=\"java\">package ru.alfastrah.profilingdemo.service;      import org.springframework.stereotype.Service;   import java.util.concurrent.TimeUnit;      @Service   public class SomeService {          private final SomeAnotherService anotherService;          public SomeService(SomeAnotherService anotherService) {           this.anotherService = anotherService;       }          public String doSomething() throws InterruptedException {           TimeUnit.SECONDS.sleep(1);           String somethingElse = anotherService.doSomethingElse();           return \"did something and \" + somethingElse;       }   }  <\/code><\/pre>\n<p>\u0422\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f AOP \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"java\">package ru.alfastrah.profilingdemo;      import org.aspectj.lang.annotation.Pointcut;   import org.springframework.aop.Advisor;   import org.springframework.aop.aspectj.AspectJExpressionPointcut;   import org.springframework.aop.interceptor.PerformanceMonitorInterceptor;   import org.springframework.aop.support.DefaultPointcutAdvisor;   import org.springframework.context.annotation.Bean;   import org.springframework.context.annotation.Configuration;   import org.springframework.context.annotation.EnableAspectJAutoProxy;      @Configuration   @EnableAspectJAutoProxy   public class ProfilingConfiguration {          @Pointcut(\"execution(public String ru.alfastrah.profilingdemo.service.SomeService.doSomething(..))\")       public void monitor() { }          @Bean       public PerformanceMonitorInterceptor interceptor() {           return new PerformanceMonitorInterceptor();       }          @Bean       public Advisor performanceMonitorAdvisor() {           var pointcut = new AspectJExpressionPointcut();           pointcut.setExpression(\"ru.alfastrah.ProfilingConfiguration .monitor()\");           return new DefaultPointcutAdvisor(pointcut, interceptor());       }   }  <\/code><\/pre>\n<p>\u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f <em>PerformanceMonitorInterceptor<\/em> \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 <em>TRACE<\/em>:<\/p>\n<pre><code class=\"java\">logging.level.org.springframework.aop.interceptor.PerformanceMonitorInterceptor=TRACE<\/code><\/pre>\n<p>\u0418 \u0432\u0441\u0451 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0432 \u043b\u043e\u0433\u0430\u0445 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 doSomething:<\/p>\n<pre><code class=\"java\">o.s.a.i.PerformanceMonitorInterceptor : StopWatch 'ru.alfastrah.profilingdemo.service.SomeService.doSomething': running time = 3022447900 ns<\/code><\/pre>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c, \u0446\u0435\u043b\u044c \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u0430, \u043d\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043d\u0435 \u0431\u044b \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c (\u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434) \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c.<\/p>\n<p><strong>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445<\/strong>, \u0441\u043c\u0443\u0449\u0430\u0435\u0442 \u0432\u044b\u0432\u043e\u0434 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432 \u043d\u0430\u043d\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445. \u0422\u0430\u043a\u0430\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0438 \u043a \u0447\u0435\u043c\u0443, \u0430 \u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043b\u043e\u0433\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f <em>AbstractMonitoringInterceptor<\/em> &#8212; <em>PerformanceMonitorInterceptor<\/em>. \u042f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0451 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u044e:<\/p>\n<pre><code class=\"java\">public class CustomPerformanceMonitorInterceptor extends AbstractMonitoringInterceptor {        @Override     protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {           String name = this.createInvocationTraceName(invocation);           var stopWatch = new StopWatch(name);           stopWatch.start(name);              Object result;           try {               result = invocation.proceed();           } finally {               stopWatch.stop();               this.writeToLog(logger, String.format(\"Profiling: %s. Running time: %f sec\", name, stopWatch.getTotalTimeSeconds()));           }              return result;       }   }  <\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0448 \u0438\u043d\u0442\u0435\u0440\u0441\u0435\u043f\u0442\u043e\u0440 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e, \u043f\u043e\u043f\u0443\u0442\u043d\u043e \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u044f\u0441\u044c \u043e\u0442 \u0438\u0437\u043b\u0438\u0448\u043d\u0435\u0433\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0435\u0433\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0438\u043d\u0430:<\/p>\n<pre><code class=\"java\">@Bean   public Advisor performanceMonitorAdvisor() {       var pointcut = new AspectJExpressionPointcut();       pointcut.setExpression(\"ru.alfastrah.profilingdemo.ProfilingConfiguration.monitor()\");       return new DefaultPointcutAdvisor(pointcut, new CustomPerformanceMonitorInterceptor());   }   <\/code><\/pre>\n<p>\u0418 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"java\">logging.level.ru.alfastrah.profilingdemo.config.CustomPerformanceMonitorInterceptor=TRACE<\/code><\/pre>\n<p>\u0418 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u0435 \u043b\u043e\u0433\u0438:<\/p>\n<pre><code class=\"java\">.p.c.CustomPerformanceMonitorInterceptor : Profiling: ru.alfastrah.profilingdemo.service.SomeService.doSomething. Running time: 3,018584 sec<\/code><\/pre>\n<p><strong>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445<\/strong>, \u043c\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u043b\u0438 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u043a\u043e\u0434 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u043d\u043e \u0432\u044b\u0431\u043e\u0440 \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0434 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435, \u0447\u0442\u043e \u0432\u043b\u0435\u0447\u0435\u0442 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438, \u0435\u0441\u043b\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 &#8212; \u0440\u0435\u0432\u044c\u044e, \u043c\u0435\u0440\u0434\u0436, \u0440\u0435\u043b\u0438\u0437 \u0438 \u0442.\u043f. \u041c\u043d\u0435 \u0431\u044b \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u043d\u0444\u0438\u0433-\u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0438 \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c\u0441\u044f &#171;\u043d\u0430 \u043b\u0435\u0442\u0443&#187;. \u041f\u043e \u044d\u0442\u043e\u0439 \u0436\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043c\u043d\u043e\u044e \u043d\u0435 \u0431\u044b\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u043d\u0430\u0434 \u0441\u0430\u043c\u0438\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438\\\u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0411\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e, \u0443 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439 \u0432 \u0444\u0430\u0439\u043b\u0435, \u0430 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438, \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u041d\u043e \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u0431\u044b\u043b\u043e \u0446\u0435\u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0439 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u0430 \u043d\u0443\u0436\u0435\u043d \u0431\u044b\u043b \u043b\u0435\u0433\u043a\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c, \u043d\u0435 \u043e\u0441\u0442\u0430\u0432\u0438\u0432 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0441\u043b\u0435\u0434\u043e\u0432 \u0432 \u043a\u043e\u0434\u0435.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u0438\u0437\u0431\u0430\u0432\u0438\u043c\u0441\u044f \u043e\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <em>Pointcut<\/em> \u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 <em>Value<\/em>:<\/p>\n<pre><code class=\"java\">  @Value(\"${profiling.pointcuts}\")     private String pointcuts;        @Bean     public Advisor performanceMonitorAdvisor() {           var pointcut = new AspectJExpressionPointcut();           pointcut.setExpression(pointcuts);           return new DefaultPointcutAdvisor(pointcut, new CustomPerformanceMonitorInterceptor());       }<\/code><\/pre>\n<p>\u0412 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043f\u0440\u043e\u043f\u0438\u0448\u0435\u043c expression (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 <a href=\"https:\/\/docs.spring.io\/spring-framework\/docs\/current\/reference\/html\/core.html#aop-pointcuts\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>):<\/p>\n<pre><code class=\"java\">profiling.pointcuts=execution(public * ru.alfastrah.profilingdemo.service.SomeService.doSomething(..))<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 || :<\/p>\n<pre><code class=\"java\">profiling.pointcuts=execution(public * ru.alfastrah.profilingdemo.service.SomeService.doSomething(..)) || \\   execution(public * ru.alfastrah.profilingdemo.service.SomeAnotherService.doSomethingElse(..))<\/code><\/pre>\n<p>\u043b\u0438\u0431\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u043a \u0446\u0435\u043b\u043e\u043c\u0443 \u043f\u0430\u043a\u0435\u0442\u0443:<\/p>\n<pre><code class=\"java\">profiling.pointcuts=execution(public * ru.alfastrah.profilingdemo..*(..))<\/code><\/pre>\n<p>\u0423\u0436\u0435 \u043b\u0443\u0447\u0448\u0435, \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u043a\u043e\u0434 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c, \u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043c\u0443\u0449\u0430\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 execution-\u043e\u0432, \u043a\u0443\u0447\u0430 \u0441\u043a\u043e\u0431\u043e\u043a, \u0437\u0432\u0435\u0437\u0434\u043e\u0447\u0435\u043a \u0438 \u0442.\u043f. &#8212; \u043b\u0435\u0433\u043a\u043e \u043e\u0448\u0438\u0431\u0438\u0442\u044c\u0441\u044f, \u0434\u0430 \u0438 \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a \u0441\u0435\u0431\u0435.<\/p>\n<p>\u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u043c \u0432\u0440\u044f\u0434 \u043b\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 pointcut expressions, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e &#8212; \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433 \u043a\u043b\u0430\u0441\u0441 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u043a \u043f\u0430\u043a\u0435\u0442\u0443\\\u043a\u043b\u0430\u0441\u0441\u0443\\\u043c\u0435\u0442\u043e\u0434\u0443:<\/p>\n<pre><code class=\"java\">@Value(\"${profiling.pointcuts}\")   private List&lt;String> pointcuts;      @Bean   public Advisor performanceMonitorAdvisor() {       var pointcut = new AspectJExpressionPointcut();       pointcut.setExpression(formExpressions());       return new DefaultPointcutAdvisor(pointcut, new CustomPerformanceMonitorInterceptor());   }      private String formExpressions() {       return pointcuts               .stream()               .map(this::formExpression)               .collect(Collectors.joining(\" || \"));   }    private String formExpression(String pointcut) {       return pointcut.endsWith(\")\") ? execForMethod(pointcut) : execForPackageClass(pointcut);   }      private String execForMethod(String pointcut) {       return String.format(\"execution(public * %s(..))\", pointcut.replace(\"()\", \"\"));   }      private String execForPackageClass(String pointcut) {       return String.format(\"execution(public * %s..*(..))\", pointcut);   }  <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u043a \u043f\u0430\u043a\u0435\u0442\u0443\\\u043a\u043b\u0430\u0441\u0441\u0443\\\u043c\u0435\u0442\u043e\u0434\u0443 \u0432 \u0432\u0438\u0434\u0435 \u0441\u043f\u0438\u0441\u043a\u0430:<\/p>\n<pre><code class=\"java\">profiling.pointcuts=ru.alfastrah.profilingdemo.service.SomeService.doSomething(), \\    ru.alfastrah.profilingdemo.service.SomeAnotherService, \\    ru.alfastrah.profilingdemo.controller <\/code><\/pre>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u0438 \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 \u0442\u0440\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 (\u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u043f\u0430\u043a\u0435\u0442\u0430, \u043a\u043b\u0430\u0441\u0441\u0430, \u043c\u0435\u0442\u043e\u0434\u0430) \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442:<\/p>\n<pre><code class=\"java\">.a.p.CustomPerformanceMonitorInterceptor : Profiling: ru.alfastrah.profilingdemo.service.SomeAnotherService.doSomethingElse. Running time: <\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-345462","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/345462","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=345462"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/345462\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=345462"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=345462"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=345462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}