Skip to content

Commit 8318d03

Browse files
committed
COH-29603 -Add options to each of the TracingShimLoader implementations (OpenTracing and OTel) to disable one of them in case both runtimes are available on the classpath (merge main -> ce/main @ 108073)
[git-p4: depot-paths = "//dev/coherence-ce/main/": change = 108117]
1 parent bc6efe7 commit 8318d03

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

prj/coherence-tracing/opentelemetry/src/main/java/com/tangosol/internal/tracing/opentelemetry/OpenTelemetryShimLoader.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import com.oracle.coherence.common.base.Logger;
1010

11+
import com.tangosol.coherence.config.Config;
1112
import com.tangosol.internal.tracing.TracingShim;
1213
import com.tangosol.internal.tracing.TracingShimLoader;
1314

@@ -40,7 +41,14 @@ public class OpenTelemetryShimLoader
4041
@Override
4142
public TracingShim loadTracingShim()
4243
{
43-
return ensureDependenciesPresent() ? new OpenTelemetryShim() : TracingShim.Noop.INSTANCE;
44+
if (ENABLED)
45+
{
46+
return ensureDependenciesPresent()
47+
? new OpenTelemetryShim()
48+
: TracingShim.Noop.INSTANCE;
49+
}
50+
51+
return null;
4452
}
4553

4654
// ----- helper methods -------------------------------------------------
@@ -113,6 +121,12 @@ protected boolean ensureClassPresent(String sClassName, ClassLoader classLoader)
113121
"io.opentelemetry.context.Context", "opentelemetry-context",
114122
"io.opentelemetry.sdk.OpenTelemetrySdk", "opentracing-util");
115123

124+
/**
125+
* A flag that allows the explicit disabling of OpenTelemetry.
126+
*/
127+
protected static final boolean ENABLED =
128+
Config.getBoolean("com.oracle.coherence.opentelemetry.enabled", true);
129+
116130
// ----- inner class: Noops ---------------------------------------------
117131
/**
118132
* Utility class for determining what OpenTelemetry types are Noop types.

prj/coherence-tracing/opentracing/src/main/java/com/tangosol/internal/tracing/opentracing/OpenTracingShimLoader.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import com.oracle.coherence.common.base.Logger;
1010

11+
import com.tangosol.coherence.config.Config;
1112
import com.tangosol.internal.tracing.TracingShim;
1213
import com.tangosol.internal.tracing.TracingShimLoader;
1314

@@ -35,7 +36,14 @@ public class OpenTracingShimLoader
3536
@Override
3637
public TracingShim loadTracingShim()
3738
{
38-
return ensureDependenciesPresent() ? new OpenTracingShim() : TracingShim.Noop.INSTANCE;
39+
if (ENABLED)
40+
{
41+
return ensureDependenciesPresent()
42+
? new OpenTracingShim()
43+
: TracingShim.Noop.INSTANCE;
44+
}
45+
46+
return null;
3947
}
4048

4149
// ----- helper methods -------------------------------------------------
@@ -129,4 +137,10 @@ protected boolean ensureClassPresent(String sClassName, ClassLoader classLoader)
129137
put("io.opentracing.contrib.tracerresolver.TracerResolver", "opentracing-tracerresolver");
130138
}
131139
});
140+
141+
/**
142+
* A flag that allows the explicit disabling of OpenTracing.
143+
*/
144+
protected static final boolean ENABLED =
145+
Config.getBoolean("com.oracle.coherence.opentracing.enabled", true);
132146
}

0 commit comments

Comments
 (0)