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 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, @Nullable 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 - can be null
    • MongoObservationCommandListener

      public MongoObservationCommandListener(io.micrometer.observation.ObservationRegistry observationRegistry, @Nullable com.mongodb.ConnectionString connectionString, MongoHandlerObservationConvention observationConvention)
      Create a new MongoObservationCommandListener to record Observations. This constructor attaches the ConnectionString to every Observation and uses the given MongoHandlerObservationConvention.
      Parameters:
      observationRegistry - must not be null
      connectionString - can be null
      observationConvention - must not be null
      Since:
      4.3
  • 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