Class Metrics

java.lang.Object
hudson.Plugin
jenkins.metrics.api.Metrics
All Implemented Interfaces:
Saveable, Loadable, org.kohsuke.stapler.StaplerProxy

public class Metrics extends Plugin
Entry point for all things metrics.
  • Field Details

    • HEALTH_CHECK_INTERVAL_MINS

      public static final int HEALTH_CHECK_INTERVAL_MINS
      The frequency with which to run health checks.
    • PERMISSIONS

      public static final PermissionGroup PERMISSIONS
      Permission group for Metrics related permissions.
    • VIEW

      public static final Permission VIEW
      Permission to view the Codahale Metrics Operations Servlet.
    • THREAD_DUMP

      public static final Permission THREAD_DUMP
      Permission to get a thread dump from the Codahale Metrics Operations Servlet.
    • HEALTH_CHECK

      public static final Permission HEALTH_CHECK
      Permission to run healthchecks from the Codahale Metrics Operations Servlet.
    • JMX_DOMAIN

      public static final String JMX_DOMAIN
      JMX domain
      See Also:
  • Constructor Details

    • Metrics

      public Metrics()
  • Method Details

    • healthCheckRegistry

      @NonNull public static com.codahale.metrics.health.HealthCheckRegistry healthCheckRegistry()
      Returns the HealthCheckRegistry for the current Jenkins.
      Returns:
      the HealthCheckRegistry for the current Jenkins
      Throws:
      AssertionError - if there is no Jenkins or Metrics or HealthCheckRegistry
    • getHealthCheckResults

      @NonNull public static SortedMap<String,com.codahale.metrics.health.HealthCheck.Result> getHealthCheckResults()
      Get the last health check results
      Returns:
      a map with health check name -> health check result
    • getHealthCheckData

      @CheckForNull public static Metrics.HealthCheckData getHealthCheckData()
      Get the current health check data.
      Returns:
      the current health check data or null if the health checks have not run yet.
    • metricRegistry

      @NonNull public static com.codahale.metrics.MetricRegistry metricRegistry()
      Returns the MetricRegistry for the current Jenkins.
      Returns:
      the MetricRegistry for the current Jenkins
      Throws:
      AssertionError - if there is no Jenkins or Metrics or MetricRegistry
    • checkAccessKey

      public static void checkAccessKey(@CheckForNull String accessKey)
      Checks an access key.
      Parameters:
      accessKey - the access key.
    • checkAccessKeyPing

      public static void checkAccessKeyPing(@CheckForNull String accessKey)
      Checks an access key.
      Parameters:
      accessKey - the access key.
    • checkAccessKeyThreadDump

      public static void checkAccessKeyThreadDump(@CheckForNull String accessKey)
      Checks an access key.
      Parameters:
      accessKey - the access key.
    • checkAccessKeyHealthCheck

      public static void checkAccessKeyHealthCheck(@CheckForNull String accessKey)
      Checks an access key.
      Parameters:
      accessKey - the access key.
    • checkAccessKeyMetrics

      public static void checkAccessKeyMetrics(@CheckForNull String accessKey)
      Checks an access key.
      Parameters:
      accessKey - the access key.
    • cors

      public static org.kohsuke.stapler.HttpResponse cors(@CheckForNull String accessKey, org.kohsuke.stapler.HttpResponse resp)
    • reindexAccessKeys

      public static void reindexAccessKeys()
      Re-indexes all the access keys from the different MetricsAccessKey.Provider extensions.
    • start

      public void start() throws Exception
      Overrides:
      start in class Plugin
      Throws:
      Exception
    • afterExtensionsAugmented

      @Initializer(after=EXTENSIONS_AUGMENTED, before=JOB_LOADED) public static void afterExtensionsAugmented()
      Initializes all the metrics providers and health check providers. Ideally we would like this to be called earlier but there are occasional deadlocks that can arise if we attempt to enumerate the extensions prior to InitMilestone.EXTENSIONS_AUGMENTED so we had to move this functionality out of Plugin.postInitialize()
    • stop

      public void stop() throws Exception
      Overrides:
      stop in class Plugin
      Throws:
      Exception