Code Monkey home page Code Monkey logo

ee-stats's Introduction

Appropriated from https://github.com/kosmisk-dk/ee-stats with permission of original author by original author

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.dbc.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.dbc</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>

ee-stats's People

Contributors

mb-dbc-dk avatar kosmisk-dk avatar

Watchers

 avatar  avatar Jørgen G. Nielsen avatar Hans-Henrik Lund avatar James Cloos avatar Jacob Poulsen avatar Søren Vibjerg avatar  avatar Jan Bauer Nielsen avatar Finn Stausgaard avatar Anders Andersen avatar  avatar Anders Vestergaard avatar  avatar  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.