Ejemplo n.º 1
0
  @Test
  public void testTaggableGauge() {
    ContextAwareGauge<Long> queueSize =
        this.context.newContextAwareGauge(
            QUEUE_SIZE,
            new Gauge<Long>() {
              @Override
              public Long getValue() {
                return 1000l;
              }
            });
    this.context.register(QUEUE_SIZE, queueSize);

    Assert.assertEquals(queueSize.getValue().longValue(), 1000l);

    Assert.assertEquals(
        this.context
            .getGauges()
            .get(MetricRegistry.name(this.context.metricNamePrefix(false), queueSize.getName())),
        queueSize);
    Assert.assertEquals(queueSize.getContext(), this.context);
    Assert.assertEquals(queueSize.getName(), QUEUE_SIZE);

    Assert.assertTrue(queueSize.getTags().isEmpty());
    queueSize.addTag(new Tag<String>(METRIC_GROUP_KEY, INPUT_RECORDS_GROUP));
    Assert.assertEquals(queueSize.getTags().size(), 1);
    Assert.assertEquals(queueSize.getTags().get(0).getKey(), METRIC_GROUP_KEY);
    Assert.assertEquals(queueSize.getTags().get(0).getValue(), INPUT_RECORDS_GROUP);
    Assert.assertEquals(
        queueSize.getFullyQualifiedName(false),
        MetricRegistry.name(INPUT_RECORDS_GROUP, QUEUE_SIZE));
  }
Ejemplo n.º 2
0
  @Test
  public void testTaggableGauge() {
    ContextAwareGauge<Long> queueSize =
        this.context.newContextAwareGauge(
            QUEUE_SIZE,
            new Gauge<Long>() {
              @Override
              public Long getValue() {
                return 1000l;
              }
            });
    this.context.register(QUEUE_SIZE, queueSize);

    Assert.assertEquals(queueSize.getValue().longValue(), 1000l);

    Assert.assertEquals(
        this.context.getGauges().get(queueSize.getName()), queueSize.getInnerMetric());
    Assert.assertEquals(queueSize.getContext(), this.context);
    Assert.assertEquals(queueSize.getName(), QUEUE_SIZE);
  }