1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.omid.metrics;
19
20 import com.google.inject.Inject;
21
22 import javax.inject.Named;
23 import javax.inject.Singleton;
24 import java.util.HashSet;
25 import java.util.Set;
26
27 @Singleton
28 public class CodahaleMetricsConfig extends AbstractMetricsConfig {
29
30 public enum Reporter {
31 CSV, SLF4J, GRAPHITE, CONSOLE
32 }
33
34 private static final String DEFAULT_PREFIX = "omid";
35 private static final String DEFAULT_GRAPHITE_HOST = "localhost:2003";
36 private static final String DEFAULT_CSV_DIR = ".";
37 private static final String DEFAULT_SLF4J_LOGGER = "metrics";
38
39 private static final String METRICS_CODAHALE_PREFIX_KEY = "metrics.codahale.prefix";
40 private static final String METRICS_CODAHALE_REPORTERS_KEY = "metrics.codahale.reporters";
41 private static final String METRICS_CODAHALE_GRAPHITE_HOST_CONFIG = "metrics.codahale.graphite.host.config";
42 private static final String METRICS_CODAHALE_CSV_DIR = "metrics.codahale.cvs.dir";
43 private static final String METRICS_CODAHALE_SLF4J_LOGGER = "metrics.codahale.slf4j.logger";
44
45 private String prefix = DEFAULT_PREFIX;
46 private Set<Reporter> reporters = new HashSet<Reporter>();
47 private String graphiteHostConfig = DEFAULT_GRAPHITE_HOST;
48 private String csvDir = DEFAULT_CSV_DIR;
49 private String slf4jLogger = DEFAULT_SLF4J_LOGGER;
50
51 public String getPrefix() {
52 return prefix;
53 }
54
55 @Inject(optional = true)
56 public void setPrefix(@Named(METRICS_CODAHALE_PREFIX_KEY) String prefix) {
57 this.prefix = prefix;
58 }
59
60 public Set<Reporter> getReporters() {
61 return reporters;
62 }
63
64 @Inject(optional = true)
65 public void setReporters(@Named(METRICS_CODAHALE_REPORTERS_KEY) Set<Reporter> reporters) {
66 this.reporters = reporters;
67 }
68
69 public void addReporter(Reporter reporter) {
70 reporters.add(reporter);
71 }
72
73 public String getGraphiteHostConfig() {
74 return graphiteHostConfig;
75 }
76
77 @Inject(optional = true)
78 public void setGraphiteHostConfig(@Named(METRICS_CODAHALE_GRAPHITE_HOST_CONFIG) String graphiteHostConfig) {
79 this.graphiteHostConfig = graphiteHostConfig;
80 }
81
82 public String getCsvDir() {
83 return csvDir;
84 }
85
86 @Inject(optional = true)
87 public void setCsvDir(@Named(METRICS_CODAHALE_CSV_DIR) String csvDir) {
88 this.csvDir = csvDir;
89 }
90
91 public String getSlf4jLogger() {
92 return slf4jLogger;
93 }
94
95 @Inject(optional = true)
96 public void setSlf4jLogger(@Named(METRICS_CODAHALE_SLF4J_LOGGER) String slf4jLogger) {
97 this.slf4jLogger = slf4jLogger;
98 }
99
100 }