Skip to content

Commit 1c0b641

Browse files
committed
Adding configuration variable
Added configuration variable to toggle between the two map implementations
1 parent ee432c9 commit 1c0b641

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

dd-trace-api/src/main/java/datadog/trace/api/config/GeneralConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,7 @@ public final class GeneralConfig {
100100
public static final String APM_TRACING_ENABLED = "apm.tracing.enabled";
101101
public static final String JDK_SOCKET_ENABLED = "jdk.socket.enabled";
102102

103+
public static final String OPTIMIZED_MAP_ENABLED = "optimized.map.enabled";
104+
103105
private GeneralConfig() {}
104106
}

internal-api/src/main/java/datadog/trace/api/Config.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ public static String getHostName() {
540540
private final boolean longRunningTraceEnabled;
541541
private final long longRunningTraceInitialFlushInterval;
542542
private final long longRunningTraceFlushInterval;
543+
543544
private final boolean cassandraKeyspaceStatementExtractionEnabled;
544545
private final boolean couchbaseInternalSpansEnabled;
545546
private final boolean elasticsearchBodyEnabled;
@@ -576,6 +577,8 @@ public static String getHostName() {
576577

577578
private final boolean jdkSocketEnabled;
578579

580+
private final boolean optimizedMapEnabled;
581+
579582
// Read order: System Properties -> Env Variables, [-> properties file], [-> default value]
580583
private Config() {
581584
this(ConfigProvider.createDefault());
@@ -2027,6 +2030,9 @@ PROFILING_DATADOG_PROFILER_ENABLED, isDatadogProfilerSafeInCurrentEnvironment())
20272030

20282031
this.jdkSocketEnabled = configProvider.getBoolean(JDK_SOCKET_ENABLED, true);
20292032

2033+
this.optimizedMapEnabled =
2034+
configProvider.getBoolean(GeneralConfig.OPTIMIZED_MAP_ENABLED, false);
2035+
20302036
log.debug("New instance: {}", this);
20312037
}
20322038

@@ -3653,6 +3659,10 @@ public boolean isJdkSocketEnabled() {
36533659
return jdkSocketEnabled;
36543660
}
36553661

3662+
public boolean isOptimizedMapEnabled() {
3663+
return optimizedMapEnabled;
3664+
}
3665+
36563666
/** @return A map of tags to be applied only to the local application root span. */
36573667
public TagMap getLocalRootSpanTags() {
36583668
final Map<String, String> runtimeTags = getRuntimeTags();

internal-api/src/main/java/datadog/trace/api/TagMap.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,10 @@ public EntryChange next() {
10561056
* That will allow all of the calls to create methods to be devirtualized without a guard
10571057
*/
10581058
abstract class TagMapFactory<MapT extends TagMap> {
1059-
public static final TagMapFactory<?> INSTANCE = new OptimizedTagMapFactory();
1059+
public static final TagMapFactory<?> INSTANCE =
1060+
Config.get().isOptimizedMapEnabled()
1061+
? new OptimizedTagMapFactory()
1062+
: new LegacyTagMapFactory();
10601063

10611064
public abstract MapT create();
10621065

0 commit comments

Comments
 (0)