-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support non-string type telemetry processor attributes (#3388)
- Loading branch information
Showing
6 changed files
with
265 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...m/microsoft/applicationinsights/smoketest/TelemetryProcessorsNonStringAttributesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.microsoft.applicationinsights.smoketest; | ||
|
||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_11; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_11_OPENJ9; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_17; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_19; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_20; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_8; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_8_OPENJ9; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.WILDFLY_13_JAVA_8; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.WILDFLY_13_JAVA_8_OPENJ9; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.Map; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
@UseAgent("applicationinsights-non-string-span-attributes.json") | ||
abstract class TelemetryProcessorsNonStringAttributesTest { | ||
|
||
@RegisterExtension static final SmokeTestExtension testing = SmokeTestExtension.create(); | ||
|
||
@Test | ||
@TargetUri("/test-non-string-strict-span-attributes") | ||
void testNonStringStrictSpanAttributes() throws Exception { | ||
Telemetry telemetry = testing.getTelemetry(0); | ||
Map<String, String> properties = telemetry.rd.getProperties(); | ||
|
||
assertThat(properties.get("myLongAttributeKey")).isEqualTo("1234"); | ||
assertThat(properties.get("myBooleanAttributeKey")).isEqualTo("true"); | ||
assertThat(properties.get("myDoubleArrayAttributeKey")).contains("1.0", "2.0", "3.0", "4.0"); | ||
assertThat(properties.get("myNewAttributeKeyStrict")).isEqualTo("myNewAttributeValueStrict"); | ||
} | ||
|
||
@Test | ||
@TargetUri("/test-non-string-regex-span-attributes") | ||
void testNonStringRegexSpanAttributes() throws Exception { | ||
Telemetry telemetry = testing.getTelemetry(0); | ||
Map<String, String> properties = telemetry.rd.getProperties(); | ||
|
||
assertThat(properties.get("myLongRegexAttributeKey")).isEqualTo("428"); | ||
assertThat(properties.get("myNewAttributeKeyRegex")).isEqualTo("myNewAttributeValueRegex"); | ||
} | ||
|
||
@Environment(TOMCAT_8_JAVA_8) | ||
static class Tomcat8Java8Test extends TelemetryProcessorsNonStringAttributesTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_8_OPENJ9) | ||
static class Tomcat8Java8OpenJ9Test extends TelemetryProcessorsNonStringAttributesTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_11) | ||
static class Tomcat8Java11Test extends TelemetryProcessorsNonStringAttributesTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_11_OPENJ9) | ||
static class Tomcat8Java11OpenJ9Test extends TelemetryProcessorsNonStringAttributesTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_17) | ||
static class Tomcat8Java17Test extends TelemetryProcessorsNonStringAttributesTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_19) | ||
static class Tomcat8Java19Test extends TelemetryProcessorsNonStringAttributesTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_20) | ||
static class Tomcat8Java20Test extends TelemetryProcessorsNonStringAttributesTest {} | ||
|
||
@Environment(WILDFLY_13_JAVA_8) | ||
static class Wildfly13Java8Test extends TelemetryProcessorsNonStringAttributesTest {} | ||
|
||
@Environment(WILDFLY_13_JAVA_8_OPENJ9) | ||
static class Wildfly13Java8OpenJ9Test extends TelemetryProcessorsNonStringAttributesTest {} | ||
} |
66 changes: 66 additions & 0 deletions
66
...tryProcessors/src/smokeTest/resources/applicationinsights-non-string-span-attributes.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"role": { | ||
"name": "testrolename", | ||
"instance": "testroleinstance" | ||
}, | ||
"sampling": { | ||
"percentage": 100 | ||
}, | ||
"preview": { | ||
"processors": [ | ||
{ | ||
"type": "attribute", | ||
"include": { | ||
"matchType": "strict", | ||
"attributes": [ | ||
{ | ||
"key": "myLongAttributeKey", | ||
"value": 1234, | ||
"type": "long" | ||
}, | ||
{ | ||
"key": "myBooleanAttributeKey", | ||
"value": true, | ||
"type": "boolean" | ||
}, | ||
{ | ||
"key": "myDoubleArrayAttributeKey", | ||
"value": [1.0, 2.0, 3.0, 4.0], | ||
"type": "double-array" | ||
} | ||
] | ||
}, | ||
"actions": [ | ||
{ | ||
"key": "myNewAttributeKeyStrict", | ||
"value": "myNewAttributeValueStrict", | ||
"action": "insert" | ||
} | ||
], | ||
"id": "attributes/insertMyNewAttributeKeyStrict" | ||
}, | ||
{ | ||
"type": "attribute", | ||
"include": { | ||
"matchType": "regexp", | ||
"attributes": [ | ||
{ | ||
"key": "myLongRegexAttributeKey", | ||
"value": "4[0-9][0-9]", | ||
"type": "long" | ||
} | ||
] | ||
}, | ||
"actions": [ | ||
{ | ||
"key": "myNewAttributeKeyRegex", | ||
"value": "myNewAttributeValueRegex", | ||
"action": "insert" | ||
} | ||
], | ||
"id": "attributes/insertMyNewAttributeKeyRegex" | ||
} | ||
] | ||
} | ||
} | ||
|