method2testcases
stringlengths
118
6.63k
### Question: Tags implements Iterable<Tag> { private void dedup() { int n = tags.length; if (n == 0 || n == 1) { last = n; return; } int j = 0; for (int i = 0; i < n - 1; i++) if (!tags[i].getKey().equals(tags[i + 1].getKey())) tags[j++] = tags[i]; tags[j++] = tags[n - 1]; last = j; } private Tags(Tag[] tags); Tags a...
### Question: Tags implements Iterable<Tag> { public Stream<Tag> stream() { return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator(), Spliterator.ORDERED | Spliterator.DISTINCT | Spliterator.NONNULL | Spliterator.SORTED), false); } private Tags(Tag[] tags); Tags and(String key, String value); Tags an...
### Question: Tags implements Iterable<Tag> { public static Tags of(@Nullable Iterable<? extends Tag> tags) { if (tags == null || !tags.iterator().hasNext()) { return Tags.empty(); } else if (tags instanceof Tags) { return (Tags) tags; } else if (tags instanceof Collection) { Collection<? extends Tag> tagsCollection = ...
### Question: ElasticMeterRegistry extends StepMeterRegistry { Optional<String> writeTimeGauge(TimeGauge gauge) { double value = gauge.value(getBaseTimeUnit()); if (Double.isFinite(value)) { return Optional.of(writeDocument(gauge, builder -> { builder.append(",\"value\":").append(value); })); } return Optional.empty();...
### Question: CompositeCounter extends AbstractCompositeMeter<Counter> implements Counter { @Override public void increment(double amount) { forEachChild(c -> c.increment(amount)); } CompositeCounter(Meter.Id id); @Override void increment(double amount); @Override double count(); }### Answer: @Test @Issue("#119") void...
### Question: ElasticMeterRegistry extends StepMeterRegistry { Optional<String> writeLongTaskTimer(LongTaskTimer timer) { return Optional.of(writeDocument(timer, builder -> { builder.append(",\"activeTasks\":").append(timer.activeTasks()); builder.append(",\"duration\":").append(timer.duration(getBaseTimeUnit())); }));...
### Question: ElasticMeterRegistry extends StepMeterRegistry { Optional<String> writeSummary(DistributionSummary summary) { HistogramSnapshot histogramSnapshot = summary.takeSnapshot(); return Optional.of(writeDocument(summary, builder -> { builder.append(",\"count\":").append(histogramSnapshot.count()); builder.append...
### Question: CompositeLongTaskTimer extends AbstractCompositeMeter<LongTaskTimer> implements LongTaskTimer { @Override public Sample start() { List<Sample> samples = new ArrayList<>(); forEachChild(ltt -> samples.add(ltt.start())); return new CompositeSample(samples); } CompositeLongTaskTimer(Meter.Id id, Distribution...
### Question: MicrometerMetricsPublisherThreadPool implements HystrixMetricsPublisherThreadPool { private static String metricName(String name) { return String.join(".", NAME_HYSTRIX_THREADPOOL, name); } MicrometerMetricsPublisherThreadPool( final MeterRegistry meterRegistry, final HystrixThreadPoolKey thre...
### Question: ElasticMeterRegistry extends StepMeterRegistry { Optional<String> writeMeter(Meter meter) { Iterable<Measurement> measurements = meter.measure(); List<String> names = new ArrayList<>(); List<Double> values = new ArrayList<>(); for (Measurement measurement : measurements) { double value = measurement.getVa...
### Question: MicrometerHttpRequestExecutor extends HttpRequestExecutor { public static Builder builder(MeterRegistry registry) { return new Builder(registry); } private MicrometerHttpRequestExecutor(int waitForContinue, MeterRegistry registry, ...
### Question: KafkaConsumerMetrics implements MeterBinder, AutoCloseable { int kafkaMajorVersion(Tags tags) { if (kafkaMajorVersion == null || kafkaMajorVersion == -1) { kafkaMajorVersion = tags.stream().filter(t -> "client.id".equals(t.getKey())).findAny() .map(clientId -> { try { String version = (String) mBeanServer...
### Question: KafkaMetrics implements MeterBinder, AutoCloseable { @Override public void bindTo(MeterRegistry registry) { commonTags = getCommonTags(registry); prepareToBindMetrics(registry); checkAndBindMetrics(registry); scheduler.scheduleAtFixedRate(() -> checkAndBindMetrics(registry), getRefreshIntervalInMillis(), ...
### Question: DatabaseTableMetrics implements MeterBinder { public static void monitor(MeterRegistry registry, String tableName, String dataSourceName, DataSource dataSource, String... tags) { monitor(registry, dataSource, dataSourceName, tableName, Tags.of(tags)); } DatabaseTableMetrics(DataSource dataSource, String d...
### Question: PostgreSQLDatabaseMetrics implements MeterBinder { @Override public void bindTo(MeterRegistry registry) { Gauge.builder("postgres.size", postgresDataSource, dataSource -> getDatabaseSize()) .tags(tags) .description("The database size") .register(registry); Gauge.builder("postgres.connections", postgresDat...
### Question: LogbackMetrics implements MeterBinder, AutoCloseable { @Override public void bindTo(MeterRegistry registry) { MetricsTurboFilter filter = new MetricsTurboFilter(registry, tags); synchronized (metricsTurboFilters) { metricsTurboFilters.put(registry, filter); loggerContext.addTurboFilter(filter); } } Logbac...
### Question: LogbackMetrics implements MeterBinder, AutoCloseable { public static void ignoreMetrics(Runnable r) { ignoreMetrics.set(true); try { r.run(); } finally { ignoreMetrics.remove(); } } LogbackMetrics(); LogbackMetrics(Iterable<Tag> tags); LogbackMetrics(Iterable<Tag> tags, LoggerContext context); @Override...
### Question: FileDescriptorMetrics implements MeterBinder { @Override public void bindTo(MeterRegistry registry) { if (openFilesMethod != null) { Gauge.builder("process.files.open", osBean, x -> invoke(openFilesMethod)) .tags(tags) .description("The open file descriptor count") .baseUnit(BaseUnits.FILES) .register(reg...
### Question: UptimeMetrics implements MeterBinder { @Override public void bindTo(MeterRegistry registry) { TimeGauge.builder("process.uptime", runtimeMXBean, TimeUnit.MILLISECONDS, RuntimeMXBean::getUptime) .tags(tags) .description("The uptime of the Java virtual machine") .register(registry); TimeGauge.builder("proce...
### Question: ElasticMeterRegistry extends StepMeterRegistry { protected String indexName() { ZonedDateTime dt = ZonedDateTime.ofInstant(new Date(config().clock().wallTime()).toInstant(), ZoneOffset.UTC); return config.index() + config.indexDateSeparator() + indexDateFormatter.format(dt); } @SuppressWarnings("deprecati...
### Question: SignalFxNamingConvention implements NamingConvention { @Override public String tagKey(String key) { String conventionKey = delegate.tagKey(key); conventionKey = START_UNDERSCORE_PATTERN.matcher(conventionKey).replaceAll(""); conventionKey = SF_PATTERN.matcher(conventionKey).replaceAll(""); conventionKey =...
### Question: JvmMemory { static Optional<MemoryPoolMXBean> getOldGen() { return ManagementFactory .getPlatformMXBeans(MemoryPoolMXBean.class) .stream() .filter(JvmMemory::isHeap) .filter(mem -> isOldGenPool(mem.getName())) .findAny(); } private JvmMemory(); }### Answer: @Test void assertJvmMemoryGetOldGen() { Optio...
### Question: JvmThreadMetrics implements MeterBinder { @Override public void bindTo(MeterRegistry registry) { ThreadMXBean threadBean = ManagementFactory.getThreadMXBean(); Gauge.builder("jvm.threads.peak", threadBean, ThreadMXBean::getPeakThreadCount) .tags(tags) .description("The peak live thread count since the Jav...
### Question: JvmThreadMetrics implements MeterBinder { static long getThreadStateCount(ThreadMXBean threadBean, Thread.State state) { return Arrays.stream(threadBean.getThreadInfo(threadBean.getAllThreadIds())) .filter(threadInfo -> threadInfo != null && threadInfo.getThreadState() == state) .count(); } JvmThreadMetri...
### Question: ClassLoaderMetrics implements MeterBinder { @Override public void bindTo(MeterRegistry registry) { ClassLoadingMXBean classLoadingBean = ManagementFactory.getClassLoadingMXBean(); Gauge.builder("jvm.classes.loaded", classLoadingBean, ClassLoadingMXBean::getLoadedClassCount) .tags(tags) .description("The n...
### Question: JvmMemoryMetrics implements MeterBinder { @Override public void bindTo(MeterRegistry registry) { for (BufferPoolMXBean bufferPoolBean : ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class)) { Iterable<Tag> tagsWithId = Tags.concat(tags, "id", bufferPoolBean.getName()); Gauge.builder("jvm.buffer.co...
### Question: DiskSpaceMetrics implements MeterBinder { public DiskSpaceMetrics(File path) { this(path, emptyList()); } DiskSpaceMetrics(File path); DiskSpaceMetrics(File path, Iterable<Tag> tags); @Override void bindTo(MeterRegistry registry); }### Answer: @Test void diskSpaceMetrics() { new DiskSpaceMetrics(new Fil...
### Question: DiskSpaceMetrics implements MeterBinder { @Override public void bindTo(MeterRegistry registry) { Iterable<Tag> tagsWithPath = Tags.concat(tags, "path", absolutePath); Gauge.builder("disk.free", path, File::getUsableSpace) .tags(tagsWithPath) .description("Usable space for path") .baseUnit(BaseUnits.BYTES)...
### Question: JvmCompilationMetrics implements MeterBinder { @Override public void bindTo(MeterRegistry registry) { CompilationMXBean compilationBean = ManagementFactory.getCompilationMXBean(); if (compilationBean != null && compilationBean.isCompilationTimeMonitoringSupported()) { FunctionCounter.builder("jvm.compilat...
### Question: EhCache2Metrics extends CacheMeterBinder { public static Ehcache monitor(MeterRegistry registry, Ehcache cache, String... tags) { return monitor(registry, cache, Tags.of(tags)); } EhCache2Metrics(Ehcache cache, Iterable<Tag> tags); static Ehcache monitor(MeterRegistry registry, Ehcache cache, String... ta...
### Question: EhCache2Metrics extends CacheMeterBinder { @Override protected Long size() { return stats.getSize(); } EhCache2Metrics(Ehcache cache, Iterable<Tag> tags); static Ehcache monitor(MeterRegistry registry, Ehcache cache, String... tags); static Ehcache monitor(MeterRegistry registry, Ehcache cache, Iterable<T...
### Question: EhCache2Metrics extends CacheMeterBinder { @Override protected Long evictionCount() { return stats.cacheEvictedCount(); } EhCache2Metrics(Ehcache cache, Iterable<Tag> tags); static Ehcache monitor(MeterRegistry registry, Ehcache cache, String... tags); static Ehcache monitor(MeterRegistry registry, Ehcach...
### Question: EhCache2Metrics extends CacheMeterBinder { @Override protected long hitCount() { return stats.cacheHitCount(); } EhCache2Metrics(Ehcache cache, Iterable<Tag> tags); static Ehcache monitor(MeterRegistry registry, Ehcache cache, String... tags); static Ehcache monitor(MeterRegistry registry, Ehcache cache, ...
### Question: EhCache2Metrics extends CacheMeterBinder { @Override protected Long missCount() { return stats.cacheMissCount(); } EhCache2Metrics(Ehcache cache, Iterable<Tag> tags); static Ehcache monitor(MeterRegistry registry, Ehcache cache, String... tags); static Ehcache monitor(MeterRegistry registry, Ehcache cache...
### Question: EhCache2Metrics extends CacheMeterBinder { @Override protected long putCount() { return stats.cachePutCount(); } EhCache2Metrics(Ehcache cache, Iterable<Tag> tags); static Ehcache monitor(MeterRegistry registry, Ehcache cache, String... tags); static Ehcache monitor(MeterRegistry registry, Ehcache cache, ...
### Question: HazelcastCacheMetrics extends CacheMeterBinder { public static Object monitor(MeterRegistry registry, Object cache, String... tags) { return monitor(registry, cache, Tags.of(tags)); } HazelcastCacheMetrics(Object cache, Iterable<Tag> tags); static Object monitor(MeterRegistry registry, Object cache, Strin...
### Question: HazelcastCacheMetrics extends CacheMeterBinder { @Override protected Long size() { return cache.getLocalMapStats().getOwnedEntryCount(); } HazelcastCacheMetrics(Object cache, Iterable<Tag> tags); static Object monitor(MeterRegistry registry, Object cache, String... tags); static Object monitor(MeterRegist...
### Question: HazelcastCacheMetrics extends CacheMeterBinder { @Override protected Long missCount() { return null; } HazelcastCacheMetrics(Object cache, Iterable<Tag> tags); static Object monitor(MeterRegistry registry, Object cache, String... tags); static Object monitor(MeterRegistry registry, Object cache, Iterable<...
### Question: HazelcastCacheMetrics extends CacheMeterBinder { @Nullable @Override protected Long evictionCount() { return null; } HazelcastCacheMetrics(Object cache, Iterable<Tag> tags); static Object monitor(MeterRegistry registry, Object cache, String... tags); static Object monitor(MeterRegistry registry, Object ca...
### Question: HazelcastCacheMetrics extends CacheMeterBinder { @Override protected long hitCount() { return cache.getLocalMapStats().getHits(); } HazelcastCacheMetrics(Object cache, Iterable<Tag> tags); static Object monitor(MeterRegistry registry, Object cache, String... tags); static Object monitor(MeterRegistry regi...
### Question: HazelcastCacheMetrics extends CacheMeterBinder { @Override protected long putCount() { return cache.getLocalMapStats().getPutOperationCount(); } HazelcastCacheMetrics(Object cache, Iterable<Tag> tags); static Object monitor(MeterRegistry registry, Object cache, String... tags); static Object monitor(Meter...
### Question: GuavaCacheMetrics extends CacheMeterBinder { public static <C extends Cache<?, ?>> C monitor(MeterRegistry registry, C cache, String cacheName, String... tags) { return monitor(registry, cache, cacheName, Tags.of(tags)); } GuavaCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static ...
### Question: GuavaCacheMetrics extends CacheMeterBinder { @Override protected Long size() { return cache.size(); } GuavaCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String cacheName, String... tags); static C monitor(MeterRegistry registry, C ...
### Question: GuavaCacheMetrics extends CacheMeterBinder { @Override protected long hitCount() { return cache.stats().hitCount(); } GuavaCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String cacheName, String... tags); static C monitor(MeterRegis...
### Question: GuavaCacheMetrics extends CacheMeterBinder { @Override protected Long missCount() { return cache.stats().missCount(); } GuavaCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String cacheName, String... tags); static C monitor(MeterReg...
### Question: ElasticNamingConvention implements NamingConvention { @Override public String tagKey(String key) { if (key.equals("name")) { key = "name.tag"; } else if (key.equals("type")) { key = "type.tag"; } else if (key.startsWith("_")) { key = FIRST_UNDERSCORE_PATTERN.matcher(key).replaceFirst(""); } return delegat...
### Question: GuavaCacheMetrics extends CacheMeterBinder { @Override protected Long evictionCount() { return cache.stats().evictionCount(); } GuavaCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String cacheName, String... tags); static C monitor(...
### Question: GuavaCacheMetrics extends CacheMeterBinder { @Override protected long putCount() { return cache.stats().loadCount(); } GuavaCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String cacheName, String... tags); static C monitor(MeterRegi...
### Question: CaffeineCacheMetrics extends CacheMeterBinder { public static <C extends Cache<?, ?>> C monitor(MeterRegistry registry, C cache, String cacheName, String... tags) { return monitor(registry, cache, cacheName, Tags.of(tags)); } CaffeineCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); s...
### Question: CaffeineCacheMetrics extends CacheMeterBinder { @Override protected Long size() { return cache.estimatedSize(); } CaffeineCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String cacheName, String... tags); static C monitor(MeterRegist...
### Question: CaffeineCacheMetrics extends CacheMeterBinder { @Override protected long hitCount() { return cache.stats().hitCount(); } CaffeineCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String cacheName, String... tags); static C monitor(Mete...
### Question: CaffeineCacheMetrics extends CacheMeterBinder { @Override protected Long missCount() { return cache.stats().missCount(); } CaffeineCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String cacheName, String... tags); static C monitor(Me...
### Question: CaffeineCacheMetrics extends CacheMeterBinder { @Override protected Long evictionCount() { return cache.stats().evictionCount(); } CaffeineCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String cacheName, String... tags); static C mo...
### Question: CaffeineCacheMetrics extends CacheMeterBinder { @Override protected long putCount() { return cache.stats().loadCount(); } CaffeineCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String cacheName, String... tags); static C monitor(Met...
### Question: JCacheMetrics extends CacheMeterBinder { public static <K, V, C extends Cache<K, V>> C monitor(MeterRegistry registry, C cache, String... tags) { return monitor(registry, cache, Tags.of(tags)); } JCacheMetrics(Cache<?, ?> cache, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String...
### Question: JCacheMetrics extends CacheMeterBinder { @Override protected Long size() { return null; } JCacheMetrics(Cache<?, ?> cache, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String... tags); static C monitor(MeterRegistry registry, C cache, Iterable<Tag> tags); }### Answer: @Test void...
### Question: JCacheMetrics extends CacheMeterBinder { @Override protected Long missCount() { return lookupStatistic("CacheMisses"); } JCacheMetrics(Cache<?, ?> cache, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String... tags); static C monitor(MeterRegistry registry, C cache, Iterable<Tag> ...
### Question: JCacheMetrics extends CacheMeterBinder { @Override protected Long evictionCount() { return lookupStatistic("CacheEvictions"); } JCacheMetrics(Cache<?, ?> cache, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String... tags); static C monitor(MeterRegistry registry, C cache, Iterabl...
### Question: JCacheMetrics extends CacheMeterBinder { @Override protected long hitCount() { return lookupStatistic("CacheHits"); } JCacheMetrics(Cache<?, ?> cache, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String... tags); static C monitor(MeterRegistry registry, C cache, Iterable<Tag> tag...
### Question: JCacheMetrics extends CacheMeterBinder { @Override protected long putCount() { return lookupStatistic("CachePuts"); } JCacheMetrics(Cache<?, ?> cache, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String... tags); static C monitor(MeterRegistry registry, C cache, Iterable<Tag> tag...
### Question: JCacheMetrics extends CacheMeterBinder { @Override protected void bindImplementationSpecificMetrics(MeterRegistry registry) { if (objectName != null) { Gauge.builder("cache.removals", objectName, objectName -> lookupStatistic("CacheRemovals")) .tags(getTagsWithCacheName()) .description("Cache removals") ....
### Question: TimedHandler extends HandlerWrapper implements Graceful { @Override public Future<Void> shutdown() { return shutdown.shutdown(); } TimedHandler(MeterRegistry registry, Iterable<Tag> tags); TimedHandler(MeterRegistry registry, Iterable<Tag> tags, HttpServletRequestTagsProvider tagsProvider); @Override voi...
### Question: JettySslHandshakeMetrics implements SslHandshakeListener { @Override public void handshakeFailed(Event event, Throwable failure) { handshakesFailed.increment(); } JettySslHandshakeMetrics(MeterRegistry registry); JettySslHandshakeMetrics(MeterRegistry registry, Iterable<Tag> tags); @Override void handsha...
### Question: JettySslHandshakeMetrics implements SslHandshakeListener { @Override public void handshakeSucceeded(Event event) { SSLSession session = event.getSSLEngine().getSession(); Counter.builder(METER_NAME) .baseUnit(BaseUnits.EVENTS) .description(DESCRIPTION) .tag(TAG_RESULT, "succeeded") .tag(TAG_PROTOCOL, sess...
### Question: HibernateMetrics implements MeterBinder { public static void monitor(MeterRegistry registry, SessionFactory sessionFactory, String sessionFactoryName, String... tags) { monitor(registry, sessionFactory, sessionFactoryName, Tags.of(tags)); } HibernateMetrics(SessionFactory sessionFactory, String sessionFac...
### Question: PushMeterRegistry extends MeterRegistry { @Deprecated public final void start() { start(Executors.defaultThreadFactory()); } protected PushMeterRegistry(PushRegistryConfig config, Clock clock); @Deprecated final void start(); void start(ThreadFactory threadFactory); void stop(); @Override void close(); ...
### Question: PushMeterRegistry extends MeterRegistry { @Override public void close() { if (config.enabled()) { publishSafely(); } stop(); super.close(); } protected PushMeterRegistry(PushRegistryConfig config, Clock clock); @Deprecated final void start(); void start(ThreadFactory threadFactory); void stop(); @Overrid...
### Question: StepFunctionTimer implements FunctionTimer { public double totalTime(TimeUnit unit) { accumulateCountAndTotal(); return TimeUtils.convert(countTotal.poll2(), baseTimeUnit(), unit); } StepFunctionTimer(Id id, Clock clock, long stepMillis, T obj, ToLongFunction<T> countFunction, ...
### Question: StepFunctionTimer implements FunctionTimer { public double count() { accumulateCountAndTotal(); return countTotal.poll1(); } StepFunctionTimer(Id id, Clock clock, long stepMillis, T obj, ToLongFunction<T> countFunction, ToDoubleFunction<T> totalTimeFunction, TimeUnit totalTime...
### Question: StepValue { public V poll() { rollCount(clock.wallTime()); return previous; } StepValue(final Clock clock, final long stepMillis); V poll(); }### Answer: @Test void poll() { final AtomicLong aLong = new AtomicLong(42); final long stepTime = 60; final StepValue<Long> stepValue = new StepValue<Long>(clock,...
### Question: AppOpticsMeterRegistry extends StepMeterRegistry { Optional<String> writeGauge(Gauge gauge) { double value = gauge.value(); if (!Double.isFinite(value)) { return Optional.empty(); } return Optional.of(write(gauge.getId(), "gauge", Fields.Value.tag(), decimal(value))); } @SuppressWarnings("deprecation") A...
### Question: StepFunctionCounter extends AbstractMeter implements FunctionCounter { @Override public double count() { T obj2 = ref.get(); if (obj2 != null) { double prevLast = last; last = f.applyAsDouble(obj2); count.getCurrent().add(last - prevLast); } return count.poll(); } StepFunctionCounter(Id id, Clock clock, l...
### Question: MultiGauge { private MultiGauge(MeterRegistry registry, Meter.Id commonId) { this.registry = registry; this.commonId = commonId; } private MultiGauge(MeterRegistry registry, Meter.Id commonId); static Builder builder(String name); void register(Iterable<Row<?>> rows); @SuppressWarnings("unchecked") void ...
### Question: MultiGauge { public void register(Iterable<Row<?>> rows) { register(rows, false); } private MultiGauge(MeterRegistry registry, Meter.Id commonId); static Builder builder(String name); void register(Iterable<Row<?>> rows); @SuppressWarnings("unchecked") void register(Iterable<Row<?>> rows, boolean overwri...
### Question: FixedBoundaryVictoriaMetricsHistogram implements Histogram { public static String getRangeTagValue(double value) { IdxOffset idxOffset = getBucketIdxAndOffset(value); return VMRANGES[getRangeIndex(idxOffset.bucketIdx, idxOffset.offset)]; } FixedBoundaryVictoriaMetricsHistogram(); @Override void recordLong...
### Question: DistributionStatisticConfig implements Mergeable<DistributionStatisticConfig> { @Override public DistributionStatisticConfig merge(DistributionStatisticConfig parent) { return DistributionStatisticConfig.builder() .percentilesHistogram(this.percentileHistogram == null ? parent.percentileHistogram : this.p...
### Question: HistogramGauges { public static HistogramGauges register(HistogramSupport meter, MeterRegistry registry, Function<ValueAtPercentile, String> percentileName, Function<ValueAtPercentile, Iterable<Tag>> percentileTags, Function<ValueAtPercentile, Double> percentileValue, Function<CountAtBucket, String> bucke...
### Question: TimeWindowPercentileHistogram extends AbstractTimeWindowHistogram<DoubleRecorder, DoubleHistogram> { @Override void recordDouble(DoubleRecorder bucket, double value) { bucket.recordValue(value); } TimeWindowPercentileHistogram(Clock clock, DistributionStatisticConfig distributionStatisticConfig, ...
### Question: TimeWindowFixedBoundaryHistogram extends AbstractTimeWindowHistogram<TimeWindowFixedBoundaryHistogram.FixedBoundaryHistogram, Void> { @Override final void recordDouble(FixedBoundaryHistogram bucket, double value) { recordLong(bucket, (long) Math.ceil(value)); } TimeWindowFixedBoundaryHistogram(Clock clock...
### Question: DefaultJerseyTagsProvider implements JerseyTagsProvider { @Override public Iterable<Tag> httpRequestTags(RequestEvent event) { ContainerResponse response = event.getContainerResponse(); return Tags.of(JerseyTags.method(event.getContainerRequest()), JerseyTags.uri(event), JerseyTags.exception(event), Jerse...
### Question: DefaultJerseyTagsProvider implements JerseyTagsProvider { @Override public Iterable<Tag> httpLongRequestTags(RequestEvent event) { return Tags.of(JerseyTags.method(event.getContainerRequest()), JerseyTags.uri(event)); } @Override Iterable<Tag> httpRequestTags(RequestEvent event); @Override Iterable<Tag> ...
### Question: AppOpticsMeterRegistry extends StepMeterRegistry { Optional<String> writeTimeGauge(TimeGauge timeGauge) { double value = timeGauge.value(getBaseTimeUnit()); if (!Double.isFinite(value)) { return Optional.empty(); } return Optional.of(write(timeGauge.getId(), "timeGauge", Fields.Value.tag(), decimal(value)...
### Question: AppOpticsMeterRegistry extends StepMeterRegistry { Optional<String> writeFunctionCounter(FunctionCounter counter) { double count = counter.count(); if (Double.isFinite(count) && count > 0) { return Optional.of(write(counter.getId(), "functionCounter", Fields.Value.tag(), decimal(count))); } return Optiona...
### Question: AppOpticsMeterRegistry extends StepMeterRegistry { @Override protected void publish() { try { String bodyMeasurementsPrefix = getBodyMeasurementsPrefix(); for (List<Meter> batch : MeterPartition.partition(this, config.batchSize())) { final List<String> meters = batch.stream() .map(meter -> meter.match( th...
### Question: AppOpticsMeterRegistry extends StepMeterRegistry { String getBodyMeasurementsPrefix() { long stepSeconds = config.step().getSeconds(); long wallTimeInSeconds = TimeUnit.MILLISECONDS.toSeconds(clock.wallTime()); if (config.floorTimes()) { wallTimeInSeconds -= wallTimeInSeconds % stepSeconds; } return Strin...
### Question: AtlasMeterRegistry extends MeterRegistry { @Override public void close() { stop(); super.close(); } AtlasMeterRegistry(AtlasConfig config, Clock clock); AtlasMeterRegistry(AtlasConfig config); void start(); void stop(); @Override void close(); Registry getSpectatorRegistry(); }### Answer: @Issue("#484")...
### Question: AtlasMeterRegistry extends MeterRegistry { public Registry getSpectatorRegistry() { return registry; } AtlasMeterRegistry(AtlasConfig config, Clock clock); AtlasMeterRegistry(AtlasConfig config); void start(); void stop(); @Override void close(); Registry getSpectatorRegistry(); }### Answer: @Issue("#20...
### Question: AtlasNamingConvention implements NamingConvention { @Override public String tagKey(String key) { if (key.equals("name")) { key = "name.tag"; } else if (key.equals("statistic")) { key = "statistic.tag"; } return NamingConvention.camelCase.tagKey(key); } @Override String name(String name, Meter.Type type, ...
### Question: SpectatorTimer extends AbstractTimer { @Override public double max(TimeUnit unit) { for (Measurement measurement : timer.measure()) { if (stream(measurement.id().tags().spliterator(), false) .anyMatch(tag -> tag.key().equals("statistic") && tag.value().equals(Statistic.max.toString()))) { return TimeUtils...
### Question: DynatraceMeterRegistry extends StepMeterRegistry { void putCustomMetric(final DynatraceMetricDefinition customMetric) { try { httpClient.put(customMetricEndpointTemplate + customMetric.getMetricId() + "?api-token=" + config.apiToken()) .withJsonContent(customMetric.asJson()) .send() .onSuccess(response ->...
### Question: DynatraceMeterRegistry extends StepMeterRegistry { List<DynatraceBatchedPayload> createPostMessages(String type, String group, List<DynatraceTimeSeries> timeSeries) { final String header = "{\"type\":\"" + type + '\"' + (StringUtils.isNotBlank(group) ? ",\"group\":\"" + group + '\"' : "") + ",\"series\":[...
### Question: DynatraceMetricDefinition { String asJson() { String displayName = description == null ? metricId : StringEscapeUtils.escapeJson(description); String body = "{\"displayName\":\"" + StringUtils.truncate(displayName, MAX_DISPLAY_NAME) + "\""; if (StringUtils.isNotBlank(group)) body += ",\"group\":\"" + Stri...
### Question: DynatraceNamingConvention implements NamingConvention { @Override public String name(String name, Meter.Type type, @Nullable String baseUnit) { return "custom:" + sanitizeName(delegate.name(name, type, baseUnit)); } DynatraceNamingConvention(NamingConvention delegate); DynatraceNamingConvention(); @Overr...
### Question: DynatraceNamingConvention implements NamingConvention { @Override public String tagKey(String key) { return KEY_CLEANUP_PATTERN.matcher(delegate.tagKey(key)).replaceAll("_"); } DynatraceNamingConvention(NamingConvention delegate); DynatraceNamingConvention(); @Override String name(String name, Meter.Type...
### Question: DynatraceTimeSeries { String asJson() { String body = "{\"timeseriesId\":\"" + metricId + "\"" + ",\"dataPoints\":[[" + time + "," + DoubleFormat.wholeOrDecimal(value) + "]]"; if (dimensions != null && !dimensions.isEmpty()) { body += ",\"dimensions\":{" + dimensions.entrySet().stream() .map(t -> "\"" + t...
### Question: PrometheusRenameFilter implements MeterFilter { @Override public Meter.Id map(Meter.Id id) { String convertedName = MICROMETER_TO_PROMETHEUS_NAMES.get(id.getName()); return convertedName == null ? id : id.withName(convertedName); } @Override Meter.Id map(Meter.Id id); }### Answer: @Test void doesNotChan...
### Question: PrometheusMeterRegistry extends MeterRegistry { public PrometheusMeterRegistry throwExceptionOnRegistrationFailure() { config().onMeterRegistrationFailed((id, reason) -> { throw new IllegalArgumentException(reason); }); return this; } PrometheusMeterRegistry(PrometheusConfig config); PrometheusMeterRegis...
### Question: PrometheusMeterRegistry extends MeterRegistry { public CollectorRegistry getPrometheusRegistry() { return registry; } PrometheusMeterRegistry(PrometheusConfig config); PrometheusMeterRegistry(PrometheusConfig config, CollectorRegistry registry, Clock clock); String scrape(); void scrape(Writer writer); @...
### Question: CacheController { public ClientConnection getConnection(String deviceName){ synchronized (clientCache) { List<ClientConnection> clientConnections = clientCache.get(deviceName); if (clientConnections != null && !clientConnections.isEmpty()){ for (ClientConnection c : clientConnections){ if (!isConnectionEx...
### Question: DeviceManager implements RadarListener { @Override public void deviceLeft(NetworkDevice device) { if (device == null || device.getNetworkDeviceName() == null || device.getNetworkDeviceType() == null) return; logger.info("Device "+device.getNetworkDeviceName()+" of type "+device.getNetworkDeviceType()+" le...