Skip to content

Commit c6e03ab

Browse files
authored
Add Extra Unit Test for AwsMetricAttributeGenerator (#903)
*Issue #, if available:* Adding extra unit test to check if leading whitespace in remote operation attributes are removed By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 048535a commit c6e03ab

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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)