Search in sources :

Example 1 with WARN

use of org.slf4j.event.Level.WARN in project opentelemetry-java by open-telemetry.

the class SdkMeterTest method testLongHistogram_upperCaseConflict.

@Test
void testLongHistogram_upperCaseConflict() {
    LongHistogram longHistogram = sdkMeter.histogramBuilder("testLongValueRecorder").ofLongs().setDescription("My very own counter").setUnit("metric tonnes").build();
    assertThat(longHistogram).isNotNull();
    assertThat(logs.getEvents()).isEmpty();
    sdkMeter.histogramBuilder("testLongValueRecorder".toUpperCase()).ofLongs().build();
    assertThat(logs.assertContains(loggingEvent -> loggingEvent.getLevel().equals(WARN), "Failed to register metric.").getThrowable()).hasMessageContaining("Metric with same name and different descriptor already created.");
}
Also used : LongCounter(io.opentelemetry.api.metrics.LongCounter) DoubleUpDownCounter(io.opentelemetry.api.metrics.DoubleUpDownCounter) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DoubleHistogram(io.opentelemetry.api.metrics.DoubleHistogram) Test(org.junit.jupiter.api.Test) InMemoryMetricReader(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader) LogCapturer(io.github.netmikey.logunit.api.LogCapturer) MeterSharedState(io.opentelemetry.sdk.metrics.internal.state.MeterSharedState) SuppressLogger(io.opentelemetry.internal.testing.slf4j.SuppressLogger) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) DoubleCounter(io.opentelemetry.api.metrics.DoubleCounter) LongHistogram(io.opentelemetry.api.metrics.LongHistogram) Meter(io.opentelemetry.api.metrics.Meter) WARN(org.slf4j.event.Level.WARN) LongUpDownCounter(io.opentelemetry.api.metrics.LongUpDownCounter) LongHistogram(io.opentelemetry.api.metrics.LongHistogram) Test(org.junit.jupiter.api.Test)

Example 2 with WARN

use of org.slf4j.event.Level.WARN in project opentelemetry-java by open-telemetry.

the class SdkMeterTest method testDoubleUpDownCounter.

@Test
void testDoubleUpDownCounter() {
    DoubleUpDownCounter doubleUpDownCounter = sdkMeter.upDownCounterBuilder("testDoubleUpDownCounter").ofDoubles().setDescription("My very own counter").setUnit("metric tonnes").build();
    assertThat(doubleUpDownCounter).isNotNull();
    // Note: We no longer get the same instrument instance as these instances are lightweight
    // objects backed by storage now.  Here we just make sure it doesn't log an error.
    sdkMeter.upDownCounterBuilder("testDoubleUpDownCounter").ofDoubles().setDescription("My very own counter").setUnit("metric tonnes").build();
    assertThat(logs.getEvents()).isEmpty();
    sdkMeter.upDownCounterBuilder("testDoubleUpDownCounter").ofDoubles().build();
    assertThat(logs.assertContains(loggingEvent -> loggingEvent.getLevel().equals(WARN), "Failed to register metric.").getThrowable()).hasMessageContaining("Metric with same name and different descriptor already created.");
}
Also used : LongCounter(io.opentelemetry.api.metrics.LongCounter) DoubleUpDownCounter(io.opentelemetry.api.metrics.DoubleUpDownCounter) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DoubleHistogram(io.opentelemetry.api.metrics.DoubleHistogram) Test(org.junit.jupiter.api.Test) InMemoryMetricReader(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader) LogCapturer(io.github.netmikey.logunit.api.LogCapturer) MeterSharedState(io.opentelemetry.sdk.metrics.internal.state.MeterSharedState) SuppressLogger(io.opentelemetry.internal.testing.slf4j.SuppressLogger) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) DoubleCounter(io.opentelemetry.api.metrics.DoubleCounter) LongHistogram(io.opentelemetry.api.metrics.LongHistogram) Meter(io.opentelemetry.api.metrics.Meter) WARN(org.slf4j.event.Level.WARN) LongUpDownCounter(io.opentelemetry.api.metrics.LongUpDownCounter) DoubleUpDownCounter(io.opentelemetry.api.metrics.DoubleUpDownCounter) Test(org.junit.jupiter.api.Test)

Example 3 with WARN

use of org.slf4j.event.Level.WARN in project opentelemetry-java by open-telemetry.

the class SdkMeterTest method testLongUpDownCounter.

@Test
void testLongUpDownCounter() {
    LongUpDownCounter longUpDownCounter = sdkMeter.upDownCounterBuilder("testLongUpDownCounter").setDescription("My very own counter").setUnit("metric tonnes").build();
    assertThat(longUpDownCounter).isNotNull();
    // Note: We no longer get the same instrument instance as these instances are lightweight
    // objects backed by storage now.  Here we just make sure it doesn't throw to grab
    // a second instance.
    sdkMeter.upDownCounterBuilder("testLongUpDownCounter").setDescription("My very own counter").setUnit("metric tonnes").build();
    assertThat(logs.getEvents()).isEmpty();
    sdkMeter.upDownCounterBuilder("testLongUpDownCounter").build();
    assertThat(logs.assertContains(loggingEvent -> loggingEvent.getLevel().equals(WARN), "Failed to register metric.").getThrowable()).hasMessageContaining("Metric with same name and different descriptor already created.");
}
Also used : LongCounter(io.opentelemetry.api.metrics.LongCounter) DoubleUpDownCounter(io.opentelemetry.api.metrics.DoubleUpDownCounter) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DoubleHistogram(io.opentelemetry.api.metrics.DoubleHistogram) Test(org.junit.jupiter.api.Test) InMemoryMetricReader(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader) LogCapturer(io.github.netmikey.logunit.api.LogCapturer) MeterSharedState(io.opentelemetry.sdk.metrics.internal.state.MeterSharedState) SuppressLogger(io.opentelemetry.internal.testing.slf4j.SuppressLogger) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) DoubleCounter(io.opentelemetry.api.metrics.DoubleCounter) LongHistogram(io.opentelemetry.api.metrics.LongHistogram) Meter(io.opentelemetry.api.metrics.Meter) WARN(org.slf4j.event.Level.WARN) LongUpDownCounter(io.opentelemetry.api.metrics.LongUpDownCounter) LongUpDownCounter(io.opentelemetry.api.metrics.LongUpDownCounter) Test(org.junit.jupiter.api.Test)

