Mongodb: avoid duplicate tracing (#6465)
This commit is contained in:
parent
08f013f9d6
commit
b5f49636f2
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue