Mongodb: avoid duplicate tracing (#6465)

This commit is contained in:
Lauri Tulmin 2022-08-12 18:41:18 +03:00 committed by GitHub
parent 08f013f9d6
commit b5f49636f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 20 additions and 4 deletions

View File

@ -66,7 +66,7 @@ public class MongoClientInstrumentationModule extends InstrumentationModule {
@Advice.This MongoClientOptions.Builder builder,
@Advice.FieldValue("commandListeners") List<CommandListener> commandListeners) {
for (CommandListener commandListener : commandListeners) {
if (commandListener == MongoInstrumentationSingletons.LISTENER) {
if (MongoInstrumentationSingletons.isTracingListener(commandListener)) {
return;
}
}

View File

@ -14,5 +14,9 @@ public final class MongoInstrumentationSingletons {
public static final CommandListener LISTENER =
MongoTelemetry.create(GlobalOpenTelemetry.get()).newCommandListener();
public static boolean isTracingListener(CommandListener listener) {
return listener.getClass().getName().equals(LISTENER.getClass().getName());
}
private MongoInstrumentationSingletons() {}
}

View File

@ -49,7 +49,7 @@ final class MongoClientSettingsBuilderInstrumentation implements TypeInstrumenta
@Advice.This MongoClientSettings.Builder builder,
@Advice.FieldValue("commandListeners") List<CommandListener> commandListeners) {
for (CommandListener commandListener : commandListeners) {
if (commandListener == MongoInstrumentationSingletons.LISTENER) {
if (MongoInstrumentationSingletons.isTracingListener(commandListener)) {
return;
}
}

View File

@ -14,5 +14,9 @@ public final class MongoInstrumentationSingletons {
public static final CommandListener LISTENER =
MongoTelemetry.create(GlobalOpenTelemetry.get()).newCommandListener();
public static boolean isTracingListener(CommandListener listener) {
return listener.getClass().getName().equals(LISTENER.getClass().getName());
}
private MongoInstrumentationSingletons() {}
}

View File

@ -49,7 +49,7 @@ final class MongoClientSettingsBuilderInstrumentation implements TypeInstrumenta
@Advice.This MongoClientSettings.Builder builder,
@Advice.FieldValue("commandListeners") List<CommandListener> commandListeners) {
for (CommandListener commandListener : commandListeners) {
if (commandListener == MongoInstrumentationSingletons.LISTENER) {
if (MongoInstrumentationSingletons.isTracingListener(commandListener)) {
return;
}
}

View File

@ -14,5 +14,9 @@ public final class MongoInstrumentationSingletons {
public static final CommandListener LISTENER =
MongoTelemetry.create(GlobalOpenTelemetry.get()).newCommandListener();
public static boolean isTracingListener(CommandListener listener) {
return listener.getClass().getName().equals(LISTENER.getClass().getName());
}
private MongoInstrumentationSingletons() {}
}

View File

@ -51,7 +51,7 @@ final class MongoClientSettingsBuildersInstrumentation implements TypeInstrument
@Advice.This MongoClientSettings.Builder builder,
@Advice.FieldValue("commandListeners") List<CommandListener> commandListeners) {
for (CommandListener commandListener : commandListeners) {
if (commandListener == MongoInstrumentationSingletons.LISTENER) {
if (MongoInstrumentationSingletons.isTracingListener(commandListener)) {
return;
}
}

View File

@ -14,5 +14,9 @@ public final class MongoInstrumentationSingletons {
public static final CommandListener LISTENER =
MongoTelemetry.create(GlobalOpenTelemetry.get()).newCommandListener();
public static boolean isTracingListener(CommandListener listener) {
return listener.getClass().getName().equals(LISTENER.getClass().getName());
}
private MongoInstrumentationSingletons() {}
}