Coder Social home page Coder Social logo

Comments (16)

codahale avatar codahale commented on May 9, 2024

@ryantenney, this is all yours.

from metrics.

codahale avatar codahale commented on May 9, 2024

Actually, considering this a dupe of #162.

from metrics.

ryantenney avatar ryantenney commented on May 9, 2024

The problem is actually with the XML namespace beans, as I omitted the schemaLocation for the spring-beans xsd.

xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.yammer.com/schema/metrics http://www.yammer.com/schema/metrics/metrics.xsd">

The XML in the manual was intended as an example of the XML the should be added to your Spring application's existing applicationContext.xml. If it is added as a separate file, it will not have any effect.

from metrics.

sheki avatar sheki commented on May 9, 2024

Thanks. Works now.
Missed the spring bean part.

from metrics.

sheki avatar sheki commented on May 9, 2024

Though I get a null pointer exception in my app now which looks like https://gist.github.com/1934852
Can you just have a look at it.Please, pretty please.

from metrics.

ryantenney avatar ryantenney commented on May 9, 2024

When I wrote this, I actually had ruled out the possibility of this error occurring... Is healthAsHTML the method that you have annotated with @timed? Could you give me some more information about the class that this method belongs to? It seems to implement an interface, does that interface define the healthAsHTML method?

from metrics.

sheki avatar sheki commented on May 9, 2024

healthAsHTML is part of an interface.
Here are my code snippets of HealthCheck inteface and its implementation.
https://gist.github.com/1935181

from metrics.

sheki avatar sheki commented on May 9, 2024

healthAsHTML is part of an interface.
Here are my code snippets of HealthCheck inteface and its implementation.
https://gist.github.com/1935181

-Abhishek Kona

On Wed, Feb 29, 2012 at 2:34 AM, Ryan W Tenney <
[email protected]

wrote:

When I wrote this, I actually had ruled out the possibility of this error
occurring... Is healthAsHTML the method that you have annotated with
@timed? Could you give me some more information about the class that this
method belongs to? It seems to implement an interface, does that interface
define the healthAsHTML method?


Reply to this email directly or view it on GitHub:
https://github.com/codahale/metrics/issues/169#issuecomment-4225453

from metrics.

ryantenney avatar ryantenney commented on May 9, 2024

Thanks! I'll run some tests to see if I can replicate this issue.

from metrics.

ryantenney avatar ryantenney commented on May 9, 2024

Good news, I was able to reproduce this problem! I'll look into whether it is possible to fix this, but in the meantime, you can avoid this issue by annotating the implementation of healthAsHTML in the class HealthCheckImpl, instead of annotating the method in the interface HealthCheck. (see https://gist.github.com/1935505 )

from metrics.

sheki avatar sheki commented on May 9, 2024

Annotating the method in HealthCheckImpl does not time the method and no stats are collected.
I already had annotated asJSON method in the Impl but no stats are collected for it.

from metrics.

sheki avatar sheki commented on May 9, 2024

Ok my bad. The data is getting collected, it is available as a JMX Bean, but to get the data out on Graphite, do I need to configure something else in the bean?

Right now I am initializing the Graphite Reporter in code and not in XML.

from metrics.

sheki avatar sheki commented on May 9, 2024

Looks like I cannot initialize the graphite reporter in XML, how Do I access the registry defined in XML in Code?

from metrics.

ryantenney avatar ryantenney commented on May 9, 2024

Right now, if you're calling GraphiteReporter.enable(long period, TimeUnit unit, String host, int port), it tries to use the default MetricsRegistry, which is not the same as the one created by this module. The MetricsRegistry created by this module is made available as a candidate for autowiring, so you can create a class like the one below and create it as a Spring bean:

public class EnableGraphiteReporter {

    @Autowired
    MetricsRegistry metricsRegistry;

    @PostConstruct
    public void init() {
        /* pass metricsRegistry into GraphiteReporter.enable(), like so: */
        GraphiteReporter.enable(metricsRegistry, 1, TimeUnit.MINUTE, "graphite-server", 8080);
    }

}

from metrics.

sheki avatar sheki commented on May 9, 2024

Right, this worked for me. but get a lot of Null Pointer errors. The @Timed annotation can be safely used in the higher Layers of Jersey

from metrics.

ryantenney avatar ryantenney commented on May 9, 2024

I spent some time playing with the Guice module, and it seems that it also does not recognize annotations on interfaces. I'll put in a patch to prevent the NullPointerExceptions, but I think that the behavior should remain consistent with that of the Guice module.

from metrics.

Related Issues (20)

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.