com.mongodb.event.CommandListener Java Examples

The following examples show how to use com.mongodb.event.CommandListener. 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: MongoClientWrapper.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public MongoClientWrapperBuilder addCommandListener(@Nullable final CommandListener commandListener) {
    if (null != commandListener) {
        mongoClientSettingsBuilder.addCommandListener(commandListener);
    }
    return this;
}
 
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: MongoDBTracingTest.java    From brave with Apache License 2.0 5 votes vote down vote up
@Test public void commandListener_returnsTraceMongoCommandListener() {
  Tracer tracer = mock(Tracer.class);
  when(tracing.tracer()).thenReturn(tracer);

  CommandListener listener = MongoDBTracing.newBuilder(tracing).build().commandListener();
  assertThat(listener).isInstanceOf(TraceMongoCommandListener.class);
  assertThat(listener).extracting("threadLocalSpan").extracting("tracer").isEqualTo(tracer);
}
 
Example #4
Source File: SearchRootActor.java    From ditto with Eclipse Public License 2.0 4 votes vote down vote up
@Nullable
private static CommandListener getCommandListenerOrNull(final MongoDbConfig.MonitoringConfig monitoringConfig) {
    return monitoringConfig.isCommandsEnabled() ? new KamonCommandListener(KAMON_METRICS_PREFIX) : null;
}
 
Example #5
Source File: SearchUpdaterRootActor.java    From ditto with Eclipse Public License 2.0 4 votes vote down vote up
@Nullable
private static CommandListener getCommandListenerOrNull(final MongoDbConfig.MonitoringConfig monitoringConfig) {
    return monitoringConfig.isCommandsEnabled() ? new KamonCommandListener(KAMON_METRICS_PREFIX) : null;
}
 
Example #6
Source File: MongoDBTracing.java    From brave with Apache License 2.0 4 votes vote down vote up
public CommandListener commandListener() {
  return new TraceMongoCommandListener(this);
}
 
Example #7
Source File: DittoMongoClientBuilder.java    From ditto with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Adds a custom CommandListener.
 *
 * @param commandListener the listener to be added.
 * @return this builder instance to allow method chaining.
 */
GeneralPropertiesStep addCommandListener(@Nullable CommandListener commandListener);