Class DefaultMongoCommandTagsProvider
java.lang.Object
io.micrometer.core.instrument.binder.mongodb.DefaultMongoCommandTagsProvider
- All Implemented Interfaces:
MongoCommandTagsProvider
Default implementation for
MongoCommandTagsProvider
.- Since:
- 1.7.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
commandStarted
(com.mongodb.event.CommandStartedEvent event) Signals that a command has started and is a chance for implementations to prepare or do any necessary pre-processing.commandTags
(com.mongodb.event.CommandEvent event) Provides tags to be associated with metrics for the given Mongo command.determineCollectionName
(String commandName, org.bson.BsonDocument command) Attempts to determine the name of the collection a command is operating on.
-
Constructor Details
-
DefaultMongoCommandTagsProvider
public DefaultMongoCommandTagsProvider()
-
-
Method Details
-
commandTags
Description copied from interface:MongoCommandTagsProvider
Provides tags to be associated with metrics for the given Mongo command.- Specified by:
commandTags
in interfaceMongoCommandTagsProvider
- 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 interfaceMongoCommandTagsProvider
- 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. IfcommandName
is not in the allow list or there is no collection info incommand
, it will use the content of the'collection'
field oncommand
, if it exists.Taken from TraceMongoCommandListener.java in Brave
- Parameters:
commandName
- name of the mongo commandcommand
- mongo command object- Returns:
- optional collection name or empty if could not be determined or not in the allow list of command names
-