io.opencensus.stats.Measure.MeasureDouble Java Examples

The following examples show how to use io.opencensus.stats.Measure.MeasureDouble. 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: ViewManagerImplTest.java    From opencensus-java with Apache License 2.0 5 votes vote down vote up
private static MeasureMap putToMeasureMap(MeasureMap measureMap, Measure measure, double value) {
  if (measure instanceof MeasureDouble) {
    return measureMap.put((MeasureDouble) measure, value);
  } else if (measure instanceof MeasureLong) {
    return measureMap.put((MeasureLong) measure, Math.round(value));
  } else {
    // Future measures.
    throw new AssertionError();
  }
}
 
Example #2
Source File: NoopStats.java    From opencensus-java with Apache License 2.0 5 votes vote down vote up
@Override
public MeasureMap put(MeasureDouble measure, double value) {
  if (value < 0) {
    hasUnsupportedValues = true;
  }
  return this;
}
 
Example #3
Source File: MeasureTest.java    From opencensus-java with Apache License 2.0 5 votes vote down vote up
@Test
public void preventTooLongMeasureName() {
  char[] chars = new char[Measure.NAME_MAX_LENGTH + 1];
  Arrays.fill(chars, 'a');
  String longName = String.valueOf(chars);
  thrown.expect(IllegalArgumentException.class);
  Measure.MeasureDouble.create(longName, "description", "1");
}
 
Example #4
Source File: ViewManagerImplTest.java    From opencensus-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultipleViews_DifferentMeasureTypes() {
  testMultipleViews_DifferentMeasures(
      MeasureDouble.create(MEASURE_NAME, MEASURE_DESCRIPTION, MEASURE_UNIT),
      MeasureLong.create(MEASURE_NAME_2, MEASURE_DESCRIPTION, MEASURE_UNIT),
      1.1,
      5000);
}
 
Example #5
Source File: MeasureTest.java    From opencensus-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testMeasureDoubleComponents() {
  Measure measurement = Measure.MeasureDouble.create("Foo", "The description of Foo", "Mbit/s");
  assertThat(measurement.getName()).isEqualTo("Foo");
  assertThat(measurement.getDescription()).isEqualTo("The description of Foo");
  assertThat(measurement.getUnit()).isEqualTo("Mbit/s");
}
 
Example #6
Source File: MeasureTest.java    From opencensus-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testMeasureDoubleEquals() {
  new EqualsTester()
      .addEqualityGroup(
          Measure.MeasureDouble.create("name", "description", "bit/s"),
          Measure.MeasureDouble.create("name", "description", "bit/s"))
      .addEqualityGroup(Measure.MeasureDouble.create("name", "description 2", "bit/s"))
      .testEquals();
}
 
Example #7
Source File: ViewManagerImplTest.java    From opencensus-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultipleViews_DifferentMeasureNames() {
  testMultipleViews_DifferentMeasures(
      MeasureDouble.create(MEASURE_NAME, MEASURE_DESCRIPTION, MEASURE_UNIT),
      MeasureDouble.create(MEASURE_NAME_2, MEASURE_DESCRIPTION, MEASURE_UNIT),
      1.1,
      2.2);
}
 
Example #8
Source File: ViewManagerImplTest.java    From opencensus-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testRecord_MeasureTypeNotMatch() {
  testRecord_MeasureNotMatch(
      MeasureLong.create(MEASURE_NAME, "measure", MEASURE_UNIT),
      MeasureDouble.create(MEASURE_NAME, "measure", MEASURE_UNIT),
      10.0);
}
 
Example #9
Source File: ViewManagerImplTest.java    From opencensus-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testRecord_MeasureNameNotMatch() {
  testRecord_MeasureNotMatch(
      MeasureDouble.create(MEASURE_NAME, "measure", MEASURE_UNIT),
      MeasureDouble.create(MEASURE_NAME_2, "measure", MEASURE_UNIT),
      10.0);
}
 
Example #10
Source File: ViewManagerImplTest.java    From opencensus-java with Apache License 2.0 5 votes vote down vote up
@Test
public void preventRegisteringDifferentMeasureWithSameName() {
  MeasureDouble measure1 = MeasureDouble.create("measure", "description", "1");
  MeasureLong measure2 = MeasureLong.create("measure", "description", "1");
  View view1 =
      View.create(
          VIEW_NAME, VIEW_DESCRIPTION, measure1, DISTRIBUTION, Arrays.asList(KEY), CUMULATIVE);
  View view2 =
      View.create(
          VIEW_NAME_2, VIEW_DESCRIPTION, measure2, DISTRIBUTION, Arrays.asList(KEY), CUMULATIVE);
  testFailedToRegisterView(
      view1, view2, "A different measure with the same name is already registered");
}
 
Example #11
Source File: MeasureMapImpl.java    From opencensus-java with Apache License 2.0 5 votes vote down vote up
@Override
public MeasureMapImpl put(MeasureDouble measure, double value) {
  if (value < 0) {
    hasUnsupportedValues = true;
  }
  builder.put(measure, value);
  return this;
}
 
