Skip to content

Commit 47ce3b1

Browse files
authored
Replace stringLeading method with Java 8 friendlty alternative (aws-observability#902)
*Issue #, if available:* The stringLeading method is only available in Java 11+. This doesn't meet our requirement of ADOT Java being available for Java 8+. We need to find an alternative method. *Description of changes:* Refactor code to be Java 8 friendlty *Test run:* https://github.com/aws-observability/aws-otel-java-instrumentation/actions/runs/11158858146 *Note* Previously, the test was failing Java 8 for EKS use case. With this new change, it is passing now. This proves that: 1. The function `getDBStatementRemoteOperation`, specfically `stripLeading()` is being tested by E2E test 2. The new change does not affect Java 11+ and also fixes Java 8 Unit tests also show that combinations of different attributes all pass ([Link](https://github.com/aws-observability/aws-otel-java-instrumentation/blob/main/awsagentprovider/src/test/java/software/amazon/opentelemetry/javaagent/providers/AwsMetricAttributeGeneratorTest.java#L573)) By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent c6e03ab commit 47ce3b1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/AwsMetricAttributeGenerator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ private static String getDBStatementRemoteOperation(
640640

641641
// Remove all whitespace and newline characters from the beginning of remote_operation
642642
// and retrieve the first MAX_KEYWORD_LENGTH characters
643-
remoteOperation = remoteOperation.stripLeading();
643+
remoteOperation = remoteOperation.replaceFirst("^\\s+", "");
644644
if (remoteOperation.length() > MAX_KEYWORD_LENGTH) {
645645
remoteOperation = remoteOperation.substring(0, MAX_KEYWORD_LENGTH);
646646
}

0 commit comments

Comments
 (0)