Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReportScheduler addReporter报错UnsupportedOperationException #364

Closed
wszyquan opened this issue May 27, 2014 · 1 comment
Closed

ReportScheduler addReporter报错UnsupportedOperationException #364

wszyquan opened this issue May 27, 2014 · 1 comment

Comments

@wszyquan
Copy link

错误再现

将showcase的MetricsManager类作如下修改

ConsoleReporter consoleReporter = new ConsoleReporter();
Slf4jReporter slf4jReporter = new Slf4jReporter();
scheduler = new ReportScheduler(MetricRegistry.INSTANCE,
consoleReporter);

    if (graphiteEnabled) {
        GraphiteReporter graphiteReporter = new GraphiteReporter(
                new InetSocketAddress("localhost", 2003));
        scheduler.addReporter(graphiteReporter);
    }

    scheduler.addReporter(slf4jReporter);
    scheduler.start(10, TimeUnit.SECONDS);

添加了一个slf4jReport,运行即报错。

解决办法

1、添加依赖

         <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
    </dependency>

2、将metrics项目的ReportScheduler的构造函数

public ReportScheduler(MetricRegistry metricRegistry, Reporter... reporters) {
this(metricRegistry, Arrays.asList(reporters));
}
修改为
public ReportScheduler(MetricRegistry metricRegistry, Reporter... reporters) {
this(metricRegistry, Lists.newArrayList(reporters));
}

即可

springside pushed a commit that referenced this issue Jun 5, 2014
1 .使用slf4j reporter代替console logger,避免满屏都是log,
2. slf4Reporter和consoleReport多打印一个meanRate()
3. logback演示三种滚动策略
@springside
Copy link
Collaborator

不想引入新的依赖,所以用别的笨办法解决。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant