@Test public void collect() throws Exception { try { final String spec = "http: final HttpURLConnection urlConnection = (HttpURLConnection) new URL(spec).openConnection(); urlConnection.getInputStream().close(); urlConnection.disconnect(); } catch (FileNotFoundException ignored) { } assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_requests_total"), is(1.0)); assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_requests_active"), is(0.0)); assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_requests_active_max"), is(1.0)); assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_request_time_max_seconds"), is(notNullValue())); assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_request_time_seconds_total"), is(notNullValue())); assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_dispatched_total"), is(1.0)); assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_dispatched_active"), is(0.0)); assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_dispatched_active_max"), is(greaterThan(0.0))); assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_dispatched_time_max"), is(notNullValue())); assertThat( CollectorRegistry.defaultRegistry.getSampleValue("jetty_dispatched_time_seconds_total"), is(notNullValue())); assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_async_requests_total"), is(0.0)); assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_async_requests_waiting"), is(0.0)); assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_async_requests_waiting_max"), is(0.0)); assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_async_dispatches_total"), is(0.0)); assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_expires_total"), is(0.0)); assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_responses_total", new String[]{"code"}, new String[]{"1xx"}), is(0.0)); assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_responses_total", new String[]{"code"}, new String[]{"2xx"}), is(0.0)); assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_responses_total", new String[]{"code"}, new String[]{"3xx"}), is(0.0)); assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_responses_total", new String[]{"code"}, new String[]{"4xx"}), is(1.0)); assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_responses_total", new String[]{"code"}, new String[]{"5xx"}), is(0.0)); assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_stats_seconds"), is(notNullValue())); assertThat(CollectorRegistry.defaultRegistry.getSampleValue("jetty_responses_bytes_total"), is(notNullValue())); }
@Override public List<MetricFamilySamples> collect() { return Arrays.asList( buildCounter("jetty_requests_total", "Number of requests", statisticsHandler.getRequests()), buildGauge("jetty_requests_active", "Number of requests currently active", statisticsHandler.getRequestsActive()), buildGauge("jetty_requests_active_max", "Maximum number of requests that have been active at once", statisticsHandler.getRequestsActiveMax()), buildGauge("jetty_request_time_max_seconds", "Maximum time spent handling requests", statisticsHandler.getRequestTimeMax() / 1000.0), buildCounter("jetty_request_time_seconds_total", "Total time spent in all request handling", statisticsHandler.getRequestTimeTotal() / 1000.0), buildCounter("jetty_dispatched_total", "Number of dispatches", statisticsHandler.getDispatched()), buildGauge("jetty_dispatched_active", "Number of dispatches currently active", statisticsHandler.getDispatchedActive()), buildGauge("jetty_dispatched_active_max", "Maximum number of active dispatches being handled", statisticsHandler.getDispatchedActiveMax()), buildGauge("jetty_dispatched_time_max", "Maximum time spent in dispatch handling", statisticsHandler.getDispatchedTimeMax()), buildCounter("jetty_dispatched_time_seconds_total", "Total time spent in dispatch handling", statisticsHandler.getDispatchedTimeTotal() / 1000.0), buildCounter("jetty_async_requests_total", "Total number of async requests", statisticsHandler.getAsyncRequests()), buildGauge("jetty_async_requests_waiting", "Currently waiting async requests", statisticsHandler.getAsyncRequestsWaiting()), buildGauge("jetty_async_requests_waiting_max", "Maximum number of waiting async requests", statisticsHandler.getAsyncRequestsWaitingMax()), buildCounter("jetty_async_dispatches_total", "Number of requested that have been asynchronously dispatched", statisticsHandler.getAsyncDispatches()), buildCounter("jetty_expires_total", "Number of async requests requests that have expired", statisticsHandler.getExpires()), buildStatusCounter(), buildGauge("jetty_stats_seconds", "Time in seconds stats have been collected for", statisticsHandler.getStatsOnMs() / 1000.0), buildCounter("jetty_responses_bytes_total", "Total number of bytes across all responses", statisticsHandler.getResponsesBytesTotal()) ); }
JettyStatisticsCollector extends Collector { @Override public List<MetricFamilySamples> collect() { return Arrays.asList( buildCounter("jetty_requests_total", "Number of requests", statisticsHandler.getRequests()), buildGauge("jetty_requests_active", "Number of requests currently active", statisticsHandler.getRequestsActive()), buildGauge("jetty_requests_active_max", "Maximum number of requests that have been active at once", statisticsHandler.getRequestsActiveMax()), buildGauge("jetty_request_time_max_seconds", "Maximum time spent handling requests", statisticsHandler.getRequestTimeMax() / 1000.0), buildCounter("jetty_request_time_seconds_total", "Total time spent in all request handling", statisticsHandler.getRequestTimeTotal() / 1000.0), buildCounter("jetty_dispatched_total", "Number of dispatches", statisticsHandler.getDispatched()), buildGauge("jetty_dispatched_active", "Number of dispatches currently active", statisticsHandler.getDispatchedActive()), buildGauge("jetty_dispatched_active_max", "Maximum number of active dispatches being handled", statisticsHandler.getDispatchedActiveMax()), buildGauge("jetty_dispatched_time_max", "Maximum time spent in dispatch handling", statisticsHandler.getDispatchedTimeMax()), buildCounter("jetty_dispatched_time_seconds_total", "Total time spent in dispatch handling", statisticsHandler.getDispatchedTimeTotal() / 1000.0), buildCounter("jetty_async_requests_total", "Total number of async requests", statisticsHandler.getAsyncRequests()), buildGauge("jetty_async_requests_waiting", "Currently waiting async requests", statisticsHandler.getAsyncRequestsWaiting()), buildGauge("jetty_async_requests_waiting_max", "Maximum number of waiting async requests", statisticsHandler.getAsyncRequestsWaitingMax()), buildCounter("jetty_async_dispatches_total", "Number of requested that have been asynchronously dispatched", statisticsHandler.getAsyncDispatches()), buildCounter("jetty_expires_total", "Number of async requests requests that have expired", statisticsHandler.getExpires()), buildStatusCounter(), buildGauge("jetty_stats_seconds", "Time in seconds stats have been collected for", statisticsHandler.getStatsOnMs() / 1000.0), buildCounter("jetty_responses_bytes_total", "Total number of bytes across all responses", statisticsHandler.getResponsesBytesTotal()) ); } }
JettyStatisticsCollector extends Collector { @Override public List<MetricFamilySamples> collect() { return Arrays.asList( buildCounter("jetty_requests_total", "Number of requests", statisticsHandler.getRequests()), buildGauge("jetty_requests_active", "Number of requests currently active", statisticsHandler.getRequestsActive()), buildGauge("jetty_requests_active_max", "Maximum number of requests that have been active at once", statisticsHandler.getRequestsActiveMax()), buildGauge("jetty_request_time_max_seconds", "Maximum time spent handling requests", statisticsHandler.getRequestTimeMax() / 1000.0), buildCounter("jetty_request_time_seconds_total", "Total time spent in all request handling", statisticsHandler.getRequestTimeTotal() / 1000.0), buildCounter("jetty_dispatched_total", "Number of dispatches", statisticsHandler.getDispatched()), buildGauge("jetty_dispatched_active", "Number of dispatches currently active", statisticsHandler.getDispatchedActive()), buildGauge("jetty_dispatched_active_max", "Maximum number of active dispatches being handled", statisticsHandler.getDispatchedActiveMax()), buildGauge("jetty_dispatched_time_max", "Maximum time spent in dispatch handling", statisticsHandler.getDispatchedTimeMax()), buildCounter("jetty_dispatched_time_seconds_total", "Total time spent in dispatch handling", statisticsHandler.getDispatchedTimeTotal() / 1000.0), buildCounter("jetty_async_requests_total", "Total number of async requests", statisticsHandler.getAsyncRequests()), buildGauge("jetty_async_requests_waiting", "Currently waiting async requests", statisticsHandler.getAsyncRequestsWaiting()), buildGauge("jetty_async_requests_waiting_max", "Maximum number of waiting async requests", statisticsHandler.getAsyncRequestsWaitingMax()), buildCounter("jetty_async_dispatches_total", "Number of requested that have been asynchronously dispatched", statisticsHandler.getAsyncDispatches()), buildCounter("jetty_expires_total", "Number of async requests requests that have expired", statisticsHandler.getExpires()), buildStatusCounter(), buildGauge("jetty_stats_seconds", "Time in seconds stats have been collected for", statisticsHandler.getStatsOnMs() / 1000.0), buildCounter("jetty_responses_bytes_total", "Total number of bytes across all responses", statisticsHandler.getResponsesBytesTotal()) ); } JettyStatisticsCollector(StatisticsHandler statisticsHandler); }
JettyStatisticsCollector extends Collector { @Override public List<MetricFamilySamples> collect() { return Arrays.asList( buildCounter("jetty_requests_total", "Number of requests", statisticsHandler.getRequests()), buildGauge("jetty_requests_active", "Number of requests currently active", statisticsHandler.getRequestsActive()), buildGauge("jetty_requests_active_max", "Maximum number of requests that have been active at once", statisticsHandler.getRequestsActiveMax()), buildGauge("jetty_request_time_max_seconds", "Maximum time spent handling requests", statisticsHandler.getRequestTimeMax() / 1000.0), buildCounter("jetty_request_time_seconds_total", "Total time spent in all request handling", statisticsHandler.getRequestTimeTotal() / 1000.0), buildCounter("jetty_dispatched_total", "Number of dispatches", statisticsHandler.getDispatched()), buildGauge("jetty_dispatched_active", "Number of dispatches currently active", statisticsHandler.getDispatchedActive()), buildGauge("jetty_dispatched_active_max", "Maximum number of active dispatches being handled", statisticsHandler.getDispatchedActiveMax()), buildGauge("jetty_dispatched_time_max", "Maximum time spent in dispatch handling", statisticsHandler.getDispatchedTimeMax()), buildCounter("jetty_dispatched_time_seconds_total", "Total time spent in dispatch handling", statisticsHandler.getDispatchedTimeTotal() / 1000.0), buildCounter("jetty_async_requests_total", "Total number of async requests", statisticsHandler.getAsyncRequests()), buildGauge("jetty_async_requests_waiting", "Currently waiting async requests", statisticsHandler.getAsyncRequestsWaiting()), buildGauge("jetty_async_requests_waiting_max", "Maximum number of waiting async requests", statisticsHandler.getAsyncRequestsWaitingMax()), buildCounter("jetty_async_dispatches_total", "Number of requested that have been asynchronously dispatched", statisticsHandler.getAsyncDispatches()), buildCounter("jetty_expires_total", "Number of async requests requests that have expired", statisticsHandler.getExpires()), buildStatusCounter(), buildGauge("jetty_stats_seconds", "Time in seconds stats have been collected for", statisticsHandler.getStatsOnMs() / 1000.0), buildCounter("jetty_responses_bytes_total", "Total number of bytes across all responses", statisticsHandler.getResponsesBytesTotal()) ); } JettyStatisticsCollector(StatisticsHandler statisticsHandler); @Override List<MetricFamilySamples> collect(); }
JettyStatisticsCollector extends Collector { @Override public List<MetricFamilySamples> collect() { return Arrays.asList( buildCounter("jetty_requests_total", "Number of requests", statisticsHandler.getRequests()), buildGauge("jetty_requests_active", "Number of requests currently active", statisticsHandler.getRequestsActive()), buildGauge("jetty_requests_active_max", "Maximum number of requests that have been active at once", statisticsHandler.getRequestsActiveMax()), buildGauge("jetty_request_time_max_seconds", "Maximum time spent handling requests", statisticsHandler.getRequestTimeMax() / 1000.0), buildCounter("jetty_request_time_seconds_total", "Total time spent in all request handling", statisticsHandler.getRequestTimeTotal() / 1000.0), buildCounter("jetty_dispatched_total", "Number of dispatches", statisticsHandler.getDispatched()), buildGauge("jetty_dispatched_active", "Number of dispatches currently active", statisticsHandler.getDispatchedActive()), buildGauge("jetty_dispatched_active_max", "Maximum number of active dispatches being handled", statisticsHandler.getDispatchedActiveMax()), buildGauge("jetty_dispatched_time_max", "Maximum time spent in dispatch handling", statisticsHandler.getDispatchedTimeMax()), buildCounter("jetty_dispatched_time_seconds_total", "Total time spent in dispatch handling", statisticsHandler.getDispatchedTimeTotal() / 1000.0), buildCounter("jetty_async_requests_total", "Total number of async requests", statisticsHandler.getAsyncRequests()), buildGauge("jetty_async_requests_waiting", "Currently waiting async requests", statisticsHandler.getAsyncRequestsWaiting()), buildGauge("jetty_async_requests_waiting_max", "Maximum number of waiting async requests", statisticsHandler.getAsyncRequestsWaitingMax()), buildCounter("jetty_async_dispatches_total", "Number of requested that have been asynchronously dispatched", statisticsHandler.getAsyncDispatches()), buildCounter("jetty_expires_total", "Number of async requests requests that have expired", statisticsHandler.getExpires()), buildStatusCounter(), buildGauge("jetty_stats_seconds", "Time in seconds stats have been collected for", statisticsHandler.getStatsOnMs() / 1000.0), buildCounter("jetty_responses_bytes_total", "Total number of bytes across all responses", statisticsHandler.getResponsesBytesTotal()) ); } JettyStatisticsCollector(StatisticsHandler statisticsHandler); @Override List<MetricFamilySamples> collect();  }