Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Latest commit

 

History

History
84 lines (48 loc) · 3.18 KB

README.md

File metadata and controls

84 lines (48 loc) · 3.18 KB

primeval-metrics-aspecio Build Status Gitter primeval-io/Lobby

Uses Aspecio to provide an aspect named MetricsAspect. It measures the execution time of methods annotated with the @Measured annotation.

Maven coordinates

	<groupId>io.primeval</groupId>
	<artifactId>primeval-metrics-aspecio</artifactId>
	<version>1.0.0-SNAPSHOT</version>

Until a stable release, the snapshot version is available in the Sonatype OSS Snapshots repository.

Dependencies

primeval-metrics-aspecio requires Java 8 and depends on Primeval Metrics.

	<dependency>
		<groupId>io.primeval</groupId>
		<artifactId>primeval-metrics</artifactId>
		<version>1.0.0-SNAPSHOT</version>
	</dependency>

Aspects provided

Aspect MetricsAspect is provided.

When active, this aspects uses a Metrics timer to time execution time of methods annotated with the @Measured annotation.

The timer is named from the method identifier: package names are short-form (initials only), exceptions and return types are ignored. For instance, a method identifier might look as i.p.m.i.AnnotatedMetricInterceptorImpl.setMetrics(Metrics).

Counters under these names represent the time before a method returns (normally or exceptionally).

If a method returns an OSGi Promise (as used in Primeval Codex), then another timer is used and has the form <methodId>::promise. It represents the time until a Promise is resolved (successfully or not). A method returning a Promise should ideally be non-blocking and have negligible execution time, while the promise resolution time should display actual performance.

Also note that a service property named primeval.metrics.measured will be set to Boolean.TRUE to your service if it is properly woven with that aspect.

Adding MetricsAspect to your service

To add MetricsAspect to your service, set your OSGi service property service.aspect.weave.optional (or service.aspect.weave if you want mandatory weaving) to io.primeval.metrics.aspect.MetricsAspect. Don't forget your implementation must add @Measured to intercepted methods you wish to measure (Aspecio and Primeval Metrics must be active).

If you use Declarative Services, bnd and the Primeval's bnd-dsap-plugin, you can measure a component this way:

@Component
@Weave(optional = MetricsAspect.class)
public final class HelloGoodbyeImpl implements Hello, Goodbye {

    @Measured
    public String hello() {
        return "hello";
    }

    public String goodbye() {
        return "goodbye";
    }

}

Getting help

Post a new GitHub issue or join on Gitter.

Author

primeval-metrics-aspecio was developed by Simon Chemouil.

Copyright

(c) 2016-2017, Simon Chemouil, Lambdacube

primeval-metrics-aspecio is part of the Primeval project.