Example usage for com.mongodb.event CommandSucceededEvent getElapsedTime

List of usage examples for com.mongodb.event CommandSucceededEvent getElapsedTime

Introduction

In this page you can find the example usage for com.mongodb.event CommandSucceededEvent getElapsedTime.

Prototype

public long getElapsedTime(final TimeUnit timeUnit) 

Source Link

Document

Gets the elapsed time in the given unit of time.

Usage

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

License:Open Source License

@Override
public void commandSucceeded(final CommandSucceededEvent event) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(//  www .  j a va2 s . c o m
                "Successfully executed command '{}' with id {} "
                        + "on connection '{}' to server '{}' after {}ms",
                event.getCommandName(), event.getRequestId(),
                event.getConnectionDescription().getConnectionId(),
                event.getConnectionDescription().getServerAddress(),
                event.getElapsedTime(TimeUnit.MILLISECONDS));
    }

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