Java Code Examples for com.netflix.spectator.api.Id#create()

The following examples show how to use com.netflix.spectator.api.Id#create() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConsolidatorTest.java    From spectator with Apache License 2.0 6 votes vote down vote up
@Test
public void avgRandom() {
  Id id = Id.create("test");
  Id measurementId = id.withTag("atlas.dstype", "rate").withTag(Statistic.count);
  ManualClock clock = new ManualClock();

  Counter primary = registry(clock, PRIMARY_STEP).counter(id);
  Counter consolidated = registry(clock, CONSOLIDATED_STEP).counter(id);

  Consolidator consolidator = new Consolidator.Avg(CONSOLIDATED_STEP, MULTIPLE);

  consolidateRandomData(
      measurementId,
      clock,
      consolidator,
      primary::add,
      consolidated::add,
      primary::measure,
      consolidated::measure);
}
 
Example 2
Source File: ConsolidatorTest.java    From spectator with Apache License 2.0 6 votes vote down vote up
@Test
public void maxRandom() {
  Id id = Id.create("test");
  Id measurementId = id.withTag("atlas.dstype", "gauge").withTag(Statistic.max);
  ManualClock clock = new ManualClock();

  Gauge primary = registry(clock, PRIMARY_STEP).maxGauge(id);
  Gauge consolidated = registry(clock, CONSOLIDATED_STEP).maxGauge(id);

  Consolidator consolidator = new Consolidator.Max(CONSOLIDATED_STEP, MULTIPLE);

  consolidateRandomData(
      measurementId,
      clock,
      consolidator,
      primary::set,
      consolidated::set,
      primary::measure,
      consolidated::measure);
}
 
Example 3
Source File: ConsolidatorTest.java    From spectator with Apache License 2.0 6 votes vote down vote up
@Test
public void noneRandom() {
  Id id = Id.create("test");
  Id measurementId = id.withTag("atlas.dstype", "rate").withTag(Statistic.count);
  ManualClock clock = new ManualClock();

  Counter primary = registry(clock, CONSOLIDATED_STEP).counter(id);
  Counter consolidated = registry(clock, CONSOLIDATED_STEP).counter(id);

  Consolidator consolidator = new Consolidator.None();

  consolidateRandomData(
      measurementId,
      clock,
      consolidator,
      primary::add,
      consolidated::add,
      primary::measure,
      consolidated::measure);
}
 
Example 4
Source File: PollMetersBench.java    From spectator with Apache License 2.0 5 votes vote down vote up
private Id randomId(Random r) {
  Id tmp = Id.create(randomString(r, 2 + r.nextInt(120)));
  int n = r.nextInt(20);
  for (int i = 0; i < n; ++i) {
    String k = randomString(r, 2 + r.nextInt(60));
    String v = randomString(r, 2 + r.nextInt(120));
    tmp = tmp.withTag(k, v);
  }
  return tmp;
}
 
Example 5
Source File: MicrometerRegistry.java    From spectator with Apache License 2.0 4 votes vote down vote up
@Override public Id createId(String name) {
  return Id.create(name);
}
 
Example 6
Source File: ConsolidatorTest.java    From spectator with Apache License 2.0 4 votes vote down vote up
@Test
public void createFromIdNoStatistic() {
  Id id = Id.create("foo");
  Consolidator consolidator = Consolidator.create(id, CONSOLIDATED_STEP, MULTIPLE);
  Assertions.assertTrue(consolidator instanceof Consolidator.Max);
}
 
Example 7
Source File: ConsolidatorTest.java    From spectator with Apache License 2.0 4 votes vote down vote up
@Test
public void createFromIdMultipleOne() {
  Id id = Id.create("foo");
  Consolidator consolidator = Consolidator.create(id, CONSOLIDATED_STEP, 1);
  Assertions.assertTrue(consolidator instanceof Consolidator.None);
}
 
Example 8
Source File: TestMeter.java    From spectator with Apache License 2.0 4 votes vote down vote up
public TestMeter(String name, List<Measurement> measures) {
  myId = Id.create(name);
  myMeasurements = measures;
}