Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.
/ metrics-schema Public archive

Define your Metrics in a JSON file so you can keep track of what you're expecting and what's actually going out.

License

Notifications You must be signed in to change notification settings

jahed/metrics-schema

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Metrics Schema

Travis Maven Central Javadocs

Define your Metrics in a JSON file so you can keep track of what you're expecting and what's actually going out.

Installation

Maven

Add this dependency to your pom.xml. Update the version to the one you want.

<dependency>
    <groupId>io.jahed</groupId>
    <artifactId>metrics-schema</artifactId>
    <version>1.0</version>
</dependency>

Usage

Create a JSON to define your schema.

{
  "application": {
    "metric-meter": "com.codahale.metrics.Meter",
    "metric-timer": "com.codahale.metrics.Timer"
  }
}

Here we're saying that we expect 2 metrics to be used. A Meter called application.metric-meter and a Timer called application.metric-timer.

The Metric must be a full canonical name of a class which implements com.codahale.metrics.Metric.

Once you've defined your schema, you can use it to validate your MetricRegistry.

MetricRegistry registry = new MetricRegistry();
MetricSchema schema = MetricSchemaFactory.createFromResource("/resource/path/to/your/schema.json");
new MetricRegistryValidator(schema, registry)
    .onSuccess(success -> logger.debug(success.getMessage()))
    .onFailure(failure -> logger.warn(failure.getMessage()))
    .startValidating();

If you ever want to stop validating, you can do the following:

validator.stopValidating();

License

See LICENSE file.

About

Define your Metrics in a JSON file so you can keep track of what you're expecting and what's actually going out.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages