Skip to content

kosmisk-dk/ee-stats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EE-Stats

An EJB to depend on in a ee-project, that supplies:

Services provided

  • a jolokia.html index file with stats (and pie chart) from the application
  • jolokia/ the jolokia servlet
  • jolokia/name a text file providing the first found value of
    1. Environment variable $JOLOKIA_NAME
    2. Environment variable $APPLICAITON_NAME
    3. the application name as declared in the ee container
  • Annotations to provide stats using metric
    1. @Counted - simple counter
    2. @Metered - @Counted + Rate of calls
    3. @Timed - @Metered + durations of calls
    4. @LifeCycleMetric - class level annotation needed for the other 3 to work ok Constructor, @PostConstruct and @PreDestroy. If this is needed but not supplied, an EJBException is thrown on startup. If it's present, but unneeded, an error is logged.

How to provide stats

This is only for Beans example:

Simple bean invocations

@Stateless
@Path("foo")
public class Foo {

    @GET
    @Path("now")
    @Produces(MediaType.TEXT_PLAIN)
    @dk.kosmisk.ee.stats.Timed // @Metered or @Counted
    public String now() {
        return Instant.now().toString();
    }
}

LifeCycle measurements

@Stateless
@LifeCycleMetric
public class Foo {

    @PostConstruct
    @Timed
    public void init() {
        // Something time consuming
        // like initialization of JavaScript environment
    }
}

Remember measurements can only be made on bean-method invocations, ie. this.method() cannot me measured. One workaround is, Make a bean with business logic, and invoke the methods needed to accomplish the task, this way you can measure which part of the process that takes time.

@Inject

You can inject:

  1. MetricRegistry
  2. Counter
  3. Meter
  4. Timer

Counter/Meter/Timer gets fully qualified name as JMX metric name unless annotated with @ExposeAs("name").

Example application in example

example

How to depend on it

in pom.xml

<dependencies>
    ...

    <dependency>
        <groupId>dk.kosmisk</groupId>
        <artifactId>ee-stats</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

About

JavaEE CDI/Jolokia/Metric based stat module (EBJ)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published