本文整理汇总了Java中org.springframework.boot.actuate.metrics.writer.Delta类的典型用法代码示例。如果您正苦于以下问题:Java Delta类的具体用法?Java Delta怎么用?Java Delta使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Delta类属于org.springframework.boot.actuate.metrics.writer包,在下文中一共展示了Delta类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: increment
import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Override
public void increment(Delta<?> delta) {
final String metricName = delta.getName();
final int amount = delta.getValue().intValue();
final Date timestamp = delta.getTimestamp();
this.metrics.update(metricName, new Callback<Metric<?>>() {
@Override
public Metric<?> modify(Metric<?> current) {
if (current != null) {
Metric<? extends Number> metric = current;
return new Metric<Long>(metricName,
metric.increment(amount).getValue(), timestamp);
}
else {
return new Metric<Long>(metricName, Long.valueOf(amount), timestamp);
}
}
});
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:InMemoryMetricRepository.java
示例2: increment
import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void increment() {
this.repository.increment("foo", new Delta<Number>("foo.bar", 1));
this.repository.increment("foo", new Delta<Number>("foo.bar", 2));
this.repository.increment("foo", new Delta<Number>("foo.spam", 1));
Metric<?> bar = null;
Set<String> names = new HashSet<String>();
for (Metric<?> metric : this.repository.findAll("foo")) {
names.add(metric.getName());
if (metric.getName().equals("foo.bar")) {
bar = metric;
}
}
assertThat(names).hasSize(2).contains("foo.bar");
assertThat(bar.getValue()).isEqualTo(3d);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:RedisMultiMetricRepositoryTests.java
示例3: counterWithGaugeWriter
import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void counterWithGaugeWriter() throws Exception {
SimpleGaugeWriter writer = new SimpleGaugeWriter();
MetricCopyExporter exporter = new MetricCopyExporter(this.reader, writer);
try {
this.reader.increment(new Delta<Number>("counter.foo", 2));
exporter.export();
this.reader.increment(new Delta<Number>("counter.foo", 3));
exporter.export();
exporter.flush();
assertThat(writer.getValue().getValue()).isEqualTo(5L);
}
finally {
exporter.close();
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:MetricCopyExporterTests.java
示例4: increment
import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Override
public void increment(Delta<?> delta) {
final String metricName = delta.getName();
final int amount = delta.getValue().intValue();
final Date timestamp = delta.getTimestamp();
this.metrics.update(metricName, new Callback<Metric<?>>() {
@Override
public Metric<?> modify(Metric<?> current) {
if (current != null) {
Metric<? extends Number> metric = current;
return new Metric<Long>(metricName,
metric.increment(amount).getValue(), timestamp);
}
else {
return new Metric<Long>(metricName, new Long(amount), timestamp);
}
}
});
}
示例5: increment
import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void increment() {
this.repository.increment("foo", new Delta<Number>("foo.bar", 1));
this.repository.increment("foo", new Delta<Number>("foo.bar", 2));
this.repository.increment("foo", new Delta<Number>("foo.spam", 1));
Metric<?> bar = null;
Set<String> names = new HashSet<String>();
for (Metric<?> metric : this.repository.findAll("foo")) {
names.add(metric.getName());
if (metric.getName().equals("foo.bar")) {
bar = metric;
}
}
assertEquals(2, names.size());
assertTrue("Wrong names: " + names, names.contains("foo.bar"));
assertEquals(3d, bar.getValue());
}
示例6: ingestMetric
import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
/**
* Ingest a raw {@link Delta}.
*
* @param delta Raw {@link Delta} exported by springboot
*/
public void ingestMetric(Delta<?> delta) {
ExportedMetric exportedMetric = new ExportedMetric.Builder()
.withName(delta.getName())
.withValue(delta.getValue().doubleValue())
.withTimestamp(delta.getTimestamp().getTime() / 1000L)
.build();
ingest(exportedMetric);
}
示例7: shouldIngestMetricOnIncrement
import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void shouldIngestMetricOnIncrement() {
// When
Delta delta = new Delta<>("foo", 1L);
subject.increment(delta);
// Then
verify(statfulClientProxy).ingestMetric(delta);
}
示例8: shouldIngestFromDelta
import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void shouldIngestFromDelta() {
// Given
when(statfulMetricProcessor.validate(any())).thenReturn(true);
List<ProcessedMetric> processedMetrics = Lists.newArrayList(getProcessedMetric());
when(statfulMetricProcessor.process(any())).thenReturn(processedMetrics);
Delta delta = new Delta<>(METRIC_NAME, 1L);
// When
subject.ingestMetric(delta);
// Then
verify(statfulClient).put(eq(INGESTED_METRIC_NAME), eq(Double.toString(1L)), any(Tags.class), eq(null),
eq(null), anyInt(), eq(NAMESPACE), anyInt());
}
示例9: increment
import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Override
public void increment(Delta<?> delta) {
String name = delta.getName();
String key = keyFor(name);
trackMembership(key);
double value = this.zSetOperations.incrementScore(key,
delta.getValue().doubleValue());
String raw = serialize(new Metric<Double>(name, value, delta.getTimestamp()));
this.redisOperations.opsForValue().set(key, raw);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:RedisMetricRepository.java
示例10: increment
import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Override
public void increment(String group, Delta<?> delta) {
String groupKey = keyFor(group);
trackMembership(groupKey);
BoundZSetOperations<String, String> zSetOperations = this.redisOperations
.boundZSetOps(groupKey);
String key = keyFor(delta.getName());
double value = zSetOperations.incrementScore(key, delta.getValue().doubleValue());
String raw = serialize(
new Metric<Double>(delta.getName(), value, delta.getTimestamp()));
this.redisOperations.opsForValue().set(key, raw);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:RedisMultiMetricRepository.java
示例11: calculateDelta
import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
private Delta<?> calculateDelta(Metric<?> value) {
long delta = value.getValue().longValue();
Long old = this.counts.replace(value.getName(), delta);
if (old != null) {
delta = delta - old;
}
else {
this.counts.putIfAbsent(value.getName(), delta);
}
return new Delta<Long>(value.getName(), delta, value.getTimestamp());
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:MetricCopyExporter.java
示例12: incrementCounter
import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void incrementCounter() {
this.source.increment(new Delta<Long>("foo.bar.counter.spam", 2L));
this.source.increment(new Delta<Long>("oof.rab.counter.spam", 3L));
assertThat(this.reader.findOne("aggregate.counter.spam").getValue())
.isEqualTo(5L);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:AggregateMetricReaderTests.java
示例13: countGaugesAndCounters
import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void countGaugesAndCounters() {
this.source.set(new Metric<Double>("foo.bar.spam", 2.3));
this.source.set(new Metric<Double>("oof.rab.spam", 2.4));
this.source.increment(new Delta<Long>("foo.bar.counter.spam", 2L));
this.source.increment(new Delta<Long>("oof.rab.counter.spam", 3L));
assertThat(this.reader.count()).isEqualTo(2);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:AggregateMetricReaderTests.java
示例14: setIncrementAndGet
import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void setIncrementAndGet() {
this.repository.set(new Metric<Number>("foo", 12.3));
this.repository.increment(new Delta<Long>("foo", 3L));
Metric<?> metric = this.repository.findOne("foo");
assertThat(metric.getName()).isEqualTo("foo");
assertThat(metric.getValue().doubleValue()).isEqualTo(15.3, offset(0.01));
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:RedisMetricRepositoryTests.java
示例15: registeredPrefixCounted
import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void registeredPrefixCounted() {
this.repository.increment(new Delta<Number>("foo.bar", 1));
this.repository.increment(new Delta<Number>("foo.bar", 1));
this.repository.increment(new Delta<Number>("foo.spam", 1));
Set<String> names = new HashSet<String>();
for (Metric<?> metric : this.repository.findAll("foo")) {
names.add(metric.getName());
}
assertThat(names).hasSize(2);
assertThat(names.contains("foo.bar")).isTrue();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:InMemoryPrefixMetricRepositoryTests.java