Use locale insensitive lower/upper case conversion
MODIFY
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/config/NamingConvention.java
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/config/NamingConvention.java
package io.opentelemetry.instrumentation.api.config;
+import java.util.Locale;
+
// config property names are normalized to underscore separated lowercase words
enum NamingConvention {
DOT {
@Override
public String normalize(String key) {
// many instrumentation names have dashes ('-')
- return key.toLowerCase().replace('-', '.');
+ return key.toLowerCase(Locale.ROOT).replace('-', '.');
}
},
ENV_VAR {
@Override
public String normalize(String key) {
- return key.toLowerCase().replace('_', '.');
+ return key.toLowerCase(Locale.ROOT).replace('_', '.');
}
};

MODIFY
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/db/RedisCommandSanitizer.java
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/db/RedisCommandSanitizer.java
@@ -15,6 +15,7 @@ import io.opentelemetry.instrumentation.api.db.RedisCommandSanitizer.CommandSani
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
/**
@@ -316,7 +317,9 @@ public final class RedisCommandSanitizer {
if (!StatementSanitizationConfig.isStatementSanitizationEnabled()) {
return KeepAllArgs.INSTANCE.sanitize(command, args);
}
- return SANITIZERS.getOrDefault(command.toUpperCase(), DEFAULT).sanitize(command, args);
+ return SANITIZERS
+ .getOrDefault(command.toUpperCase(Locale.ROOT), DEFAULT)
+ .sanitize(command, args);
}
public interface CommandSanitizer {

MODIFY
instrumentation-api/src/main/jflex/SqlSanitizer.flex
instrumentation-api/src/main/jflex/SqlSanitizer.flex
@@ -107,7 +107,7 @@ WHITESPACE = [ \t\r\n]+
}
SqlStatementInfo getResult(String fullStatement) {
- return SqlStatementInfo.create(fullStatement, getClass().getSimpleName().toUpperCase(), mainTable);
+ return SqlStatementInfo.create(fullStatement, getClass().getSimpleName().toUpperCase(java.util.Locale.ROOT), mainTable);
}
}

MODIFY
instrumentation/aws-lambda-1.0/library/src/main/java/io/opentelemetry/instrumentation/awslambda/v1_0/MapUtils.java
instrumentation/aws-lambda-1.0/library/src/main/java/io/opentelemetry/instrumentation/awslambda/v1_0/MapUtils.java
package io.opentelemetry.instrumentation.awslambda.v1_0;
import java.util.Collections;
+import java.util.Locale;
import java.util.Map;
import java.util.stream.Collectors;
@@ -13,7 +14,7 @@ final class MapUtils {
static Map<String, String> lowercaseMap(Map<String, String> source) {
return emptyIfNull(source).entrySet().stream()
.filter(e -> e.getKey() != null)
- .collect(Collectors.toMap(e -> e.getKey().toLowerCase(), Map.Entry::getValue));
+ .collect(Collectors.toMap(e -> e.getKey().toLowerCase(Locale.ROOT), Map.Entry::getValue));
}
static Map<String, String> emptyIfNull(Map<String, String> map) {

MODIFY
instrumentation/aws-lambda-1.0/library/src/main/java/io/opentelemetry/instrumentation/awslambda/v1_0/ParentContextExtractor.java
instrumentation/aws-lambda-1.0/library/src/main/java/io/opentelemetry/instrumentation/awslambda/v1_0/ParentContextExtractor.java
@@ -14,6 +14,7 @@ import io.opentelemetry.context.propagation.TextMapGetter;
import io.opentelemetry.extension.aws.AwsXrayPropagator;
import io.opentelemetry.instrumentation.api.tracer.BaseTracer;
import java.util.Collections;
+import java.util.Locale;
import java.util.Map;
public class ParentContextExtractor {
@@ -69,7 +70,7 @@ public class ParentContextExtractor {
@Override
public String get(Map<String, String> map, String s) {
- return map.get(s.toLowerCase());
+ return map.get(s.toLowerCase(Locale.ROOT));
}
}
}

MODIFY
instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/MethodHandleFactory.java
instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/MethodHandleFactory.java
@@ -7,12 +7,13 @@ package io.opentelemetry.instrumentation.awssdk.v2_2;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
+import java.util.Locale;
import java.util.concurrent.ConcurrentHashMap;
class MethodHandleFactory {
private String lowerCase(String string) {
- return string.substring(0, 1).toLowerCase() + string.substring(1);
+ return string.substring(0, 1).toLowerCase(Locale.ROOT) + string.substring(1);
}
private final ClassValue<ConcurrentHashMap<String, MethodHandle>> getterCache =

MODIFY
instrumentation/jdbc/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jdbc/JdbcConnectionUrlParser.java
instrumentation/jdbc/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jdbc/JdbcConnectionUrlParser.java
@@ -15,6 +15,7 @@ import java.net.URLDecoder;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.regex.Matcher;
@@ -815,7 +816,7 @@ public enum JdbcConnectionUrlParser {
return DEFAULT;
}
// Make this easier and ignore case.
- connectionUrl = connectionUrl.toLowerCase();
+ connectionUrl = connectionUrl.toLowerCase(Locale.ROOT);
if (!connectionUrl.startsWith("jdbc:")) {
return DEFAULT;

MODIFY
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/LoggingConfigurer.java
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/LoggingConfigurer.java
package io.opentelemetry.javaagent.tooling;
+import java.util.Locale;
+
class LoggingConfigurer {
private static final String SIMPLE_LOGGER_SHOW_DATE_TIME_PROPERTY =
@@ -57,7 +59,7 @@ class LoggingConfigurer {
}
String tracerDebugLevelEnv =
- System.getenv(tracerDebugLevelSysprop.replace('.', '_').toUpperCase());
+ System.getenv(tracerDebugLevelSysprop.replace('.', '_').toUpperCase(Locale.ROOT));
if (tracerDebugLevelEnv != null) {
return Boolean.parseBoolean(tracerDebugLevelEnv);

Use locale insensitive lower/upper case conversion (#2838)