com.mongodb.event.CommandSucceededEvent Java Examples

The following examples show how to use com.mongodb.event.CommandSucceededEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KamonCommandListener.java    From ditto with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void commandSucceeded(final CommandSucceededEvent event) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("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);
}
 
Example #2
Source File: TraceMongoDbAutoConfigurationTests.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
@Override
public void customize(MongoClientSettings.Builder clientSettingsBuilder) {
	super.customize(clientSettingsBuilder);
	CommandListener listener = clientSettingsBuilder.build().getCommandListeners()
			.get(0);
	listener.commandStarted(new CommandStartedEvent(0, null, "", "",
			BDDMockito.mock(BsonDocument.class)));
	listener.commandSucceeded(new CommandSucceededEvent(1, null, "",
			BDDMockito.mock(BsonDocument.class), 100));
}
 
Example #3
Source File: TraceMongoCommandListenerTest.java    From brave with Apache License 2.0 5 votes vote down vote up
CommandSucceededEvent createCommandSucceededEvent() {
  return new CommandSucceededEvent(
    1,
    createConnectionDescription(),
    "insert",
    new BsonDocument(),
    1000
  );
}
 
Example #4
Source File: TraceMongoCommandListener.java    From brave with Apache License 2.0 4 votes vote down vote up
@Override public void commandSucceeded(CommandSucceededEvent event) {
  Span span = threadLocalSpan.remove();
  if (span == null) return;
  span.finish();
}