Class MongoObservationCommandListener
java.lang.Object
org.springframework.data.mongodb.observability.MongoObservationCommandListener
- All Implemented Interfaces:
CommandListener
Implement MongoDB's
CommandListener using Micrometer's Observation API.
NOTE: MongoDB Java Driver 5.7+ comes with observability directly built in which can be configured
via MongoClientSettings.Builder#observabilitySettings(ObservabilitySettings).
We recommend switching to the driver native observability.
- Since:
- 4.0
- Author:
- OpenZipkin Brave Authors, Marcin Grzejszczak, Greg Turnquist, François Kha
-
Constructor Summary
ConstructorsConstructorDescriptionMongoObservationCommandListener(ObservationRegistry observationRegistry) Create a newMongoObservationCommandListenerto recordObservations.MongoObservationCommandListener(ObservationRegistry observationRegistry, @Nullable ConnectionString connectionString) Create a newMongoObservationCommandListenerto recordObservations.MongoObservationCommandListener(ObservationRegistry observationRegistry, @Nullable ConnectionString connectionString, MongoHandlerObservationConvention observationConvention) Create a newMongoObservationCommandListenerto recordObservations. -
Method Summary
-
Constructor Details
-
MongoObservationCommandListener
Create a newMongoObservationCommandListenerto recordObservations.- Parameters:
observationRegistry- must not be null
-
MongoObservationCommandListener
public MongoObservationCommandListener(ObservationRegistry observationRegistry, @Nullable ConnectionString connectionString) Create a newMongoObservationCommandListenerto recordObservations. This constructor attaches theConnectionStringto everyObservation.- Parameters:
observationRegistry- must not be nullconnectionString- can be null
-
MongoObservationCommandListener
public MongoObservationCommandListener(ObservationRegistry observationRegistry, @Nullable 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
- Specified by:
commandStartedin interfaceCommandListener
-
commandSucceeded
- Specified by:
commandSucceededin interfaceCommandListener
-
commandFailed
- Specified by:
commandFailedin interfaceCommandListener
-