/** * Returns an instance that contains no-op implementations for all the instances. * * @return an instance that contains no-op implementations for all the instances. */ static MetricsComponent newNoopMetricsComponent() { return new NoopMetricsComponent(); }
/** * Creates a {@link LabelKey}. * * @param key the key of a {@code Label}. * @param description a human-readable description of what this label key represents. * @return a {@code LabelKey}. * @since 0.17 */ public static LabelKey create(String key, String description) { return new AutoValue_LabelKey(key, description); }
/** * Returns the no-op implementation of the {@code DoubleGauge}. * * @return the no-op implementation of the {@code DoubleGauge}. * @since 0.17 */ static DoubleGauge newNoopDoubleGauge( String name, String description, String unit, List<LabelKey> labelKeys) { return NoopDoubleGauge.create(name, description, unit, labelKeys); }
@Test public void noopInstanceOf() { assertThat(metricRegistry.addLongGauge(NAME, DESCRIPTION, UNIT, LABEL_KEY)) .isInstanceOf(LongGauge.newNoopLongGauge(NAME, DESCRIPTION, UNIT, LABEL_KEY).getClass()); assertThat(metricRegistry.addDoubleGauge(NAME_2, DESCRIPTION, UNIT, LABEL_KEY)) .isInstanceOf( DoubleGauge.newNoopDoubleGauge(NAME_2, DESCRIPTION, UNIT, LABEL_KEY).getClass()); assertThat(metricRegistry.addDerivedLongGauge(NAME_3, DESCRIPTION, UNIT, LABEL_KEY)) .isInstanceOf( DerivedLongGauge.newNoopDerivedLongGauge(NAME_3, DESCRIPTION, UNIT, LABEL_KEY) .getClass()); assertThat(metricRegistry.addDerivedDoubleGauge(NAME_4, DESCRIPTION, UNIT, LABEL_KEY)) .isInstanceOf( DerivedDoubleGauge.newNoopDerivedDoubleGauge(NAME_4, DESCRIPTION, UNIT, LABEL_KEY) .getClass()); } }
@Test public void noopSameAs() { LongGauge longGauge = metricRegistry.addLongGauge(NAME, DESCRIPTION, UNIT, LABEL_KEY); assertThat(longGauge.getDefaultTimeSeries()).isSameAs(longGauge.getDefaultTimeSeries()); assertThat(longGauge.getDefaultTimeSeries()) .isSameAs(longGauge.getOrCreateTimeSeries(LABEL_VALUES)); DoubleGauge doubleGauge = metricRegistry.addDoubleGauge(NAME_2, DESCRIPTION, UNIT, LABEL_KEY); assertThat(doubleGauge.getDefaultTimeSeries()).isSameAs(doubleGauge.getDefaultTimeSeries()); assertThat(doubleGauge.getDefaultTimeSeries()) .isSameAs(doubleGauge.getOrCreateTimeSeries(LABEL_VALUES)); }
/** * Returns the global {@link ExportComponent}. * * @return the global {@code ExportComponent}. * @since 0.17 */ public static ExportComponent getExportComponent() { return metricsComponent.getExportComponent(); }
/** * Returns the global {@link MetricRegistry}. * * <p>This {@code MetricRegistry} is already added to the global {@link * io.opencensus.metrics.export.MetricProducerManager}. * * @return the global {@code MetricRegistry}. * @since 0.17 */ public static MetricRegistry getMetricRegistry() { return metricsComponent.getMetricRegistry(); }
@Override public DoubleGauge addDoubleGauge( String name, String description, String unit, List<LabelKey> labelKeys) { Utils.checkListElementNotNull(Utils.checkNotNull(labelKeys, "labelKeys"), "labelKey"); return DoubleGauge.newNoopDoubleGauge( Utils.checkNotNull(name, "name"), Utils.checkNotNull(description, "description"), Utils.checkNotNull(unit, "unit"), labelKeys); }
@Override public DerivedLongGauge addDerivedLongGauge( String name, String description, String unit, List<LabelKey> labelKeys) { Utils.checkListElementNotNull(Utils.checkNotNull(labelKeys, "labelKeys"), "labelKey"); return DerivedLongGauge.newNoopDerivedLongGauge( Utils.checkNotNull(name, "name"), Utils.checkNotNull(description, "description"), Utils.checkNotNull(unit, "unit"), labelKeys); }
@Override public DerivedDoubleGauge addDerivedDoubleGauge( String name, String description, String unit, List<LabelKey> labelKeys) { Utils.checkListElementNotNull(Utils.checkNotNull(labelKeys, "labelKeys"), "labelKey"); return DerivedDoubleGauge.newNoopDerivedDoubleGauge( Utils.checkNotNull(name, "name"), Utils.checkNotNull(description, "description"), Utils.checkNotNull(unit, "unit"), labelKeys); } }
@Override public LongGauge addLongGauge( String name, String description, String unit, List<LabelKey> labelKeys) { Utils.checkListElementNotNull(Utils.checkNotNull(labelKeys, "labelKeys"), "labelKey"); return LongGauge.newNoopLongGauge( Utils.checkNotNull(name, "name"), Utils.checkNotNull(description, "description"), Utils.checkNotNull(unit, "unit"), labelKeys); }
/** * Returns the no-op implementation of the {@code LongGauge}. * * @return the no-op implementation of the {@code LongGauge}. * @since 0.17 */ static LongGauge newNoopLongGauge( String name, String description, String unit, List<LabelKey> labelKeys) { return NoopLongGauge.create(name, description, unit, labelKeys); }
/** * Returns the no-op implementation of the {@code DerivedLongGauge}. * * @return the no-op implementation of the {@code DerivedLongGauge}. * @since 0.17 */ static DerivedLongGauge newNoopDerivedLongGauge( String name, String description, String unit, List<LabelKey> labelKeys) { return NoopDerivedLongGauge.create(name, description, unit, labelKeys); }
/** * Returns the no-op implementation of the {@code DerivedDoubleGauge}. * * @return the no-op implementation of the {@code DerivedDoubleGauge}. * @since 0.17 */ static DerivedDoubleGauge newNoopDerivedDoubleGauge( String name, String description, String unit, List<LabelKey> labelKeys) { return NoopDerivedDoubleGauge.create(name, description, unit, labelKeys); }
static NoopDerivedLongGauge create( String name, String description, String unit, List<LabelKey> labelKeys) { return new NoopDerivedLongGauge(name, description, unit, labelKeys); }
static NoopLongGauge create( String name, String description, String unit, List<LabelKey> labelKeys) { return new NoopLongGauge(name, description, unit, labelKeys); }
static NoopDoubleGauge create( String name, String description, String unit, List<LabelKey> labelKeys) { return new NoopDoubleGauge(name, description, unit, labelKeys); }
static NoopDerivedDoubleGauge create( String name, String description, String unit, List<LabelKey> labelKeys) { return new NoopDerivedDoubleGauge(name, description, unit, labelKeys); }
static MetricRegistry newNoopMetricRegistry() { return new NoopMetricRegistry(); }
/** * Creates a {@link LabelValue}. * * @param value the value of a {@code Label}. {@code null} value indicates an unset {@code * LabelValue}. * @return a {@code LabelValue}. * @since 0.17 */ public static LabelValue create(@Nullable String value) { return new AutoValue_LabelValue(value); }