@Test public void queriesCounterInc() { catcher.requestStart(new AddQuery( RequestData.builder() .correlationId(10l) .type("test") .build())); assertThat(registry.counter(this.config.getPrefix() + ".requests-active-test-count") .getCount(), equalTo(1l)); }
@Subscribe public void requestStart(AddQuery<T> data) { registry.meter(prefix + ".requests-started") .mark(); registry.counter(prefix + ".requests-started-count") .inc(); ((InstantGauge) registry.gauge(prefix + ".requests-started-interval-count", () -> new InstantGauge())).increment(); if (this.configuration.isQueriesByType()) { RequestData<T> rd = data.getData(); registry.meter(queryStartName(rd) + "-meter") .mark(); queries.start(rd.getCorrelationId(), timer(queryEndName(rd) + "-timer").time()); registry.counter(prefix + ".requests-active-" + rd.getType() + "-count") .inc(); ((InstantGauge) registry.gauge(prefix + ".requests-started-" + rd.getType() + "-interval-count", () -> new InstantGauge())).increment(); } }
/** * Marks the start of a query identified by the provided correlationId, with additional query type and data parameters * * @param query - Query data * @param correlationId - Identifier * @param type - allows queries to be grouped by type * @param additionalData - Any additional info about the request to be rendered in the JSON view / rest endpoint * @return Start event to pass to the Events systems EventBus */ public static <T> AddQuery<T> start(T query, long correlationId, String type, Object additionalData) { return new AddQuery( RequestData.builder() .query(query) .correlationId(correlationId) .type(type) .additionalData(additionalData) .build()); }
/** * Marks the start of a query identified by the provided correlationId, with additional query type and data parameters * * @param query - Query data * @param correlationId - Identifier * @param type - allows queries to be grouped by type * @param additionalData - Any additional info about the request to be rendered in the JSON view / rest endpoint * @return Start event to pass to the Events systems EventBus */ public static <T> AddQuery<T> start(T query, long correlationId, String type, Object additionalData) { return new AddQuery( RequestData.builder() .query(query) .correlationId(correlationId) .type(type) .additionalData(additionalData) .build()); }
@Test public void queriesTimer() { catcher.requestStart(new AddQuery( RequestData.builder() .correlationId(10l) .type("test") .build())); catcher.requestComplete(new RemoveQuery( RequestData.builder() .correlationId(10l) .type("test") .build())); assertThat(registry.timer(this.config.getPrefix() + ".request-end-test-timer") .getMeanRate(), equalTo(0.0)); }
@Test public void queriesTimer() { catcher.requestStart(new AddQuery( RequestData.builder() .correlationId(10l) .type("test") .build())); catcher.requestComplete(new RemoveQuery( RequestData.builder() .correlationId(10l) .type("test") .build())); assertThat(registry.timer(this.config.getPrefix() + ".request-end-test-timer") .getMeanRate(), greaterThan(0.0)); }
@Test public void queriesCounterInc() { catcher.requestStart(new AddQuery( RequestData.builder() .correlationId(10l) .type("test") .build())); assertThat(registry.counter(this.config.getPrefix() + ".requests-active-test-count") .getCount(), equalTo(0l)); }
@Test public void queriesStartMeterInc() { catcher.requestStart(new AddQuery( RequestData.builder() .correlationId(10l) .type("test") .build())); assertThat(registry.meter(this.config.getPrefix() + ".request-start-test-meter") .getMeanRate(), greaterThan(0.0)); }
@Test public void queriesStartMeterInc() { catcher.requestStart(new AddQuery( RequestData.builder() .correlationId(10l) .type("test") .build())); assertThat(registry.meter(this.config.getPrefix() + ".request-start-test") .getMeanRate(), equalTo(0.0)); }
@Test public void queriesIntervalCounterInc() { catcher.requestStart(new AddQuery( RequestData.builder() .correlationId(10l) .type("test") .build())); assertThat(registry.getGauges().size(), equalTo(2)); assertThat(registry.getGauges().get(this.config.getPrefix() + ".requests-started-interval-count").getValue(), equalTo(1l)); assertThat(registry.getGauges().get(this.config.getPrefix() + ".requests-started-test-interval-count").getValue(), equalTo(1l)); }