Class HTTPReporter

java.lang.Object
com.codahale.metrics.ScheduledReporter
net.shibboleth.idp.metrics.impl.HTTPReporter
All Implemented Interfaces:
com.codahale.metrics.Reporter, Closeable, AutoCloseable, Component, InitializableComponent

public class HTTPReporter
extends com.codahale.metrics.ScheduledReporter
implements InitializableComponent
A metrics reporter that runs at scheduled times and posts a JSON feed of metrics to a designated endpoint.
  • Field Details

    • DEFAULT_DT_FORMAT

      @Nonnull @NotEmpty public static final String DEFAULT_DT_FORMAT
      Default date/time format string.
      See Also:
      Constant Field Values
    • log

      @Nonnull private final org.slf4j.Logger log
      Class logger.
    • metricRegistry

      @Nonnull private final com.codahale.metrics.MetricRegistry metricRegistry
      Registry of metrics.
    • metricFilter

      @Nonnull private final com.codahale.metrics.MetricFilter metricFilter
      Filter to apply.
    • rateUnit

      @Nonnull private final TimeUnit rateUnit
      Rate unit.
    • durationUnit

      @Nonnull private final TimeUnit durationUnit
      Duration unit.
    • httpClient

      @NonnullAfterInit private org.apache.http.client.HttpClient httpClient
      HTTP Client used to post the data.
    • collectorURL

      @NonnullAfterInit @NotEmpty private String collectorURL
      URL to the collection point.
    • httpClientSecurityParameters

      @Nullable private HttpClientSecurityParameters httpClientSecurityParameters
      HTTP client security parameters.
    • jsonMapper

      @NonnullAfterInit private com.fasterxml.jackson.databind.ObjectMapper jsonMapper
      JSON object mapper to produce output.
    • dateTimeFormat

      @Nullable private String dateTimeFormat
      Formatting string for DateFormat fields.
    • isInitialized

      private boolean isInitialized
      Whether this component has been initialized.
  • Constructor Details

  • Method Details

    • setHttpClient

      public void setHttpClient​(@Nonnull org.apache.http.client.HttpClient client)
      Set the HttpClient to use.
      Parameters:
      client - client to use
    • setCollectorURL

      public void setCollectorURL​(@Nonnull @NotEmpty String url)
      Set the collection point to supply the data to.
      Parameters:
      url - URL to post data to
    • setHttpClientSecurityParameters

      public void setHttpClientSecurityParameters​(@Nullable HttpClientSecurityParameters params)
      Set the optional client security parameters.
      Parameters:
      params - the new client security parameters
    • setDateTimeFormat

      public void setDateTimeFormat​(@Nullable @NotEmpty String format)
      Set the DateFormat formatting string to apply when writing DateFormat-valued fields.
      Parameters:
      format - formatting string
    • isInitialized

      public boolean isInitialized()
      Specified by:
      isInitialized in interface InitializableComponent
    • initialize

      public void initialize() throws ComponentInitializationException
      Specified by:
      initialize in interface InitializableComponent
      Throws:
      ComponentInitializationException
    • stop

      public void stop()
      Overrides:
      stop in class com.codahale.metrics.ScheduledReporter
    • report

      public void report()
      Overrides:
      report in class com.codahale.metrics.ScheduledReporter
    • report

      public void report​(SortedMap<String,​com.codahale.metrics.Gauge> gauges, SortedMap<String,​com.codahale.metrics.Counter> counters, SortedMap<String,​com.codahale.metrics.Histogram> histograms, SortedMap<String,​com.codahale.metrics.Meter> meters, SortedMap<String,​com.codahale.metrics.Timer> timers)
      Specified by:
      report in class com.codahale.metrics.ScheduledReporter
    • buildHttpContext

      @Nonnull private org.apache.http.client.protocol.HttpClientContext buildHttpContext​(@Nonnull org.apache.http.client.methods.HttpUriRequest request)
      Build the HttpClientContext instance to be used by the HttpClient.
      Parameters:
      request - the HTTP client request
      Returns:
      the client context instance