下面列出了com.codahale.metrics.MetricFilter#ALL 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/** Create a new instance. */
SpectatorReporter(
MetricRegistry metricRegistry,
Registry spectatorRegistry,
NameFunction nameFunction,
ValueFunction valueFunction,
Pattern gaugeCounters) {
super(metricRegistry,
"spectator", // name
MetricFilter.ALL, // filter
TimeUnit.SECONDS, // rateUnit
TimeUnit.SECONDS); // durationUnit
this.spectatorRegistry = spectatorRegistry;
this.nameFunction = nameFunction;
this.valueFunction = valueFunction;
this.gaugeCounters = gaugeCounters;
}
public DatadogMetricsReporter(HoodieWriteConfig config, MetricRegistry registry) {
reportPeriodSeconds = config.getDatadogReportPeriodSeconds();
ApiSite apiSite = config.getDatadogApiSite();
String apiKey = config.getDatadogApiKey();
ValidationUtils.checkState(!StringUtils.isNullOrEmpty(apiKey),
"Datadog cannot be initialized: API key is null or empty.");
boolean skipValidation = config.getDatadogApiKeySkipValidation();
int timeoutSeconds = config.getDatadogApiTimeoutSeconds();
String prefix = config.getDatadogMetricPrefix();
ValidationUtils.checkState(!StringUtils.isNullOrEmpty(prefix),
"Datadog cannot be initialized: Metric prefix is null or empty.");
Option<String> host = Option.ofNullable(config.getDatadogMetricHost());
List<String> tagList = config.getDatadogMetricTags();
Option<List<String>> tags = tagList.isEmpty() ? Option.empty() : Option.of(tagList);
reporter = new DatadogReporter(
registry,
new DatadogHttpClient(apiSite, apiKey, skipValidation, timeoutSeconds),
prefix,
host,
tags,
MetricFilter.ALL,
TimeUnit.SECONDS,
TimeUnit.SECONDS
);
}
@JsonCreator
public MetricsConfigurator(
@JsonProperty("name") String name,
@JsonProperty("comment") String comment,
@JsonProperty("reporter") ReporterConfigurator reporter,
@JsonProperty("includes") List<String> includes,
@JsonProperty("excludes") List<String> excludes
) {
super();
this.name = Objects.requireNonNull(name, "All reporters must have a name");
this.comment = comment;
this.configurator = Objects.requireNonNull(reporter, () -> String.format("Invalid definition for reporter with name %s. Must define a reporter block.", name));
this.includes = Optional.ofNullable(includes).orElse(Collections.emptyList());
this.excludes = Optional.ofNullable(excludes).orElse(Collections.emptyList());
if (this.includes.isEmpty() && this.excludes.isEmpty()) {
filter = MetricFilter.ALL;
} else {
filter = new IncludesExcludesFilter(includes, excludes);
}
}
private Builder(MetricRegistry registry) {
this.registry = registry;
this.prefix = "";
this.output = System.out;
this.locale = Locale.getDefault();
this.clock = Clock.defaultClock();
this.timeZone = TimeZone.getDefault();
this.rateUnit = TimeUnit.SECONDS;
this.durationUnit = TimeUnit.MILLISECONDS;
this.filter = MetricFilter.ALL;
this.disabledMetricAttributes = Collections.emptySet();
}
private MetricFilter createMetricFilter(Config config) {
if (config.hasPath(METRIC_FILTER_NAME_REGEX) && config.hasPath(METRIC_FILTER_TYPE_LIST)) {
return MetricFilters.and(new MetricNameRegexFilter(config.getString(METRIC_FILTER_NAME_REGEX)),
new MetricTypeFilter(config.getString(METRIC_FILTER_TYPE_LIST)));
}
if (config.hasPath(METRIC_FILTER_NAME_REGEX)) {
return new MetricNameRegexFilter(config.getString(METRIC_FILTER_NAME_REGEX));
}
if (config.hasPath(METRIC_FILTER_TYPE_LIST)) {
return new MetricTypeFilter(config.getString(METRIC_FILTER_TYPE_LIST));
}
return MetricFilter.ALL;
}
private Builder(MetricRegistry registry) {
this.registry = registry;
this.rateUnit = TimeUnit.MILLISECONDS;
this.durationUnit = TimeUnit.MILLISECONDS;
this.filter = MetricFilter.ALL;
this.tags = new HashMap<>();
}
private Builder(MetricRegistry registry) {
this.registry = registry;
this.rateUnit = TimeUnit.MILLISECONDS;
this.durationUnit = TimeUnit.MILLISECONDS;
this.filter = MetricFilter.ALL;
this.tags = new HashMap<>();
}
private Builder(MetricRegistry registry) {
this.registry = registry;
this.clock = Clock.defaultClock();
this.prefix = null;
this.rateUnit = TimeUnit.SECONDS;
this.durationUnit = TimeUnit.MILLISECONDS;
this.filter = MetricFilter.ALL;
}
private static MetricFilter getFilter(final List<String> whitelistMetrics) {
if (whitelistMetrics == null || whitelistMetrics.isEmpty()) {
return MetricFilter.ALL;
}
return new MetricFilter() {
@Override
public boolean matches(String name, com.codahale.metrics.Metric metric) {
return whitelistMetrics.contains(name);
}
};
}
private Builder(final MetricRegistry metricRegistry, final CloudWatchAsyncClient cloudWatchAsyncClient, final String namespace) {
this.metricRegistry = metricRegistry;
this.cloudWatchAsyncClient = cloudWatchAsyncClient;
this.namespace = namespace;
this.percentiles = new Percentile[]{Percentile.P75, Percentile.P95, Percentile.P999};
this.metricFilter = MetricFilter.ALL;
this.rateUnit = TimeUnit.SECONDS;
this.durationUnit = TimeUnit.MILLISECONDS;
this.globalDimensions = new LinkedHashSet<>();
this.cwMeterUnit = Optional.empty();
this.cwRateUnit = toStandardUnit(rateUnit);
this.cwDurationUnit = toStandardUnit(durationUnit);
this.clock = Clock.defaultClock();
}
private Builder(MetricRegistry registry) {
this.registry = registry;
this.rateUnit = TimeUnit.SECONDS;
this.durationUnit = TimeUnit.MILLISECONDS;
this.clock = Clock.defaultClock();
this.filter = MetricFilter.ALL;
}
/**
* Retrieve matching metrics and their names.
*
* @param registry registry name.
* @param metricFilter filter (null is equivalent to {@link MetricFilter#ALL}).
* @return map of matching names and metrics
*/
public Map<String, Metric> getMetrics(String registry, MetricFilter metricFilter) {
if (metricFilter == null || metricFilter == MetricFilter.ALL) {
return registry(registry).getMetrics();
}
return registry(registry).getMetrics().entrySet().stream()
.filter(entry -> metricFilter.matches(entry.getKey(), entry.getValue()))
.collect(Collectors.toMap(entry -> entry.getKey(), entry -> entry.getValue()));
}
protected Builder() {
super();
this.name = "MetricReportReporter";
this.filter = MetricFilter.ALL;
}
private MqMeticReporterService(IMqClientBase mqClientBase) {
reporter = new MqMetricReporter(MetricSingleton.getMetricRegistry(), "mq-client", MetricFilter.ALL,
TimeUnit.MILLISECONDS, TimeUnit.MILLISECONDS, null, mqClientBase.getContext());
}
private Builder(MetricRegistry registry) {
this.registry = registry;
this.filter = MetricFilter.ALL;
this.rateUnit = TimeUnit.SECONDS;
this.durationUnit = TimeUnit.MILLISECONDS;
}
public MetricsModule(TimeUnit rateUnit, TimeUnit durationUnit,
boolean showSamples) {
this(rateUnit, durationUnit, showSamples, MetricFilter.ALL);
}
private ServerReporter(MetricRegistry registry) {
this(registry, SECONDS, MILLISECONDS, MetricFilter.ALL);
}
private Builder(MetricRegistry registry) {
this.registry = registry;
this.rateUnit = TimeUnit.SECONDS;
this.durationUnit = TimeUnit.MILLISECONDS;
this.filter = MetricFilter.ALL;
}
/**
* Returns the {@link MetricFilter} that shall be used to filter metrics, or {@link MetricFilter#ALL} if
* the default should be used.
*/
protected MetricFilter getMetricFilter() {
// use the default
return MetricFilter.ALL;
}
/**
* Create a SolrReporter instance.
* @param solrClientCache client cache to use for constructing SolrClient instances.
* @param urlProvider what URL to send to.
* @param metricManager metric manager
* @param metrics metric specifications to report
* @param handler handler name to report to
* @param reporterId my reporter id
* @param rateUnit rate unit
* @param durationUnit duration unit
* @param params request parameters
* @param skipHistograms if true then don't send histogram metrics
* @param skipAggregateValues if true then don't send aggregate metrics' individual values
* @param cloudClient if true then use CloudSolrClient, plain HttpSolrClient otherwise.
* @param compact if true then use compact representation.
*/
public SolrReporter(SolrClientCache solrClientCache, boolean closeClientCache,
Supplier<String> urlProvider, SolrMetricManager metricManager,
List<Report> metrics, String handler,
String reporterId, TimeUnit rateUnit, TimeUnit durationUnit,
SolrParams params, boolean skipHistograms, boolean skipAggregateValues,
boolean cloudClient, boolean compact) {
super(dummyRegistry, "solr-reporter", MetricFilter.ALL, rateUnit, durationUnit, null, true);
this.metricManager = metricManager;
this.urlProvider = urlProvider;
this.reporterId = reporterId;
if (handler == null) {
handler = MetricsCollectorHandler.HANDLER_PATH;
}
this.handler = handler;
this.clientCache = solrClientCache;
this.closeClientCache = closeClientCache;
this.compiledReports = new ArrayList<>();
metrics.forEach(report -> {
MetricFilter filter = new SolrMetricManager.RegexFilter(report.metricFilters);
try {
CompiledReport cs = new CompiledReport(report);
compiledReports.add(cs);
} catch (PatternSyntaxException e) {
log.warn("Skipping report with invalid registryPattern: {}", report.registryPattern, e);
}
});
this.skipHistograms = skipHistograms;
this.skipAggregateValues = skipAggregateValues;
this.cloudClient = cloudClient;
this.compact = compact;
this.params = new ModifiableSolrParams();
this.params.set(REPORTER_ID, reporterId);
// allow overrides to take precedence
if (params != null) {
this.params.add(params);
}
metadata = new HashMap<>();
metadata.put(REPORTER_ID, reporterId);
}