我正在尝试使用@Timed(http://metrics.dropwizard.io/3.1.0/apidocs/com/codahale/metrics/annotation/package-summary.html)等注释自动将指标发布到我的MetricRegistry .
这不是开箱即用的.在搜索问题时,我发现了Codahale Metrics:在普通Java中使用@Timed指标注释,其中提到了这个工作的唯一方法是使用aspectj.我将此添加到我的项目中,但仍未在MetricRegistry中看到我的指标.
这是我的pom文件.我添加了一个librato库,它加载了com.codahale.metrics:metrics-annotation.
<dependency>
<groupId>io.astefanutti.metrics.aspectj</groupId>
<artifactId>metrics-aspectj</artifactId>
<version>${metrics-aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.10</version>
</dependency>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.7</version>
<configuration>
<showWeaveInfo>true</showWeaveInfo>
<source>1.8</source>
<target>1.8</target>
<complianceLevel>1.8</complianceLevel>
<encoding>UTF-8</encoding>
<verbose>true</verbose>
<aspectLibraries>
<aspectLibrary>
<groupId>io.astefanutti.metrics.aspectj</groupId>
<artifactId>metrics-aspectj</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<dependency>
<groupId>com.librato.metrics</groupId>
<artifactId>metrics-librato</artifactId>
<version>${metrics-librato.version}</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这就是我尝试使用指标的方式
@Metrics(registry = "default") // this.metricRegistry is default
public class Foo {
@Inject
private MetricRegistry metricRegistry;
...
@Metered(name = "meterName")
public void bar() { …Run Code Online (Sandbox Code Playgroud) 我正在尝试为Big Number图表创建两个指标的简单组合:
mean([
series("metric.a", {}),
series("metric.b", {})
])
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时,我收到以下错误.我的语法是否关闭?
Unable to execute composite: ["error": "Requested MD data from SD endpoint"].
Run Code Online (Sandbox Code Playgroud)