@Override public void responseEnd(StopWatch requestWatch, HttpServerResponse response) { requestWatch.stop(); counterService.increment("responses.count.total"); int statusCode = response.getStatusCode(); long totalTimeMillis = requestWatch.getTotalTimeMillis(); gaugeService.submit("responses.totalTime.all", totalTimeMillis); if (statusCode > 400) { gaugeService.submit("responses.totalTime.error.all", totalTimeMillis); counterService.increment("responses.count.error.total"); if (statusCode > 500) { counterService.increment("responses.count.error.server"); gaugeService.submit("responses.totalTime.error.server", totalTimeMillis); } else { counterService.increment("responses.count.error.client"); gaugeService.submit("responses.totalTime.error.client", totalTimeMillis); } } else if (statusCode > 300) { counterService.increment("responses.count.redirect"); gaugeService.submit("responses.totalTime.redirect", totalTimeMillis); } else if (statusCode > 200) { counterService.increment("responses.count.success"); gaugeService.submit("responses.totalTime.success", totalTimeMillis); } }
@Around("@annotation(com.apssouza.monitoring.Monitored)") public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable { System.out.println("callend"); Method method = ((MethodSignature) joinPoint.getSignature()).getMethod(); if (this.enabled) { StopWatch sw = new StopWatch(joinPoint.toShortString()); sw.start("invoke"); try { return joinPoint.proceed(); } finally { sw.stop(); synchronized (this) { this.callCount++; this.accumulatedCallTime += sw.getTotalTimeMillis(); } publisher.publishEvent(new MonitoringInvokedEvent( method.getName(), this.accumulatedCallTime )); } } else { return joinPoint.proceed(); } }
@Test public void testShutdown() throws Exception { // Prepare final StopWatch stopWatch = new StopWatch(); stopWatch.start(); GracefulShutdownHook testee = new GracefulShutdownHook(appContext); healthCheck.setReady(true); // Modify testee.run(); // Test asyncSpringContextShutdownDelayedAssert(); assertEquals(Status.DOWN, healthCheck.health().getStatus()); verify(appContext, times(1)).close(); stopWatch.stop(); assertTrue(stopWatch.getTotalTimeSeconds() >= SHUTDOWN_WAIT_S); }
@Around("performance()") public Object watchPerformance(ProceedingJoinPoint point){ System.out.println("The service start:"); StopWatch stopWatch = new StopWatch("performance"); stopWatch.start(point.getSignature().toString()); try { return point.proceed(); } catch (Throwable throwable) { throwable.printStackTrace(); }finally { stopWatch.stop(); StopWatch.TaskInfo[] taskInfo = stopWatch.getTaskInfo(); for (StopWatch.TaskInfo info : taskInfo) { System.out.println(info.getTaskName()); System.out.println(info.getTimeMillis()); } System.out.println("The "+point.getSignature().toString()+" run time:"+stopWatch.prettyPrint()); } return null; }
/** * Swagger Springfox configuration. */ @Bean public Docket swaggerSpringfoxDocket() { log.debug("Starting Swagger"); StopWatch watch = new StopWatch(); watch.start(); Docket swaggerSpringMvcPlugin = new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .genericModelSubstitutes(ResponseEntity.class) .select() .paths(regex(DEFAULT_INCLUDE_PATTERN)) // and by paths .build(); watch.stop(); log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis()); return swaggerSpringMvcPlugin; }
@Test public void testPrototypeCreationWithOverriddenResourcePropertiesIsFastEnough() { GenericApplicationContext ctx = new GenericApplicationContext(); AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx); ctx.refresh(); RootBeanDefinition rbd = new RootBeanDefinition(ResourceAnnotatedTestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); rbd.getPropertyValues().add("spouse", new RuntimeBeanReference("spouse")); ctx.registerBeanDefinition("test", rbd); ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); TestBean spouse = (TestBean) ctx.getBean("spouse"); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { TestBean tb = (TestBean) ctx.getBean("test"); assertSame(spouse, tb.getSpouse()); } sw.stop(); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000); }
@Test public void testPrototypeCreationWithAutowiredPropertiesIsFastEnough() { GenericApplicationContext ctx = new GenericApplicationContext(); AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx); ctx.refresh(); RootBeanDefinition rbd = new RootBeanDefinition(AutowiredAnnotatedTestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); ctx.registerBeanDefinition("test", rbd); ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); TestBean spouse = (TestBean) ctx.getBean("spouse"); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { TestBean tb = (TestBean) ctx.getBean("test"); assertSame(spouse, tb.getSpouse()); } sw.stop(); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000); }
@Test public void testPrototypeCreationWithOverriddenAutowiredPropertiesIsFastEnough() { GenericApplicationContext ctx = new GenericApplicationContext(); AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx); ctx.refresh(); RootBeanDefinition rbd = new RootBeanDefinition(AutowiredAnnotatedTestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); rbd.getPropertyValues().add("spouse", new RuntimeBeanReference("spouse")); ctx.registerBeanDefinition("test", rbd); ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); TestBean spouse = (TestBean) ctx.getBean("spouse"); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { TestBean tb = (TestBean) ctx.getBean("test"); assertSame(spouse, tb.getSpouse()); } sw.stop(); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 6000); }
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { StopWatch stopWatch = createStopWatchIfNecessary(request); String path = new UrlPathHelper().getPathWithinApplication(request); int status = HttpStatus.INTERNAL_SERVER_ERROR.value(); try { chain.doFilter(request, response); status = getStatus(response); } finally { if (!request.isAsyncStarted()) { stopWatch.stop(); request.removeAttribute(ATTRIBUTE_STOP_WATCH); recordMetrics(request, path, status, stopWatch.getTotalTimeMillis()); } } }
@Test public void testPerformance1() { Assume.group(TestGroup.PERFORMANCE); StopWatch watch = new StopWatch("integer->string conversionPerformance"); watch.start("convert 4,000,000 with conversion service"); for (int i = 0; i < 4000000; i++) { conversionService.convert(3, String.class); } watch.stop(); watch.start("convert 4,000,000 manually"); for (int i = 0; i < 4000000; i++) { new Integer(3).toString(); } watch.stop(); // System.out.println(watch.prettyPrint()); }
@Test public void testPerformance2() throws Exception { Assume.group(TestGroup.PERFORMANCE); StopWatch watch = new StopWatch("list<string> -> list<integer> conversionPerformance"); watch.start("convert 4,000,000 with conversion service"); List<String> source = new LinkedList<String>(); source.add("1"); source.add("2"); source.add("3"); TypeDescriptor td = new TypeDescriptor(getClass().getField("list")); for (int i = 0; i < 1000000; i++) { conversionService.convert(source, TypeDescriptor.forObject(source), td); } watch.stop(); watch.start("convert 4,000,000 manually"); for (int i = 0; i < 4000000; i++) { List<Integer> target = new ArrayList<Integer>(source.size()); for (String element : source) { target.add(Integer.valueOf(element)); } } watch.stop(); // System.out.println(watch.prettyPrint()); }
@Test public void testPerformance3() throws Exception { Assume.group(TestGroup.PERFORMANCE); StopWatch watch = new StopWatch("map<string, string> -> map<string, integer> conversionPerformance"); watch.start("convert 4,000,000 with conversion service"); Map<String, String> source = new HashMap<String, String>(); source.put("1", "1"); source.put("2", "2"); source.put("3", "3"); TypeDescriptor td = new TypeDescriptor(getClass().getField("map")); for (int i = 0; i < 1000000; i++) { conversionService.convert(source, TypeDescriptor.forObject(source), td); } watch.stop(); watch.start("convert 4,000,000 manually"); for (int i = 0; i < 4000000; i++) { Map<String, Integer> target = new HashMap<String, Integer>(source.size()); for (Map.Entry<String, String> entry : source.entrySet()) { target.put(entry.getKey(), Integer.valueOf(entry.getValue())); } } watch.stop(); // System.out.println(watch.prettyPrint()); }
@Test public void testGetValuePerformance() throws Exception { Assume.group(TestGroup.PERFORMANCE); Map<String, String> map = new HashMap<String, String>(); map.put("key", "value"); EvaluationContext context = new StandardEvaluationContext(map); ExpressionParser spelExpressionParser = new SpelExpressionParser(); Expression expr = spelExpressionParser.parseExpression("#root['key']"); StopWatch s = new StopWatch(); s.start(); for (int i = 0; i < 10000; i++) { expr.getValue(context); } s.stop(); assertThat(s.getTotalTimeMillis(), lessThan(200L)); }
/** * Swagger Springfox configuration. */ @Bean public Docket swaggerSpringfoxDocket() { log.debug("Starting Swagger"); StopWatch watch = new StopWatch(); watch.start(); Docket docket = new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .securitySchemes(newArrayList(new BasicAuth("test"))) .genericModelSubstitutes(ResponseEntity.class) .forCodeGeneration(true) .genericModelSubstitutes(ResponseEntity.class) .directModelSubstitute(org.joda.time.LocalDate.class, String.class) .directModelSubstitute(org.joda.time.LocalDateTime.class, Date.class) .directModelSubstitute(org.joda.time.DateTime.class, Date.class) .directModelSubstitute(java.time.LocalDate.class, String.class) .directModelSubstitute(java.time.ZonedDateTime.class, Date.class) .directModelSubstitute(java.time.LocalDateTime.class, Date.class) .select() .paths(regex(DEFAULT_INCLUDE_PATTERN)) .build(); watch.stop(); log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis()); return docket; }
@Test public void testPrototypeCreationIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); Assume.notLogging(factoryLog); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); lbf.registerBeanDefinition("test", rbd); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { lbf.getBean("test"); } sw.stop(); // System.out.println(sw.getTotalTimeMillis()); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 3000); }
@Test public void testPrototypeCreationWithDependencyCheckIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); Assume.notLogging(factoryLog); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(LifecycleBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); rbd.setDependencyCheck(RootBeanDefinition.DEPENDENCY_CHECK_OBJECTS); lbf.registerBeanDefinition("test", rbd); lbf.addBeanPostProcessor(new LifecycleBean.PostProcessor()); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { lbf.getBean("test"); } sw.stop(); // System.out.println(sw.getTotalTimeMillis()); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 3000); }
/** * @Test * public void testPrototypeCreationIsFastEnough2() throws Exception { * if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) { * // Skip this test: Trace logging blows the time limit. * return; * } * DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); * Method setBeanNameMethod = TestBean.class.getMethod("setBeanName", String.class); * Method setBeanFactoryMethod = TestBean.class.getMethod("setBeanFactory", BeanFactory.class); * StopWatch sw = new StopWatch(); * sw.start("prototype"); * for (int i = 0; i < 100000; i++) { * TestBean tb = TestBean.class.newInstance(); * setBeanNameMethod.invoke(tb, "test"); * setBeanFactoryMethod.invoke(tb, lbf); * } * sw.stop(); * // System.out.println(sw.getTotalTimeMillis()); * assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 500); * } */ @Test @Ignore // TODO re-enable when ConstructorResolver TODO sorted out public void testPrototypeCreationWithConstructorArgumentsIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); Assume.notLogging(factoryLog); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); rbd.getConstructorArgumentValues().addGenericArgumentValue("juergen"); rbd.getConstructorArgumentValues().addGenericArgumentValue("99"); lbf.registerBeanDefinition("test", rbd); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { TestBean tb = (TestBean) lbf.getBean("test"); assertEquals("juergen", tb.getName()); assertEquals(99, tb.getAge()); } sw.stop(); // System.out.println(sw.getTotalTimeMillis()); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 3000); }
@Test public void testPrototypeCreationWithPropertiesIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); Assume.notLogging(factoryLog); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); rbd.getPropertyValues().add("name", "juergen"); rbd.getPropertyValues().add("age", "99"); lbf.registerBeanDefinition("test", rbd); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { TestBean tb = (TestBean) lbf.getBean("test"); assertEquals("juergen", tb.getName()); assertEquals(99, tb.getAge()); } sw.stop(); // System.out.println(sw.getTotalTimeMillis()); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 3000); }
@Test public void testPrototypeCreationWithResolvedPropertiesIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); Assume.notLogging(factoryLog); DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE); rbd.getPropertyValues().add("spouse", new RuntimeBeanReference("spouse")); lbf.registerBeanDefinition("test", rbd); lbf.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class)); TestBean spouse = (TestBean) lbf.getBean("spouse"); StopWatch sw = new StopWatch(); sw.start("prototype"); for (int i = 0; i < 100000; i++) { TestBean tb = (TestBean) lbf.getBean("test"); assertSame(spouse, tb.getSpouse()); } sw.stop(); // System.out.println(sw.getTotalTimeMillis()); assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000); }
@Around("within(@org.springframework.stereotype.Repository *)") public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable { if (this.enabled) { StopWatch sw = new StopWatch(joinPoint.toShortString()); sw.start("invoke"); try { return joinPoint.proceed(); } finally { sw.stop(); synchronized (this) { this.callCount++; this.accumulatedCallTime += sw.getTotalTimeMillis(); } } } else { return joinPoint.proceed(); } }
@Around("allRepositories() || logAnnotation()") Object log(ProceedingJoinPoint joinPoint) throws Throwable { StopWatch stopWatch = new StopWatch(); stopWatch.start(); Object result = joinPoint.proceed(); stopWatch.stop(); log(joinPoint, stopWatch, result); return result; }
private void log(ProceedingJoinPoint joinPoint, StopWatch stopWatch, Object result) { String operationName = getOperationName(joinPoint); String timerString = createTimerString(stopWatch); String resultString = createResultString(result); if (!timerString.isEmpty() || !resultString.isEmpty()) { Logger logger = getLogger(joinPoint); logger.info("{}{} {}", operationName, timerString, resultString); } }
@Test public void getId32() throws Exception { int nThreads = 1000; int size = 1000; CyclicBarrier cyclicBarrier = new CyclicBarrier(nThreads + 1); StopWatch stopWatch = new StopWatch(); ExecutorService executorService = Executors.newFixedThreadPool(nThreads); stopWatch.start(); for (int i = 0; i < nThreads; i++) { int port = (8800 + (i % 10)); executorService.execute(new Runnable() { @Override public void run() { try { cyclicBarrier.await(); for (int j = 0; j < size; j++) { mockMvc.perform( get("/api/snowflake/get-id32?partnerKey=A" + port) .header("Content-Type", "application/json;charset=UTF-8")) .andExpect(status().isOk()) .andExpect(jsonPath("$.code").value(0)) .andExpect(jsonPath("$.data.id").isNumber()); } cyclicBarrier.await(); } catch (Exception e) { e.printStackTrace(); } } }); } cyclicBarrier.await(); cyclicBarrier.await(); stopWatch.stop(); System.out.println(stopWatch.prettyPrint()); executorService.shutdown(); }
@Test public void generateId() throws Exception { int nThreads = 200; int size = 10000; CyclicBarrier cyclicBarrier = new CyclicBarrier(nThreads + 1); StopWatch stopWatch = new StopWatch(); ExecutorService executorService = Executors.newFixedThreadPool(nThreads); stopWatch.start(); AtomicInteger atomicInteger = new AtomicInteger(); for (int i = 0; i < nThreads; i++) { executorService.submit(new Callable<Object>() { @Override public Object call() throws Exception { cyclicBarrier.await(); for (int j = 0; j < size; j++) { snowflakeService.generateId("account"); atomicInteger.incrementAndGet(); } cyclicBarrier.await(); return null; } }); } cyclicBarrier.await(); cyclicBarrier.await(); stopWatch.stop(); System.out.println(String.format("[%.2f][%d][%.2f]", stopWatch.getTotalTimeSeconds(), atomicInteger.get(), ((nThreads * size) / stopWatch.getTotalTimeSeconds()))); }
@Test public void generateId32() throws Exception { int nThreads = 200; int size = 10000; CyclicBarrier cyclicBarrier = new CyclicBarrier(nThreads + 1); StopWatch stopWatch = new StopWatch(); ExecutorService executorService = Executors.newFixedThreadPool(nThreads); stopWatch.start(); AtomicInteger atomicInteger = new AtomicInteger(); for (int i = 0; i < nThreads; i++) { executorService.submit(new Callable<Object>() { @Override public Object call() throws Exception { cyclicBarrier.await(); for (int j = 0; j < size; j++) { snowflakeService.generateId32("account"); atomicInteger.incrementAndGet(); } cyclicBarrier.await(); return null; } }); } cyclicBarrier.await(); cyclicBarrier.await(); stopWatch.stop(); System.out.println(String.format("[%.2f][%d][%.2f]", stopWatch.getTotalTimeSeconds(), atomicInteger.get(), ((nThreads * size) / stopWatch.getTotalTimeSeconds()))); }
/** * Swagger Springfox configuration. */ @Bean public Docket swaggerSpringfoxDocket(JHipsterProperties jHipsterProperties) { log.debug("Starting Swagger"); StopWatch watch = new StopWatch(); watch.start(); ApiInfo apiInfo = new ApiInfo( jHipsterProperties.getSwagger().getTitle(), jHipsterProperties.getSwagger().getDescription(), jHipsterProperties.getSwagger().getVersion(), jHipsterProperties.getSwagger().getTermsOfServiceUrl(), jHipsterProperties.getSwagger().getContact(), jHipsterProperties.getSwagger().getLicense(), jHipsterProperties.getSwagger().getLicenseUrl()); Docket docket = new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo) .genericModelSubstitutes(ResponseEntity.class) .forCodeGeneration(true) .genericModelSubstitutes(ResponseEntity.class) .directModelSubstitute(java.time.LocalDate.class, String.class) .directModelSubstitute(java.time.ZonedDateTime.class, Date.class) .directModelSubstitute(java.time.LocalDateTime.class, Date.class) .select() .paths(regex(DEFAULT_INCLUDE_PATTERN)) .build(); watch.stop(); log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis()); return docket; }
protected void initDb() throws LiquibaseException { StopWatch watch = new StopWatch(); watch.start(); super.afterPropertiesSet(); watch.stop(); log.debug("Started Liquibase in {} ms", watch.getTotalTimeMillis()); }
public T measure(ProceedingJoinPoint joinPoint) throws Throwable { final StopWatch stopWatch = new StopWatch(); stopWatch.start(); @SuppressWarnings("unchecked") final T result = (T) joinPoint.proceed(); stopWatch.stop(); final long duration = stopWatch.getLastTaskTimeMillis(); String log = this.buildLog(joinPoint, duration); logger.debug(log); submit(duration); return result; }
@Override public StopWatch submitted() { counterService.increment("tasks.submitted"); StopWatch stopWatch = new StopWatch(); stopWatch.setKeepTaskList(false); stopWatch.start("submit"); return stopWatch; }
@Override public StopWatch begin(StopWatch stopWatch) { stopWatch.stop(); counterService.increment("tasks.started"); gaugeService.submit("tasks.waitTimeMs", stopWatch.getLastTaskTimeMillis()); stopWatch.start("task"); return stopWatch; }
@Override public void end(StopWatch stopWatch, boolean succeeded) { stopWatch.stop(); if (succeeded) { counterService.increment("tasks.succeeded"); } else { counterService.increment("tasks.failed"); } gaugeService.submit("tasks.durationMs", stopWatch.getLastTaskTimeMillis()); }
@Override public StopWatch connected(SocketAddress remoteAddress, String remoteName) { counterService.increment("socket.numConnected"); StopWatch stopWatch = new StopWatch(); stopWatch.start(); return stopWatch; }
@Override public StopWatch requestBegin(StopWatch socketWatch, HttpServerRequest request) { counterService.increment("requests.count.total"); counterService.increment("requests.count." + request.rawMethod()); StopWatch stopWatch = new StopWatch(); stopWatch.start("request"); return stopWatch; }
@Override public StopWatch responsePushed(StopWatch socketWatch, HttpMethod method, String uri, HttpServerResponse response) { counterService.increment("responses.pushed"); StopWatch stopWatch = new StopWatch(); stopWatch.start(); return stopWatch; }
@Override public StopWatch upgrade(StopWatch requestWatch, ServerWebSocket serverWebSocket) { requestWatch.stop(); counterService.increment("requests.upgraded"); requestWatch.start("websocket"); return requestWatch; }
@Override public StopWatch connected(StopWatch socketMetric, ServerWebSocket serverWebSocket) { counterService.increment("websockets.connected"); StopWatch websocketWatch = new StopWatch(); websocketWatch.start("websocket"); return websocketWatch; }
@Override public StopWatch createEndpoint(String host, int port, int maxPoolSize) { counterService.increment("endpoints.active"); counterService.increment("endpoints.total"); StopWatch endpointWatch = new StopWatch(); endpointWatch.start(); return endpointWatch; }
@Override public StopWatch enqueueRequest(StopWatch endpointWatch) { counterService.increment("requests.queued.active"); counterService.increment("requests.queued.total"); StopWatch taskWatch = new StopWatch(); taskWatch.start(); return taskWatch; }
@Override public StopWatch requestBegin(StopWatch endpointWatch, StopWatch socketMetric, SocketAddress localAddress, SocketAddress remoteAddress, HttpClientRequest request) { counterService.increment("requests.sent"); StopWatch requestWatch = new StopWatch(); requestWatch.start(); return requestWatch; }