List of usage examples for com.mongodb.event CommandFailedEvent getRequestId
public int getRequestId()
From source file:com.google.cloud.trace.mongodb.TracingCommandListener.java
License:Open Source License
public void commandFailed(CommandFailedEvent event) { MongoDBCommandTraceContext commandContext = contexts.get(); if (commandContext == null || commandContext.getRequestId() != event.getRequestId()) { // The context doesn't match the requestId for the event so don't make any endSpan() or // annotate() calls. Drop the context since it likely can't be used again. contexts.remove();//from w w w . ja v a2s. c o m return; } Labels.Builder labels = Labels.builder(); labels.add(MongoLabels.STATUS, "FAILURE"); labels.add(MongoLabels.ERROR, event.getThrowable().getMessage()); 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 commandFailed(CommandFailedEvent event) { Span span = cache.remove(event.getRequestId()); if (span != null) { onError(span, event.getThrowable()); span.finish();/*from w ww . j ava 2 s. co m*/ } }
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(//w ww . j a 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); }