Metrics Crawler

Little library to crawl metrics

License

License

Categories

Categories

Metrics Application Testing & Monitoring Monitoring
GroupId

GroupId

org.bytemechanics
ArtifactId

ArtifactId

metrics-crawler
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

Metrics Crawler
Little library to crawl metrics
Project URL

Project URL

https://metrics-crawler.bytemechanics.org
Project Organization

Project Organization

Byte Mechanics
Source Code Management

Source Code Management

https://github.com/bytemechanics/metrics-crawler

Download metrics-crawler

How to add to project

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

Dependencies

test (4)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.5.2
org.junit.jupiter : junit-jupiter-params jar 5.5.2
org.junit.jupiter : junit-jupiter-engine jar 5.5.2
org.jmockit : jmockit jar 1.48

Project Modules

There are no modules declared in this project.

Metrics Crawler

Latest version Quality Gate Coverage License

A little library with zero dependencies to crawl metrics and store during a certain window. The library provides an utility to monitor certain code segments and measure with minimum performance some estatistics:

  • Number of measures taken
  • Last measure
  • Maximum measure
  • Minimum measure
  • Average measure
  • Last measure occurrence

And this measures can be:

  • Double
  • Long
  • Duration (elapsed time)

All sensors implements Autocloseable in order to reduce boilerplate when taking measures. The library allows create metric names manually or tracking your sensor stack if you are using imperative programming (As the library uses ThreadLocal to stack the sensors if you use multithreading you can have unexpected results)

Motivation

When you have performance problems in production environment and don't know where look, the only way is to have measures directly from real, using sensors allows to identify the bottlenecks in production

Quick start

(Please read our Javadoc for further information)

  1. First of all include the Jar file in your compile and execution classpath.

    Maven

    <dependency>
        <groupId>org.bytemechanics</groupId>
        <artifactId>metrics-crawler</artifactId>
        <version>X.X.X</version>
    </dependency>

    Graddle

    dependencies {
        compile 'org.bytemechanics:metrics-crawler:X.X.X'
    }

    1.1. Optionally register external MetricService supplier at application startup, take in account that expects this supplier always return the same instance (only necessary if you want to use a singleton distinct from the default one)

    AbstractSensor.registerMetricsServiceSupplier([your supplier]);
  2. Start measuring

    2.1. Option1: With manual naming

    import org.bytemechanics.metrics.crawler.sensors.DoubleSensor;
    import org.bytemechanics.metrics.crawler.sensors.LongSensor;
    import org.bytemechanics.metrics.crawler.sensors.DurationSensor;
    (...)
    try(DoubleSensor sensor1=DoubleSensor.get("myName")){
    	sensor1=2.0d;
    	(...)
    }
    (...)
    try(LongSensor sensor1=LongSensor.get("my{}Name{}","long",1)){
    	sensor1=2l;
    	(...)
    	try(LongSensor sensor2=LongSensor.get("my{}Name{}.my{}Name{}","long",1,"long",2)){
    		sensor2=5l;
    		(...)
    	}
    }
    (...)
    try(DurationSensor sensor1=DurationSensor.get("{}myName{}","duration","sensor")){
    	(...)
    }

    2.2. Option2: With stack naming (the same result)

    import org.bytemechanics.metrics.crawler.sensors.stack.DoubleStackSensor;
    import org.bytemechanics.metrics.crawler.sensors.stack.LongStackSensor;
    import org.bytemechanics.metrics.crawler.sensors.stack.DurationStackSensor;
    (...)
    try(DoubleStackSensor sensor1=DoubleStackSensor.get("myName")){
    	sensor1=2.0d;
    	(...)
    }
    (...)
    try(LongStackSensor sensor1=LongStackSensor.get("my{}Name{}","long",1)){
    	sensor1=2l;
    	(...)
    	try(LongStackSensor sensor2=LongStackSensor.get("my{}Name{}","long",2)){
    		sensor2=5l;
    		(...)
    	}
    }
    (...)
    try(DurationStackSensor sensor1=DurationStackSensor.get("{}myName{}","duration","sensor")){
    	(...)
    }
org.bytemechanics

ByteMechanics Foundation

Foundation dedicated to provide opensource libraries and resources to simplify developers life

Versions

Version
1.0.2
1.0.1
1.0.0