【问题标题】:Reading metrics configuration from YAML file within a dropwizard REST application从 dropwizard REST 应用程序中的 YAML 文件读取指标配置
【发布时间】:2015-07-01 15:13:32
【问题描述】:

我的 Metrics 配置在我的 dropwizard rest 应用程序中是这样的,(hello-world.yml)

metrics:
  reporters:
    - type: log
      logger: metrics
      markerName: <marker name>

这是一个 SLF4J Reporter,我将它放在了我的 YAML 配置文件中。现在,当我想获取这个值并在我的应用程序文件中使用它时。我看到的唯一选择是将其读取为Map&lt;String, List&lt;Map&lt;String, String&gt;&gt; metrics; 读取此配置并在 dropwizard Application 类中使用它的正确方法是什么。请帮帮我。

此问题与Dropwizard Yaml for graphite server configuration 相同。但同样没有答案,因此通过创建一个新问题来试试我的运气。

【问题讨论】:

    标签: java dropwizard codahale-metrics


    【解决方案1】:

    我在 dropwizard 用户中发布了这个问题并得到了答案。 https://groups.google.com/forum/#!topic/dropwizard-user/yxceCS1CEns

     final ImmutableList<ReporterFactory> reporters = configuration.getMetricsFactory().getReporters();
            final Slf4jReporterFactory slf4jReporterFactory = (Slf4jReporterFactory) reporters.get(0);
            slf4jReporterFactory.getMarkerName();
            slf4jReporterFactory.getLoggerName();
    

    【讨论】:

      猜你喜欢
      • 2018-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-22
      • 1970-01-01
      • 2017-02-16
      • 2020-02-27
      • 2023-03-12
      相关资源
      最近更新 更多