@VisibleForTesting
DecayingEstimatedHistogramReservoir(boolean considerZeroes, int bucketCount, Clock clock)
{
if (bucketCount == DEFAULT_BUCKET_COUNT)
{
if (considerZeroes == true)
{
bucketOffsets = DEFAULT_WITH_ZERO_BUCKET_OFFSETS;
}
else
{
bucketOffsets = DEFAULT_WITHOUT_ZERO_BUCKET_OFFSETS;
}
}
else
{
bucketOffsets = EstimatedHistogram.newOffsets(bucketCount, considerZeroes);
}
decayingBuckets = new AtomicLongArray(bucketOffsets.length + 1);
buckets = new AtomicLongArray(bucketOffsets.length + 1);
this.clock = clock;
decayLandmark = clock.getTime();
}
java类com.codahale.metrics.Clock的实例源码
DecayingEstimatedHistogramReservoir.java 文件源码
项目:sstable-adaptor
阅读 41
收藏 0
点赞 0
评论 0
HttpAsyncClientRuleHelper.java 文件源码
项目:JInsight
阅读 29
收藏 0
点赞 0
评论 0
public void onResponseReceived(HttpRequest request, HttpResponse response) {
Long startTime = removeObjectProperty(request, START_TIME_PROPERTY_NAME);
if (startTime == null) {
return;
}
long t = Clock.defaultClock().getTick() - startTime;
String method = request.getRequestLine().getMethod();
int statusCode = response.getStatusLine().getStatusCode();
String metricName = ROOT_NAME.withTags(
"method", method,
"status", "" + statusCode).toString();
Timer timer = RegistryService.getMetricRegistry().timer(metricName);
timer.update(t, TimeUnit.NANOSECONDS);
}
UrlConnectionRuleHelper.java 文件源码
项目:JInsight
阅读 27
收藏 0
点赞 0
评论 0
public void onGetInputStream(HttpURLConnection urlConnection, int statusCode) {
Long startTime = removeObjectProperty(urlConnection, START_TIME_PROPERTY_NAME);
if (startTime == null) {
return;
}
long t = Clock.defaultClock().getTick() - startTime;
String method = urlConnection.getRequestMethod();
String status = "" + statusCode;
Timer timer = timers.computeIfAbsent(status + method, s -> {
TagEncodedMetricName metricName = ROOT_NAME.withTags(
"method", method,
"status", status);
return getTimer(metricName);
});
timer.update(t, TimeUnit.NANOSECONDS);
}
ElasticsearchReporter.java 文件源码
项目:spelk
阅读 41
收藏 0
点赞 0
评论 0
private ElasticsearchReporter(MetricRegistry registry, MetricFilter filter, TimeUnit rateUnit,
TimeUnit durationUnit, String host, String port, String indexName, String timestampField) {
super(registry, "elasticsearch-reporter", filter, rateUnit, durationUnit);
this.clock = Clock.defaultClock();
this.connector = new ElasticsearchConnector(host, port, indexName);
this.timestampField = timestampField;
this.timestampFormat = new SimpleDateFormat(timeStampString);
this.localhost = Utils.localHostName();
jsonFactory = new JsonFactory();
indexInitialized = connector.addDefaultMappings();
if (!indexInitialized) {
LOGGER.warn("Failed to initialize Elasticsearch index '" + indexName + "' on " + host + ":" + port);
}
}
HawkularReporter.java 文件源码
项目:hawkular-dropwizard-reporter
阅读 25
收藏 0
点赞 0
评论 0
HawkularReporter(MetricRegistry registry,
HawkularHttpClient hawkularClient,
Optional<String> prefix,
MetricsDecomposer decomposer,
MetricsTagger tagger,
TimeUnit rateUnit,
TimeUnit durationUnit,
MetricFilter filter) {
super(registry, "hawkular-reporter", filter, rateUnit, durationUnit);
this.prefix = prefix;
this.clock = Clock.defaultClock();
this.hawkularClient = hawkularClient;
this.decomposer = decomposer;
this.tagger = tagger;
}
HawkularReporter.java 文件源码
项目:hawkular-metrics
阅读 29
收藏 0
点赞 0
评论 0
HawkularReporter(MetricRegistry registry,
HawkularHttpClient hawkularClient,
Optional<String> prefix,
MetricsDecomposer decomposer,
MetricsTagger tagger,
TimeUnit rateUnit,
TimeUnit durationUnit,
MetricFilter filter) {
super(registry, "hawkular-reporter", filter, rateUnit, durationUnit);
this.prefix = prefix;
this.clock = Clock.defaultClock();
this.hawkularClient = hawkularClient;
this.decomposer = decomposer;
this.tagger = tagger;
}
ServerLogMetricForwarderUnitTest.java 文件源码
项目:NeverwinterDP-Commons
阅读 30
收藏 0
点赞 0
评论 0
@Test
public void testBasic() throws Exception {
FileUtil.removeIfExist("build/ServerLogMetricPlugin", false);
YaraServiceImpl yaraService = new YaraServiceImpl() ;
server.getServiceRegistry().register(YaraService.newReflectiveBlockingService(yaraService));
MetricRegistry server1 = createMetricRegistry("server1") ;
MetricRegistry server2 = createMetricRegistry("server2") ;
Random rand = new Random() ;
for(int i = 0; i < 100000; i++) {
long timestamp = Clock.defaultClock().getTick() ;
server1.counter("counter").incr() ;
server1.timer("timer").update(timestamp, rand.nextInt(1000)) ;
server2.counter("counter").incr() ;
server2.timer("timer").update(timestamp, rand.nextInt(1000)) ;
}
Thread.sleep(6000);
new ClusterMetricPrinter().print(yaraService.getClusterMetricRegistry());
}
StorageReporter.java 文件源码
项目:wildfly-monitor
阅读 38
收藏 0
点赞 0
评论 0
private StorageReporter(MetricRegistry registry,
Locale locale,
Clock clock,
TimeZone timeZone,
TimeUnit rateUnit,
TimeUnit durationUnit,
MetricFilter filter, StorageAdapter storageAdapter) {
super(registry, "storage-reporter", filter, rateUnit, durationUnit);
this.locale = locale;
this.clock = clock;
this.storageAdapter = storageAdapter;
this.dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT,
DateFormat.MEDIUM,
locale);
dateFormat.setTimeZone(timeZone);
}
ReporterV08.java 文件源码
项目:metrics-influxdb
阅读 33
收藏 0
点赞 0
评论 0
public ReporterV08(MetricRegistry registry,
Influxdb influxdb,
Clock clock,
String prefix,
TimeUnit rateUnit,
TimeUnit durationUnit,
MetricFilter filter,
boolean skipIdleMetrics,
ScheduledExecutorService executor) {
super(registry, "influxdb-reporter", filter, rateUnit, durationUnit, executor);
this.skipIdleMetrics = skipIdleMetrics;
this.previousValues = new TreeMap<String, Long>();
this.influxdb = influxdb;
this.clock = clock;
this.prefix = (prefix == null) ? "" : (prefix.trim() + ".");
}
ElasticsearchReporter.java 文件源码
项目:metrics-elasticsearch
阅读 27
收藏 0
点赞 0
评论 0
protected ElasticsearchReporter(MetricRegistry registry, Clock clock,
String elasticsearchIndexPrefix, String timestampFieldName,
String metricPrefix, TimeUnit rateUnit, TimeUnit durationUnit,
MetricFilter filter) {
super(registry, "elasticsearch-reporter", filter, rateUnit,
durationUnit);
this.clock = clock;
this.metricPrefix = metricPrefix;
this.timestampFieldName = timestampFieldName;
if (elasticsearchIndexPrefix.endsWith("-")) {
this.elasticsearchIndexPrefix = elasticsearchIndexPrefix;
} else {
this.elasticsearchIndexPrefix = elasticsearchIndexPrefix + "-";
}
jsonFactory = new JsonFactory();
}
InfluxDbReporterTest.java 文件源码
项目:stagemonitor
阅读 37
收藏 0
点赞 0
评论 0
@Before
public void setUp() throws Exception {
httpClient = mock(HttpClient.class);
Clock clock = mock(Clock.class);
timestamp = System.currentTimeMillis();
when(clock.getTime()).thenReturn(timestamp);
final CorePlugin corePlugin = mock(CorePlugin.class);
when(corePlugin.getInfluxDbUrl()).thenReturn(new URL("http://localhost:8086"));
when(corePlugin.getInfluxDbDb()).thenReturn("stm");
influxDbReporter = InfluxDbReporter.forRegistry(new Metric2Registry(), corePlugin)
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(DURATION_UNIT)
.globalTags(singletonMap("app", "test"))
.httpClient(httpClient)
.clock(clock)
.build();
}
AsyncRequestLog.java 文件源码
项目:grails-lightweight-deploy
阅读 30
收藏 0
点赞 0
评论 0
public AsyncRequestLog(Clock clock,
AppenderAttachableImpl<ILoggingEvent> appenders,
final TimeZone timeZone,
List<String> cookies) {
this.clock = clock;
this.cookies = cookies;
this.queue = new LinkedBlockingQueue<String>();
this.dispatcher = new Dispatcher();
this.dispatchThread = new Thread(dispatcher);
dispatchThread.setName("async-request-log-dispatcher-" + THREAD_COUNTER.incrementAndGet());
dispatchThread.setDaemon(true);
this.dateCache = new ThreadLocal<DateCache>() {
@Override
protected DateCache initialValue() {
final DateCache cache = new DateCache("dd/MMM/yyyy:HH:mm:ss Z", Locale.US);
cache.setTimeZoneID(timeZone.getID());
return cache;
}
};
this.appenders = appenders;
}
ExternalConnectorFactory.java 文件源码
项目:grails-lightweight-deploy
阅读 30
收藏 0
点赞 0
评论 0
private AbstractConnector configureExternalHttpsConnector() {
logger.info("Creating https connector");
final SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setCertAlias(getConfiguration().getSslConfiguration().getKeyStoreAlias());
sslContextFactory.setKeyStorePath(getConfiguration().getSslConfiguration().getKeyStorePath());
sslContextFactory.setKeyStorePassword(getConfiguration().getSslConfiguration().getKeyStorePassword());
final Integer port = getConfiguration().getSslConfiguration().getPort() != null ?
getConfiguration().getSslConfiguration().getPort() :
getConfiguration().getPort();
final InstrumentedSslSocketConnector connector = new InstrumentedSslSocketConnector(
this.metricRegistry,
port,
sslContextFactory,
Clock.defaultClock());
connector.setName(EXTERNAL_HTTPS_CONNECTOR_NAME);
return connector;
}
JedisRuleHelper.java 文件源码
项目:JInsight
阅读 30
收藏 0
点赞 0
评论 0
public void onTransactionExec(Transaction tx) {
Long startTime = removeObjectProperty(tx, TRANSACTION_START_TIME_PROP_NAME);
if (startTime == null) {
return;
}
long t = Clock.defaultClock().getTick() - startTime;
txExecTimer.update(t, TimeUnit.NANOSECONDS);
}
JedisRuleHelper.java 文件源码
项目:JInsight
阅读 27
收藏 0
点赞 0
评论 0
public void onTransactionDiscard(Transaction tx) {
Long startTime = removeObjectProperty(tx, TRANSACTION_START_TIME_PROP_NAME);
if (startTime == null) {
return;
}
long t = Clock.defaultClock().getTick() - startTime;
txDiscardTimer.update(t, TimeUnit.NANOSECONDS);
}
JedisRuleHelper.java 文件源码
项目:JInsight
阅读 35
收藏 0
点赞 0
评论 0
public void onPipelineSync(Pipeline pipeline) {
Long startTime = removeObjectProperty(pipeline, TRANSACTION_START_TIME_PROP_NAME);
if (startTime == null) {
return;
}
long t = Clock.defaultClock().getTick() - startTime;
pipelineSyncTimer.update(t, TimeUnit.NANOSECONDS);
}
ElasticsearchReporter.java 文件源码
项目:oneops
阅读 33
收藏 0
点赞 0
评论 0
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;
}
ElasticsearchReporter.java 文件源码
项目:oneops
阅读 35
收藏 0
点赞 0
评论 0
public ElasticsearchReporter(MetricRegistry registry, String[] hosts, int timeout,
String index, String indexDateFormat, int bulkSize, Clock clock, String prefix, TimeUnit rateUnit, TimeUnit durationUnit,
MetricFilter filter, MetricFilter percolationFilter, Notifier percolationNotifier, String timestampFieldname,Map<String,String> context) throws MalformedURLException {
super(registry, "elasticsearch-reporter", filter, rateUnit, durationUnit);
this.hosts = hosts;
this.index = index;
this.bulkSize = bulkSize;
this.clock = clock;
this.prefix = prefix;
this.timeout = timeout;
if (indexDateFormat != null && indexDateFormat.length() > 0) {
this.indexDateFormat = new SimpleDateFormat(indexDateFormat);
}
if (percolationNotifier != null && percolationFilter != null) {
this.percolationFilter = percolationFilter;
this.notifier = percolationNotifier;
}
if (timestampFieldname == null || timestampFieldname.trim().length() == 0) {
LOGGER.error("Timestampfieldname {} is not valid, using default @timestamp", timestampFieldname);
timestampFieldname = "@timestamp";
}
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
objectMapper.configure(SerializationFeature.CLOSE_CLOSEABLE, false);
// auto closing means, that the objectmapper is closing after the first write call, which does not work for bulk requests
objectMapper.configure(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT, false);
objectMapper.configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);
objectMapper.registerModule(new MetricsElasticsearchModule(rateUnit, durationUnit, timestampFieldname));
writer = objectMapper.writer();
checkForIndexTemplate();
}
HumanReadableCsvReporter.java 文件源码
项目:Lagerta
阅读 32
收藏 0
点赞 0
评论 0
private Builder(MetricRegistry registry) {
this.registry = registry;
this.locale = Locale.getDefault();
this.rateUnit = TimeUnit.SECONDS;
this.durationUnit = TimeUnit.MILLISECONDS;
this.clock = Clock.defaultClock();
this.filter = MetricFilter.ALL;
}
HumanReadableCsvReporter.java 文件源码
项目:Lagerta
阅读 33
收藏 0
点赞 0
评论 0
/** */
private HumanReadableCsvReporter(MetricRegistry registry, File directory, Locale locale, TimeUnit rateUnit,
TimeUnit durationUnit, Clock clock, MetricFilter filter) {
super(registry, "human-readable-csv-reporter", filter, rateUnit, durationUnit);
this.directory = directory;
this.locale = locale;
this.clock = clock;
}
DelegatingDerivingMeterTest.java 文件源码
项目:semantic-metrics
阅读 37
收藏 0
点赞 0
评论 0
private void setupRateTest() throws InterruptedException {
Clock clock = mock(Clock.class);
meter = new DelegatingDerivingMeter(new Meter(clock));
when(clock.getTick()).thenReturn(0L);
meter.mark(0);
meter.mark(2000);
// need to 'wait' more than 5 seconds for the Codahale metrics meter to 'tick'.
when(clock.getTick()).thenReturn(TimeUnit.NANOSECONDS.convert(6, TimeUnit.SECONDS));
}
CloudWatchReporter.java 文件源码
项目:codahale-aggregated-metrics-cloudwatch-reporter
阅读 29
收藏 0
点赞 0
评论 0
private Builder(final MetricRegistry metricRegistry, final AmazonCloudWatchAsync 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.cwRateUnit = toStandardUnit(rateUnit);
this.cwDurationUnit = toStandardUnit(durationUnit);
this.clock = Clock.defaultClock();
}
CustomMeter.java 文件源码
项目:mongoose-base
阅读 30
收藏 0
点赞 0
评论 0
public CustomMeter(final Clock clock, final int periodSec) {
final double ps = periodSec > 0 ? periodSec : 10;
final int intervalSecs = 1;
rateAvg = new EWMA(1 - exp(-intervalSecs / ps), intervalSecs, TimeUnit.SECONDS);
this.clock = clock;
startTime = clock.getTick();
lastTick.set(startTime);
}
CompositeForwardingTimer.java 文件源码
项目:monitoring-center
阅读 33
收藏 0
点赞 0
评论 0
public CompositeForwardingTimer(Timer mainDelegate, MetricProvider<Timer> supplementaryMetricProvider) {
Preconditions.checkNotNull(mainDelegate);
Preconditions.checkNotNull(supplementaryMetricProvider);
this.mainDelegate = mainDelegate;
this.supplementaryMetricProvider = supplementaryMetricProvider;
this.clock = Clock.defaultClock();
}
CirconusReporter.java 文件源码
项目:metrics-circonus
阅读 31
收藏 0
点赞 0
评论 0
private CirconusReporter(MetricRegistry metricRegistry,
Transport transport,
MetricFilter filter,
Clock clock,
String host,
EnumSet<Expansion> expansions,
TimeUnit rateUnit,
TimeUnit durationUnit,
MetricNameFormatter metricNameFormatter,
List<String> tags,
String prefix,
DynamicTagsCallback tagsCallback,
Boolean suppress) {
super(metricRegistry, "circonus-reporter", filter, rateUnit, durationUnit);
if(!(metricRegistry instanceof CirconusMetricRegistryAlaCoda)) {
LOG.warn("CirconusReporter started without a CirconusMetricRegistry(AlaCoda) so no real histograms.");
}
this.clock = clock;
this.host = host;
this.expansions = expansions;
this.metricNameFormatter = metricNameFormatter;
this.tags = (tags == null) ? new ArrayList<String>() : tags;
this.transport = transport;
this.prefix = prefix;
this.tagsCallback = tagsCallback;
this.suppress_bad_analytics = suppress;
}
CirconusReporter.java 文件源码
项目:metrics-circonus
阅读 28
收藏 0
点赞 0
评论 0
public Builder(MetricRegistry registry) {
this.registry = registry;
this.expansions = Expansion.ALL;
this.clock = Clock.defaultClock();
this.rateUnit = TimeUnit.SECONDS;
this.durationUnit = TimeUnit.MILLISECONDS;
this.filter = MetricFilter.ALL;
this.metricNameFormatter = new DefaultMetricNameFormatter();
this.tags = new ArrayList<String>();
this.suppress_bad_analytics = true;
}
OutputStreamReporter.java 文件源码
项目:Gobblin
阅读 26
收藏 0
点赞 0
评论 0
protected Builder(MetricRegistry registry) {
this.registry = registry;
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.tags = new LinkedHashMap<String, String>();
}
OperatingSystemGaugeSet.java 文件源码
项目:metrics-os
阅读 31
收藏 0
点赞 0
评论 0
public OperatingSystemGaugeSet( OperatingSystemMXBean osMxBean,
int cacheTimeoutValue,
TimeUnit cacheTimeoutUnit,
Clock cacheTimeoutClock ) {
this.osMxBean = osMxBean;
this.cacheTimeoutValue = cacheTimeoutValue;
this.cacheTimeoutUnit = cacheTimeoutUnit;
this.cacheTimeoutClock = cacheTimeoutClock;
}
OperatingSystemInfo.java 文件源码
项目:metrics-os
阅读 33
收藏 0
点赞 0
评论 0
public OperatingSystemInfo( OperatingSystemMXBean osMxBean,
long timeout,
TimeUnit timeoutUnit,
Clock timeoutClock ) {
super( Objects.requireNonNull( timeoutClock ), timeout, Objects.requireNonNull( timeoutUnit ) );
this.osMxBean = Objects.requireNonNull( osMxBean );
}
TestReporter.java 文件源码
项目:micro-server
阅读 35
收藏 0
点赞 0
评论 0
private Builder(MetricRegistry registry) {
this.registry = registry;
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;
}