|
|
|
|
@ -20,6 +20,7 @@ import static org.mockito.Mockito.*;
@@ -20,6 +20,7 @@ import static org.mockito.Mockito.*;
|
|
|
|
|
|
|
|
|
|
import io.micrometer.common.KeyValues; |
|
|
|
|
import io.micrometer.core.instrument.MeterRegistry; |
|
|
|
|
import io.micrometer.core.instrument.Tags; |
|
|
|
|
import io.micrometer.core.instrument.observation.DefaultMeterObservationHandler; |
|
|
|
|
import io.micrometer.core.instrument.simple.SimpleMeterRegistry; |
|
|
|
|
import io.micrometer.observation.Observation; |
|
|
|
|
@ -98,6 +99,20 @@ class MongoObservationCommandListenerTests {
@@ -98,6 +99,20 @@ class MongoObservationCommandListenerTests {
|
|
|
|
|
assertThat(meterRegistry).hasMeterWithName("spring.data.mongodb.command.active"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void commandStartedShouldIncludeCollectionIfMissing() { |
|
|
|
|
|
|
|
|
|
// when
|
|
|
|
|
listener.commandStarted(new CommandStartedEvent(new MapRequestContext(), 0, 0, null, "some name", "hello", null)); |
|
|
|
|
|
|
|
|
|
// then
|
|
|
|
|
// although command 'hello' is collection-less, metric must have tag "db.mongodb.collection"
|
|
|
|
|
assertThat(meterRegistry).hasMeterWithNameAndTags( |
|
|
|
|
"spring.data.mongodb.command.active", |
|
|
|
|
Tags.of("db.mongodb.collection", "none")); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void successfullyCompletedCommandShouldCreateTimerWhenParentSampleInRequestContext() { |
|
|
|
|
|
|
|
|
|
|