Module spring.data.mongodb
Class MongoObservationCommandListener
java.lang.Object
org.springframework.data.mongodb.observability.MongoObservationCommandListener
- All Implemented Interfaces:
com.mongodb.event.CommandListener
public class MongoObservationCommandListener
extends Object
implements com.mongodb.event.CommandListener
Implement MongoDB's
CommandListener using Micrometer's Observation API.- Since:
- 4.0
- Author:
- OpenZipkin Brave Authors, Marcin Grzejszczak, Greg Turnquist, François Kha
-
Constructor Summary
ConstructorsConstructorDescriptionMongoObservationCommandListener(io.micrometer.observation.ObservationRegistry observationRegistry) Create a newMongoObservationCommandListenerto recordObservations.MongoObservationCommandListener(io.micrometer.observation.ObservationRegistry observationRegistry, com.mongodb.ConnectionString connectionString) Create a newMongoObservationCommandListenerto recordObservations.MongoObservationCommandListener(io.micrometer.observation.ObservationRegistry observationRegistry, com.mongodb.ConnectionString connectionString, MongoHandlerObservationConvention observationConvention) Create a newMongoObservationCommandListenerto recordObservations. -
Method Summary
Modifier and TypeMethodDescriptionvoidcommandFailed(com.mongodb.event.CommandFailedEvent event) voidcommandStarted(com.mongodb.event.CommandStartedEvent event) voidcommandSucceeded(com.mongodb.event.CommandSucceededEvent event)
-
Constructor Details
-
MongoObservationCommandListener
public MongoObservationCommandListener(io.micrometer.observation.ObservationRegistry observationRegistry) Create a newMongoObservationCommandListenerto recordObservations.- Parameters:
observationRegistry- must not be null
-
MongoObservationCommandListener
public MongoObservationCommandListener(io.micrometer.observation.ObservationRegistry observationRegistry, @Nullable com.mongodb.ConnectionString connectionString) Create a newMongoObservationCommandListenerto recordObservations. This constructor attaches theConnectionStringto everyObservation.- Parameters:
observationRegistry- must not be nullconnectionString- can be null
-
MongoObservationCommandListener
public MongoObservationCommandListener(io.micrometer.observation.ObservationRegistry observationRegistry, @Nullable com.mongodb.ConnectionString connectionString, MongoHandlerObservationConvention observationConvention) Create a newMongoObservationCommandListenerto recordObservations. This constructor attaches theConnectionStringto everyObservationand uses the givenMongoHandlerObservationConvention.- Parameters:
observationRegistry- must not be nullconnectionString- can be nullobservationConvention- must not be null- Since:
- 4.3
-
-
Method Details
-
commandStarted
public void commandStarted(com.mongodb.event.CommandStartedEvent event) - Specified by:
commandStartedin interfacecom.mongodb.event.CommandListener
-
commandSucceeded
public void commandSucceeded(com.mongodb.event.CommandSucceededEvent event) - Specified by:
commandSucceededin interfacecom.mongodb.event.CommandListener
-
commandFailed
public void commandFailed(com.mongodb.event.CommandFailedEvent event) - Specified by:
commandFailedin interfacecom.mongodb.event.CommandListener
-