Skip to content

Commit cca635d

Browse files
authored
Fix truncation log spamming (#2066)
* Fix truncation log spamming * Fix CI * Better logging for smoke test failures
1 parent a9de263 commit cca635d

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/common/TelemetryTruncation.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ public static String truncateTelemetry(String value, int maxLength, String attri
3737
if (value == null || value.length() <= maxLength) {
3838
return value;
3939
}
40-
if (!alreadyLoggedAttributeNames.add(attributeName)) {
40+
if (alreadyLoggedAttributeNames.add(attributeName)) {
4141
// this can be expected, so don't want to flood the logs with a lot of these
4242
// (and don't want to log the full value, e.g. sql text > 8192 characters)
4343
logger.warn(
4444
"truncated {} attribute value to {} characters (this message will only be logged once"
45-
+ " per attribute name, and only for at most 10 different attribute names): {}",
45+
+ " per attribute name): {}",
4646
attributeName,
4747
maxLength,
4848
trimTo80(value));
@@ -56,7 +56,7 @@ public static String truncatePropertyValue(String value, int maxLength, String p
5656
if (value == null || value.length() <= maxLength) {
5757
return value;
5858
}
59-
if (alreadyLoggedPropertyKeys.size() < 10 && !alreadyLoggedPropertyKeys.add(propertyKey)) {
59+
if (alreadyLoggedPropertyKeys.size() < 10 && alreadyLoggedPropertyKeys.add(propertyKey)) {
6060
// this can be expected, so don't want to flood the logs with a lot of these
6161
logger.warn(
6262
"truncated {} property value to {} characters (this message will only be logged once"

test/smoke/appServers/Wildfly.11/wildfly11.linux.partial.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN if type "apt-get" > /dev/null; then \
1313
ENV WILDFLY_FULL_VERSION 11.0.0.Final
1414

1515
# install tomcat
16-
RUN wget http://download.jboss.org/wildfly/$WILDFLY_FULL_VERSION/wildfly-$WILDFLY_FULL_VERSION.tar.gz \
16+
RUN wget https://download.jboss.org/wildfly/$WILDFLY_FULL_VERSION/wildfly-$WILDFLY_FULL_VERSION.tar.gz \
1717
&& tar xzvf wildfly-$WILDFLY_FULL_VERSION.tar.gz \
1818
&& mv ./wildfly-$WILDFLY_FULL_VERSION /opt/wildfly-$WILDFLY_FULL_VERSION
1919

test/smoke/framework/testCore/src/main/java/com/microsoft/applicationinsights/smoketest/AiSmokeTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,11 @@ protected static void waitForApplicationToStart() throws Exception {
403403
System.out.println("Test app health check complete.");
404404
waitForHealthCheckTelemetryIfNeeded(contextRootUrl);
405405
} catch (Exception e) {
406-
AiDockerClient.printContainerLogs(containerInfo.getContainerId());
406+
for (ContainerInfo container : allContainers) {
407+
System.out.println("========== dumping container log: " + container.getContainerId());
408+
AiDockerClient.printContainerLogs(containerInfo.getContainerId());
409+
System.out.println("end of container log ==========");
410+
}
407411
throw e;
408412
} finally {
409413
mockedIngestion.resetData();

0 commit comments

Comments
 (0)