-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hotfixes for Linux Consumption Plan (#1737)
* Fix verbose logging in Linux Consumption Plan when self diagnostic logging level is updated at runtime * Update java doc * Turn off Quick Pulse when the instrummentation key is null * Update RoleName for Linux Consumption Plan * Fix invalid instrumentation key * Reword * DefaultQuickPulsePingSender * Fix statsbeat is not sent in Linux Consumption Plan * RoleName is used in both header and payload * Turn off azure metadata service on functions and appsvc and AKS * Fix verbose logging * Fix null resourceProviderId for Linux Consumption Plan * Use scheduleWithFixedDelay * Fix a compilation error * Fix failing unit tests * Unify logging configuration a little more * Refactor Co-authored-by: Trask Stalnaker <[email protected]> Co-authored-by: Trask Stalnaker <[email protected]>
- Loading branch information
Showing
12 changed files
with
150 additions
and
71 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
58 changes: 58 additions & 0 deletions
58
...m/microsoft/applicationinsights/agent/internal/wasbootstrap/LoggingLevelConfigurator.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,58 @@ | ||
package com.microsoft.applicationinsights.agent.internal.wasbootstrap; | ||
|
||
import ch.qos.logback.classic.Level; | ||
import ch.qos.logback.classic.Logger; | ||
|
||
import java.util.Locale; | ||
|
||
public class LoggingLevelConfigurator { | ||
|
||
private final Level level; | ||
|
||
public LoggingLevelConfigurator(String levelStr) { | ||
try { | ||
this.level = Level.valueOf(levelStr.toUpperCase(Locale.ROOT)); | ||
} catch (IllegalArgumentException e) { | ||
throw new IllegalStateException("Unexpected self-diagnostic level: " + levelStr); | ||
} | ||
} | ||
|
||
public void updateLoggerLevel(Logger logger) { | ||
Level loggerLevel; | ||
String name = logger.getName(); | ||
if (name.startsWith("org.apache.http")) { | ||
// never want to log apache http at trace or debug, it's just way too verbose | ||
loggerLevel = getAtLeastInfoLevel(level); | ||
} else if (name.startsWith("io.grpc.Context")) { | ||
// never want to log io.grpc.Context at trace or debug, as it logs confusing stack trace that looks like error but isn't | ||
loggerLevel = getAtLeastInfoLevel(level); | ||
} else if (name.startsWith("muzzleMatcher")) { | ||
// muzzleMatcher logs at WARN level, so by default this is OFF, but enabled when DEBUG logging is enabled | ||
loggerLevel = getMuzzleMatcherLevel(level); | ||
} else if (name.startsWith("com.microsoft.applicationinsights")) { | ||
loggerLevel = level; | ||
} else { | ||
loggerLevel = getOtherLibLevel(level); | ||
} | ||
logger.setLevel(loggerLevel); | ||
} | ||
|
||
// never want to log apache http at trace or debug, it's just way to verbose | ||
private static Level getAtLeastInfoLevel(Level level) { | ||
return getMaxLevel(level, Level.INFO); | ||
} | ||
|
||
private static Level getOtherLibLevel(Level level) { | ||
return level == Level.INFO ? Level.WARN : level; | ||
} | ||
|
||
// TODO need something more reliable, currently will log too much WARN if "muzzleMatcher" logger name changes | ||
// muzzleMatcher logs at WARN level in order to make them visible, but really should only be enabled when debugging | ||
private static Level getMuzzleMatcherLevel(Level level) { | ||
return level.toInt() <= Level.DEBUG.toInt() ? level : getMaxLevel(level, Level.ERROR); | ||
} | ||
|
||
private static Level getMaxLevel(Level level1, Level level2) { | ||
return level1.toInt() >= level2.toInt() ? level1 : level2; | ||
} | ||
} |
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
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
Oops, something went wrong.