Example 4 with WARN

use of org.slf4j.event.Level.WARN in project opentelemetry-java by open-telemetry.

the class SdkMeterTest method testLongCounter_upperCaseConflict.

@Test
void testLongCounter_upperCaseConflict() {
    LongCounter longCounter = sdkMeter.counterBuilder("testLongCounter").setDescription("My very own counter").setUnit("metric tonnes").build();
    assertThat(longCounter).isNotNull();
    sdkMeter.counterBuilder("testLongCounter".toUpperCase()).build();
    assertThat(logs.assertContains(loggingEvent -> loggingEvent.getLevel().equals(WARN), "Failed to register metric.").getThrowable()).hasMessageContaining("Metric with same name and different descriptor already created.");
}
Also used : LongCounter(io.opentelemetry.api.metrics.LongCounter) DoubleUpDownCounter(io.opentelemetry.api.metrics.DoubleUpDownCounter) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DoubleHistogram(io.opentelemetry.api.metrics.DoubleHistogram) Test(org.junit.jupiter.api.Test) InMemoryMetricReader(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader) LogCapturer(io.github.netmikey.logunit.api.LogCapturer) MeterSharedState(io.opentelemetry.sdk.metrics.internal.state.MeterSharedState) SuppressLogger(io.opentelemetry.internal.testing.slf4j.SuppressLogger) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) DoubleCounter(io.opentelemetry.api.metrics.DoubleCounter) LongHistogram(io.opentelemetry.api.metrics.LongHistogram) Meter(io.opentelemetry.api.metrics.Meter) WARN(org.slf4j.event.Level.WARN) LongUpDownCounter(io.opentelemetry.api.metrics.LongUpDownCounter) LongCounter(io.opentelemetry.api.metrics.LongCounter) Test(org.junit.jupiter.api.Test)

Example 5 with WARN

use of org.slf4j.event.Level.WARN in project opentelemetry-java by open-telemetry.

the class SdkMeterTest method testLongCounter.

@Test
void testLongCounter() {
    LongCounter longCounter = sdkMeter.counterBuilder("testLongCounter").setDescription("My very own counter").setUnit("metric tonnes").build();
    assertThat(longCounter).isNotNull();
    // Note: We no longer get the same instrument instance as these instances are lightweight
    // objects backed by storage now.  Here we just make sure it doesn't log a warning.
    sdkMeter.counterBuilder("testLongCounter").setDescription("My very own counter").setUnit("metric tonnes").build();
    assertThat(logs.getEvents()).isEmpty();
    sdkMeter.counterBuilder("testLongCounter").build();
    assertThat(logs.assertContains(loggingEvent -> loggingEvent.getLevel().equals(WARN), "Failed to register metric.").getThrowable()).hasMessageContaining("Metric with same name and different descriptor already created.");
}
Also used : LongCounter(io.opentelemetry.api.metrics.LongCounter) DoubleUpDownCounter(io.opentelemetry.api.metrics.DoubleUpDownCounter) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DoubleHistogram(io.opentelemetry.api.metrics.DoubleHistogram) Test(org.junit.jupiter.api.Test) InMemoryMetricReader(io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader) LogCapturer(io.github.netmikey.logunit.api.LogCapturer) MeterSharedState(io.opentelemetry.sdk.metrics.internal.state.MeterSharedState) SuppressLogger(io.opentelemetry.internal.testing.slf4j.SuppressLogger) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) DoubleCounter(io.opentelemetry.api.metrics.DoubleCounter) LongHistogram(io.opentelemetry.api.metrics.LongHistogram) Meter(io.opentelemetry.api.metrics.Meter) WARN(org.slf4j.event.Level.WARN) LongUpDownCounter(io.opentelemetry.api.metrics.LongUpDownCounter) LongCounter(io.opentelemetry.api.metrics.LongCounter) Test(org.junit.jupiter.api.Test)

Aggregations

LogCapturer (io.github.netmikey.logunit.api.LogCapturer)9 DoubleCounter (io.opentelemetry.api.metrics.DoubleCounter)9 DoubleHistogram (io.opentelemetry.api.metrics.DoubleHistogram)9 DoubleUpDownCounter (io.opentelemetry.api.metrics.DoubleUpDownCounter)9 LongCounter (io.opentelemetry.api.metrics.LongCounter)9 LongHistogram (io.opentelemetry.api.metrics.LongHistogram)9 LongUpDownCounter (io.opentelemetry.api.metrics.LongUpDownCounter)9 Meter (io.opentelemetry.api.metrics.Meter)9 SuppressLogger (io.opentelemetry.internal.testing.slf4j.SuppressLogger)9 MeterSharedState (io.opentelemetry.sdk.metrics.internal.state.MeterSharedState)9 InMemoryMetricReader (io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader)9 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)9 Test (org.junit.jupiter.api.Test)9 RegisterExtension (org.junit.jupiter.api.extension.RegisterExtension)9 WARN (org.slf4j.event.Level.WARN)9