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
  • Constructor Details

    • MongoObservationCommandListener

      public MongoObservationCommandListener(io.micrometer.observation.ObservationRegistry observationRegistry)
      Create a new MongoObservationCommandListener to record Observations.
      Parameters:
      observationRegistry - must not be null
    • MongoObservationCommandListener

      public MongoObservationCommandListener(io.micrometer.observation.ObservationRegistry observationRegistry, com.mongodb.ConnectionString connectionString)
      Create a new MongoObservationCommandListener to record Observations. This constructor attaches the ConnectionString to every Observation.
      Parameters:
      observationRegistry - must not be null
      connectionString - must not be null
  • Method Details

    • commandStarted

      public void commandStarted(com.mongodb.event.CommandStartedEvent event)
      Specified by:
      commandStarted in interface com.mongodb.event.CommandListener
    • commandSucceeded

      public void commandSucceeded(com.mongodb.event.CommandSucceededEvent event)
      Specified by:
      commandSucceeded in interface com.mongodb.event.CommandListener
    • commandFailed

      public void commandFailed(com.mongodb.event.CommandFailedEvent event)
      Specified by:
      commandFailed in interface com.mongodb.event.CommandListener