Giter Club home page Giter Club logo

lightweight-java-metrics's Introduction

MOVED

This project has moved to javadelight/delight-metrics and is now part of the Java Delight Framework.

Build Status

Lightweight Java Metrics

The Lightweight Java Metrics library provides a simple way to report metrics for Java applications based on the Dropwizard Metrics Project and the Async Properties library.

Why Other metric frameworks are often complex and feature-rich. This framework is composed of a small set of core classes; thus, it is easy to understand and plug into various environments.

Usage

Keeping a count

For instance: How many users are logged into the system concurrently?

PropertyNode m = Metrics.create();

m.record(Metrics.increment("users"));
m.record(Metrics.increment("users"));
m.record(Metrics.decrement("users"));

m.print();

m.stop().get();

Should result in the output:

{
    'users': '1'
}

Measure Operations per Second

For instance: How many times per second is a service called?

final PropertyNode m = Metrics.create();

m.record(Metrics.happened("serviceCalled"));
m.record(Metrics.happened("serviceCalled"));
m.record(Metrics.happened("serviceCalled"));

Thread.sleep(10000);

m.print();

m.stop().get();

Should result in the output:

{
    'serviceCalled': {
        'Total Events': '3',
        'Events per Second (last Minute)': '0.552026648777594',
        'Events per Second (last 5 Minutes)': '0.5900828722929705',
        'Events per Second (last 15 Minutes)': '0.5966759088029381'
    }
}

Calculate Statistics

For instance: How large are received requests in average?

final PropertyNode m = Metrics.create();

m.record(Metrics.value("requestSize", 300));
m.record(Metrics.value("requestSize", 100));
m.record(Metrics.value("requestSize", 200));

m.print();

m.stop().get();

Should result in.

{
    'requestSize': {
        'Mean': '200.0',
        'Standard Deviation': '100.0',
        'Max': '300',
        'Min': '100',
        '75% of Values Smaller Than': '300.0',
        '95% of Values Smaller Than': '300.0',
        '98% of Values Smaller Than': '300.0'
    }
}

Reporting

Metrics are turned into easily human-readable strings. What you do with these is up to.

Retrieve Single Metric as String

PropertyNode m = ...

String metric = m.retrieve("metricId").get().toString()

Retrieve All Metrics as String

PropertyNode m = ...

String metrics = m.render().get();

Maven Dependency

<dependency>
    <groupId>de.mxro.metrics</groupId>
	<artifactId>metrics</artifactId>
	<version>[latest version]</version>
</dependency>

Find latest version here.

Add repository if required:

<repositories>
	<repository>
		<id>Appjangle Releases</id>
		<url>http://maven.appjangle.com/appjangle/releases</url>
	</repository>
</repositories>

Compatibility

This project is compatible with the following environments:

  • Java 1.6+
  • GWT 2.5.0+
  • Android (any)
  • OSGi (any)

Performance and Multi-Threading

A significant part of the internal implementation in the library is based on the Dropwizard Metrics Project. Thus, some of the performance characteristics are inherited from this project.

However, this project uses a different approach to multi-threading. While in the Dropwizard Metrics Project every metric and operation is synchronized independently, the Lightweight Java Metrics project synchronizes all operations in one place (see SynchronizedMetricsNode.java).

Thus, more operations can be performed within the scope of one thread. This might lead to better performance as compared to the Dropwizard Metrics Project in some case and to worse performance in others.

Further Resources

License

Apache 2.0

lightweight-java-metrics's People

Contributors

mxro avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.