Example usage for com.mongodb.event CommandSucceededEvent getRequestId

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

Introduction

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

Prototype

public int getRequestId() 

Source Link

Document

Gets the request identifier

Usage

From source file:com.google.cloud.trace.mongodb.TracingCommandListener.java

License:Open Source License

public void commandSucceeded(CommandSucceededEvent event) {
    MongoDBCommandTraceContext commandContext = contexts.get();
    if (commandContext == null || commandContext.getRequestId() != event.getRequestId()) {
        contexts.remove();//  ww w  .  j  a  v a2s  .c om
        return;
    }
    Labels.Builder labels = Labels.builder();
    labels.add(MongoLabels.STATUS, "SUCCESS");
    tracer.annotateSpan(commandContext.getContext(), labels.build());
    tracer.endSpan(commandContext.getContext());
    contexts.remove();
}

From source file:io.opentracing.contrib.mongo.TracingCommandListener.java

License:Apache License

@Override
public void commandSucceeded(CommandSucceededEvent event) {
    Span span = cache.remove(event.getRequestId());
    if (span != null) {
        span.finish();//  w w  w.  j a  va  2 s.  c om
    }
}

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(/*w ww .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);
}