Example usage for com.mongodb.event CommandFailedEvent getConnectionDescription

List of usage examples for com.mongodb.event CommandFailedEvent getConnectionDescription

Introduction

In this page you can find the example usage for com.mongodb.event CommandFailedEvent getConnectionDescription.

Prototype

public ConnectionDescription getConnectionDescription() 

Source Link

Document

Gets the description of the connection to which the operation will be sent.

Usage

From source file:org.eclipse.ditto.services.utils.persistence.mongo.monitoring.KamonCommandListener.java

License:Open Source License

@Override
public void commandFailed(final CommandFailedEvent event) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(//from   w ww.ja  v a 2 s.c  o  m
                "Failed execution of command '{}' with id {} "
                        + "on connection '{}' to server '{}'  after {}ms with exception '{}'",
                event.getCommandName(), event.getRequestId(),
                event.getConnectionDescription().getConnectionId(),
                event.getConnectionDescription().getServerAddress(),
                event.getElapsedTime(TimeUnit.MILLISECONDS), event.getThrowable());
    }

    final long elapsedTime = event.getElapsedTime(TimeUnit.NANOSECONDS);
    final String commandName = event.getCommandName();
    recordElapsedTime(elapsedTime, commandName);
}