Example #12
Source File: RecordUtils.java    From opencensus-java with Apache License 2.0 4 votes vote down vote up
@Override
public MutableAggregation apply(MeasureDouble arg) {
  return MutableLastValueDouble.create();
}
 
Example #13
Source File: CensusStatsModule.java    From grpc-java with Apache License 2.0 4 votes vote down vote up
private void recordRealTimeMetric(TagContext ctx, MeasureDouble measure, double value) {
  if (recordRealTimeMetrics) {
    MeasureMap measureMap = statsRecorder.newMeasureMap().put(measure, value);
    measureMap.record(ctx);
  }
}
 
Example #14
Source File: OcAgentMetricsExporterIntegrationTest.java    From opencensus-java with Apache License 2.0 4 votes vote down vote up
private static void recordTaggedStat(TagKey key, String value, MeasureDouble md, double d) {
  TagContext context = tagger.emptyBuilder().put(key, TagValue.create(value)).build();
  statsRecorder.newMeasureMap().put(md, d).record(context);
}
 
Example #15
Source File: ExemplarUtilsTest.java    From opencensus-java with Apache License 2.0 4 votes vote down vote up
@Override
public MeasureMap put(MeasureDouble measure, double value) {
  return this;
}
 
Example #16
Source File: MeasureMapInternalTest.java    From opencensus-java with Apache License 2.0 4 votes vote down vote up
private static MeasureDouble makeSimpleMeasureDouble(String measure) {
  return Measure.MeasureDouble.create(measure, measure + " description", "1");
}
 
Example #17
Source File: Repl.java    From opencensus-java with Apache License 2.0 4 votes vote down vote up
private static void recordTaggedStat(TagKey key, String value, MeasureDouble md, Double d) {
  TagContext tctx = tagger.emptyBuilder().put(key, TagValue.create(value)).build();
  try (Scope ss = tagger.withTagContext(tctx)) {
    statsRecorder.newMeasureMap().put(md, d).record();
  }
}
 
Example #18
Source File: RecordUtils.java    From opencensus-java with Apache License 2.0 4 votes vote down vote up
@Override
public MutableAggregation apply(MeasureDouble arg) {
  return MutableSumDouble.create();
}
 
Example #19
Source File: MeasureTest.java    From opencensus-java with Apache License 2.0 4 votes vote down vote up
@Test
public void testMeasureDoubleIsNotEqualToMeasureLong() {
  assertThat(Measure.MeasureDouble.create("name", "description", "bit/s"))
      .isNotEqualTo(Measure.MeasureLong.create("name", "description", "bit/s"));
}
 
Example #20
Source File: MeasureTest.java    From opencensus-java with Apache License 2.0 4 votes vote down vote up
@Test
public void preventNonPrintableMeasureName() {
  thrown.expect(IllegalArgumentException.class);
  Measure.MeasureDouble.create("\2", "description", "1");
}
 
Example #21
Source File: Measurement.java    From opencensus-java with Apache License 2.0 4 votes vote down vote up
@Override
public abstract MeasureDouble getMeasure();
 
Example #22
Source File: OcAgentExportersQuickStart.java    From opencensus-java with Apache License 2.0 4 votes vote down vote up
private static void recordTaggedStat(TagKey key, String value, MeasureDouble md, double d) {
  TagContext context = tagger.emptyBuilder().put(key, TagValue.create(value)).build();
  statsRecorder.newMeasureMap().put(md, d).record(context);
}
 
Example #23
Source File: MeasureMapInternal.java    From opencensus-java with Apache License 2.0 2 votes vote down vote up
/**
 * Associates the {@link MeasureDouble} with the given value. Subsequent updates to the same
 * {@link MeasureDouble} will overwrite the previous value.
 *
 * @param measure the {@link MeasureDouble}
 * @param value the value to be associated with {@code measure}
 * @return this
 */
Builder put(MeasureDouble measure, double value) {
  measurements.add(Measurement.MeasurementDouble.create(measure, value));
  return this;
}
 
Example #24
Source File: MeasureMap.java    From opencensus-java with Apache License 2.0 2 votes vote down vote up
/**
 * Associates the {@link MeasureDouble} with the given value. Subsequent updates to the same
 * {@link MeasureDouble} will overwrite the previous value.
 *
 * @param measure the {@link MeasureDouble}
 * @param value the value to be associated with {@code measure}
 * @return this
 * @since 0.8
 */
public abstract MeasureMap put(MeasureDouble measure, double value);
 
Example #25
Source File: Measurement.java    From opencensus-java with Apache License 2.0 2 votes vote down vote up
/**
 * Constructs a new {@link MeasurementDouble}.
 *
 * @since 0.8
 */
public static MeasurementDouble create(MeasureDouble measure, double value) {
  return new AutoValue_Measurement_MeasurementDouble(measure, value);
}