Skip to content

Commit 02e9926

Browse files
authored
Merge branch 'main' into jmx
2 parents 83bc60f + 47ce3b1 commit 02e9926

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
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
}

awsagentprovider/src/test/java/software/amazon/opentelemetry/javaagent/providers/AwsMetricAttributeGeneratorTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,19 @@ public void testGetDBStatementRemoteOperation() {
632632
mockAttribute(DB_STATEMENT, "SELECT FROM *");
633633
mockAttribute(DB_OPERATION, "DB operation");
634634
validateExpectedRemoteAttributes("DB system", "DB operation");
635+
636+
// Case 10: Duplicate of case 1 with leading whitespace
637+
mockAttribute(DB_SYSTEM, "DB system");
638+
mockAttribute(DB_STATEMENT, " SELECT DB statement");
639+
mockAttribute(DB_OPERATION, null);
640+
validateExpectedRemoteAttributes("DB system", "SELECT");
641+
642+
// Case 11: Duplicate of case 2 with leading whitespace. Test if whitespace affects longest
643+
// match
644+
mockAttribute(DB_SYSTEM, "DB system");
645+
mockAttribute(DB_STATEMENT, " DROP VIEW DB statement");
646+
mockAttribute(DB_OPERATION, null);
647+
validateExpectedRemoteAttributes("DB system", "DROP VIEW");
635648
}
636649

637650
@Test

0 commit comments

Comments
 (0)