Class DefaultMongoCommandTagsProvider

java.lang.Object
io.micrometer.core.instrument.binder.mongodb.DefaultMongoCommandTagsProvider
All Implemented Interfaces:
MongoCommandTagsProvider

public class DefaultMongoCommandTagsProvider extends Object implements MongoCommandTagsProvider
Default implementation for MongoCommandTagsProvider.
Since:
1.7.0
  • Constructor Details

    • DefaultMongoCommandTagsProvider

      public DefaultMongoCommandTagsProvider()
  • Method Details

    • commandTags

      public Iterable<Tag> commandTags(com.mongodb.event.CommandEvent event)
      Description copied from interface: MongoCommandTagsProvider
      Provides tags to be associated with metrics for the given Mongo command.
      Specified by:
      commandTags in interface MongoCommandTagsProvider
      Parameters:
      event - event representing the issued command
      Returns:
      tags to associate with metrics recorded for the command
    • commandStarted

      public void commandStarted(com.mongodb.event.CommandStartedEvent event)
      Description copied from interface: MongoCommandTagsProvider
      Signals that a command has started and is a chance for implementations to prepare or do any necessary pre-processing.
      Specified by:
      commandStarted in interface MongoCommandTagsProvider
      Parameters:
      event - event representing the issued command
    • determineCollectionName

      protected Optional<String> determineCollectionName(String commandName, org.bson.BsonDocument command)
      Attempts to determine the name of the collection a command is operating on.

      Because some commands either do not have collection info or it is problematic to determine the collection info, there is an allow list of command names COMMANDS_WITH_COLLECTION_NAME used. If commandName is not in the allow list or there is no collection info in command, it will use the content of the 'collection' field on command, if it exists.

      Taken from TraceMongoCommandListener.java in Brave

      Parameters:
      commandName - name of the mongo command
      command - mongo command object
      Returns:
      optional collection name or empty if could not be determined or not in the allow list of command names