@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)); }
@Test public void queriesIntervalCounterDec() { catcher.requestComplete(new RemoveQuery( RequestData.builder() .correlationId(10l) .type("test") .build())); assertThat(registry.getGauges().size(), equalTo(2)); assertThat(registry.getGauges().get(this.config.getPrefix() + ".requests-completed-interval-count").getValue(), equalTo(1l)); assertThat(registry.getGauges().get(this.config.getPrefix() + ".requests-completed-test-interval-count").getValue(), equalTo(1l)); }
@Test public void queriesCounterDec() { catcher.requestComplete(new RemoveQuery( RequestData.builder() .correlationId(10l) .type("test") .build())); assertThat(registry.counter(this.config.getPrefix() + ".requests-active-test-count") .getCount(), equalTo(0l)); }
/** * 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 end of a query identified by the provided correlationId * * @param query - Query data * @param correlationId - Identifier * @param label - allows queries to be grouped by type * @return RemoveLabelledQuery event to pass to the Events systems EventBus */ public static <T> RemoveLabelledQuery<T> finish(T query, long correlationId, String label) { return new RemoveLabelledQuery<>( RequestData.builder() .query(query) .correlationId(correlationId) .type(label) .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 label - allows queries to be grouped by label * @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> AddLabelledQuery<T> start(T query, long correlationId, String label, Object additionalData) { return new AddLabelledQuery( RequestData.builder() .query(query) .correlationId(correlationId) .type(label) .additionalData(additionalData) .build()); }
/** * Marks the end of a query identified by the provided correlationId * * @param query - Query data * @param correlationId - Identifier * @param type - allows queries to be grouped by type * @return */ public static <T> RemoveQuery<T> finish(T query, long correlationId, String type) { return new RemoveQuery<>( RequestData.builder() .query(query) .correlationId(correlationId) .type(type) .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()); }
/** * 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 label - allows queries to be grouped by label * @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> AddLabelledQuery<T> start(T query, long correlationId, String label, Object additionalData) { return new AddLabelledQuery( RequestData.builder() .query(query) .correlationId(correlationId) .type(label) .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)); }
/** * Marks the end of a query identified by the provided correlationId * * @param query - Query data * @param correlationId - Identifier * @param label - allows queries to be grouped by type * @return RemoveLabelledQuery event to pass to the Events systems EventBus */ public static <T> RemoveLabelledQuery<T> finish(T query, long correlationId, String label) { return new RemoveLabelledQuery<>( RequestData.builder() .query(query) .correlationId(correlationId) .type(label) .build()); } }
/** * Marks the end of a query identified by the provided correlationId * * @param query - Query data * @param correlationId - Identifier * @param type - allows queries to be grouped by type * @return */ public static <T> RemoveQuery<T> finish(T query, long correlationId, String type) { return new RemoveQuery<>( RequestData.builder() .query(query) .correlationId(correlationId) .type(type) .build()); }
@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)); }
@Test public void queriesEndMeterInc() { catcher.requestComplete(new RemoveQuery( RequestData.builder() .correlationId(10l) .type("test") .build())); assertThat(registry.meter(this.config.getPrefix() + ".request-end-test") .getMeanRate(), equalTo(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 queriesEndMeterInc() { catcher.requestComplete(new RemoveQuery( RequestData.builder() .correlationId(10l) .type("test") .build())); assertThat(registry.meter(this.config.getPrefix() + ".request-end-test") .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 queriesCounterDec() { catcher.requestComplete(new RemoveQuery( RequestData.builder() .correlationId(10l) .type("test") .build())); assertThat(registry.counter(this.config.getPrefix() + ".requests-active-test-count") .getCount(), equalTo(-1l)); }
@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)); }