Simple Metrics

Simple Metrics for Java for handling and publishing application metrics.

License

License

ISC License
Categories

Categories

Metrics Application Testing & Monitoring Monitoring
GroupId

GroupId

com.j256.simplemetrics
ArtifactId

ArtifactId

simplemetrics
Last Version

Last Version

1.9
Release Date

Release Date

Type

Type

jar
Description

Description

Simple Metrics
Simple Metrics for Java for handling and publishing application metrics.
Project URL

Project URL

http://256stuff.com/sources/simplemetrics/
Source Code Management

Source Code Management

https://github.com/j256/simplemetrics

Download simplemetrics

How to add to project

<!-- https://jarcasting.com/artifacts/com.j256.simplemetrics/simplemetrics/ -->
<dependency>
    <groupId>com.j256.simplemetrics</groupId>
    <artifactId>simplemetrics</artifactId>
    <version>1.9</version>
</dependency>
// https://jarcasting.com/artifacts/com.j256.simplemetrics/simplemetrics/
implementation 'com.j256.simplemetrics:simplemetrics:1.9'
// https://jarcasting.com/artifacts/com.j256.simplemetrics/simplemetrics/
implementation ("com.j256.simplemetrics:simplemetrics:1.9")
'com.j256.simplemetrics:simplemetrics:jar:1.9'
<dependency org="com.j256.simplemetrics" name="simplemetrics" rev="1.9">
  <artifact name="simplemetrics" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.j256.simplemetrics', module='simplemetrics', version='1.9')
)
libraryDependencies += "com.j256.simplemetrics" % "simplemetrics" % "1.9"
[com.j256.simplemetrics/simplemetrics "1.9"]

Dependencies

compile (3)

Group / Artifact Type Version
com.j256.simplejmx : simplejmx Optional jar 1.17
com.amazonaws : aws-java-sdk Optional jar 1.10.40
com.google.code.gson : gson Optional jar 2.2.2

test (2)

Group / Artifact Type Version
junit : junit jar 4.8.1
org.easymock : easymock jar 3.4

Project Modules

There are no modules declared in this project.

Simple Java Metrics

This package provides some Java classes to help with the providing application metrics.

Enjoy, Gray Watson

Little Sample Program

I've checked in a little example program.

Getting Started

Here's a quick code sample showing how to get started.

// create our metrics manager which controls everything
MetricsManager metricsManager = new MetricsManager();

// create and register a persister, you will probably want to write your own for your own logging
LoggingMetricsPersister persister = new LoggingMetricsPersister();
metricsManager.setMetricValuesPersisters(new MetricValuesPersister[] { persister });

// create and register one (or many) metrics
ControlledMetricAccum hitCounter =
	new ControlledMetricAccum("example", null, "hits", "number of hits to the cache", null);
metricsManager.registerMetric(hitCounter);

// optionally start a persister thread to persist the metrics every minute (60000 millis)
MetricsPersisterJob persisterThread = new MetricsPersisterJob(manager, 60000, 60000, true);

// now the metric can be incremented whenever a "hit" occurs
hitCounter.increment();
// or maybe we need to account for a bunch of hits
hitCounter.add(23);
// ...

// the persister will log the value of hitCounter every 60 seconds automatically

Maven Configuration

<dependencies>
	<dependency>
		<groupId>com.j256.simplemetrics</groupId>
		<artifactId>simplemetrics</artifactId>
		<!-- NOTE: change the version to the most recent release version from the repo -->
		<version>1.10</version>
	</dependency>
</dependencies>

ChangeLog Release Notes

See the ChangeLog.txt file.

Versions

Version
1.9
1.8
1.7
1.6
1.5
1.3
1.2
1.1
0.7
0.6
0.5