Interface MeterRegistry

All Superinterfaces:
Wrapper

public interface MeterRegistry extends Wrapper
Manages the look-up and registration of meters.
  • Method Details

    • meters

      List<Meter> meters()
      Returns all previously-registered meters.
      Returns:
      registered meters
    • meters

      Collection<Meter> meters(Predicate<Meter> filter)
      Returns previously-registered meters which match the specified Predicate.
      Parameters:
      filter - the predicate with which to evaluate each Meter
      Returns:
      meters which match the predicate
    • meters

      Iterable<Meter> meters(Iterable<String> scopeSelection)
      Returns previously-registered meters which match one of the specified scopes.
      Parameters:
      scopeSelection - scopes to match
      Returns:
      matching meters
    • scopes

      Iterable<String> scopes()
      Returns the scopes (if any) as represented by tags on meter IDs.
      Returns:
      scopes across all registered meters
    • close

      void close()
      Closes the meter registry.
    • isMeterEnabled

      boolean isMeterEnabled(String name, Map<String,String> tags, Optional<String> scope)
      Returns whether the specified meter is enabled or not, based on whether the meter registry as a whole is enabled and also whether the config settings for filtering include and exclude indicate the specific meter is enabled.
      Parameters:
      name - name of the meter to check
      tags - tags of the meter to check
      scope - scope, if present, of the meter to check
      Returns:
      true if the meter (and its meter registry) are enabled; false otherwise
    • clock

      Clock clock()
      Returns the default Clock in use by the registry.
      Returns:
      default clock
    • getOrCreate

      <B extends Meter.Builder<B, M>, M extends Meter> M getOrCreate(B builder)
      Locates a previously-registered meter using the name and tags in the provided builder or, if not found, registers a new one using the provided builder.
      Type Parameters:
      B - builder for the meter
      M - type of the meter
      Parameters:
      builder - builder to use in finding or creating a meter
      Returns:
      the previously-registered meter with the same name and tags or, if none, the newly-registered one
    • counter

      default Optional<Counter> counter(String name, Iterable<Tag> tags)
      Locates a previously-registered counter.
      Parameters:
      name - name to match
      tags - tags to match
      Returns:
      Optional of the previously-registered counter; empty if not found
    • summary

      default Optional<DistributionSummary> summary(String name, Iterable<Tag> tags)
      Locates a previously-registered distribution summary.
      Parameters:
      name - name to match
      tags - tags to match
      Returns:
      Optional of the previously-registered distribution summary; empty if not found
    • gauge

      default Optional<Gauge> gauge(String name, Iterable<Tag> tags)
      Locates a previously-registered gauge.
      Parameters:
      name - name to match
      tags - tags to match
      Returns:
      Optional of the previously-registered gauge; empty if not found
    • timer

      default Optional<Timer> timer(String name, Iterable<Tag> tags)
      Locates a previously-registered timer.
      Parameters:
      name - name to match
      tags - tags to match
      Returns:
      Optional of the previously-registered timer; empty if not found
    • meter

      <M extends Meter> Optional<M> meter(Class<M> mClass, String name, Iterable<Tag> tags)
      Locates a previously-registered meter of the specified type, matching the name and tags.

      The method throws an ClassCastException if a meter exists with the name and tags but is not type-compatible with the provided class.

      Type Parameters:
      M - type of the meter to find
      Parameters:
      mClass - type of the meter to find
      name - name to match
      tags - tags to match
      Returns:
      Optional of the previously-regsitered meter; empty if not found
    • remove

      Optional<Meter> remove(Meter meter)
      Removes a previously-registered meter.
      Parameters:
      meter - the meter to remove
      Returns:
      the removed meter; empty if the meter is not currently registered
    • remove

      Optional<Meter> remove(Meter.Id id)
      Removes a previously-registered meter with the specified ID.
      Parameters:
      id - ID for the meter to remove
      Returns:
      the removed meter; empty if the meter is not currently registered
    • remove

      Optional<Meter> remove(Meter.Id id, String scope)
      Removes a previously-registered meter with the specified ID and scope.
      Parameters:
      id - ID for the meter to remove
      scope - scope of the meter to remove
      Returns:
      the removed meter; empty if the specified ID and scope do not correspond to a registered meter
    • remove

      Optional<Meter> remove(String name, Iterable<Tag> tags)
      Removes a previously-registered meter with the specified name and tags.
      Parameters:
      name - meter name
      tags - tags for further identifying the meter
      Returns:
      the removed meter; empty if the specified name and tags do not correspond to a registered meter
    • remove

      Optional<Meter> remove(String name, Iterable<Tag> tags, String scope)
      Removes a previously-registered meter with the specified name, tags, and scope.
      Parameters:
      name - meter name
      tags - tags for further identifying the meter
      scope - scope within which to locate the meter
      Returns:
      the removed meter; empty if the specified name, tags, and scope do not correspond to a registered meter
    • isDeleted

      boolean isDeleted(Meter meter)
      Indicates if the meter has been deleted.
      Parameters:
      meter - Meter to check
      Returns:
      true if the meter has been deleted; false if it is still active
    • onMeterAdded

      MeterRegistry onMeterAdded(Consumer<Meter> onAddListener)
      Enroll a listener to be notified when a Meter is added.
      Parameters:
      onAddListener - listener to invoke upon each meter registration
      Returns:
      the meter registry
    • onMeterRemoved

      MeterRegistry onMeterRemoved(Consumer<Meter> onRemoveListener)
      Enroll a listener to be notified when a Meter is removed.
      Parameters:
      onRemoveListener - listener to invoke upon each meter removal
      Returns:
      the meter registry