@Test public void createRemoveLabelledQuery() { RemoveLabelledQuery<String> userQuery = LabelledEvents.finish(query, corrId, label); RequestData<String> rd = userQuery.getData(); assertThat(rd.getQuery(), is(query)); assertThat(rd.getType(), is(label)); assertThat(rd.getCorrelationId(), is(corrId)); } }
/** * 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 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()); } }
@Subscribe public void requestComplete(RemoveLabelledQuery<T> data) { if (this.configuration.isQueriesByType()) { RequestData<T> rd = data.getData(); ((InstantGauge) registry.gauge(prefix + ".requests-completed-" + rd.getType() + "-interval-count", () -> new InstantGauge())) .increment(); } }