Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence profiler warning on jdk21 #1470

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,33 @@ public void onStartupFailure(Throwable throwable) {
delegate.onStartupFailure(throwable);
}

private static final String METRICS_RETRY_LOGGER_PROPERTY =
"org.apache.http.impl.execchain.RetryExec";
private static final String LOGGER_PREFIX = "io.opentelemetry.javaagent.slf4j.simpleLogger.log.";

private static void addCustomLoggingConfiguration() {
// metrics exporter sometimes logs "Broken pipe (Write failed)" at INFO; usually in
// docker-based environments
// most likely docker resets long-running connections and the exporter has to retry, and it
// always succeeds after retrying and metrics are exported correctly
// limit default logging level to WARN unless debug mode is on or the user has overridden it
String metricsRetryLoggerLevel = System.getProperty(METRICS_RETRY_LOGGER_PROPERTY);
if (metricsRetryLoggerLevel == null && !isDebugMode()) {
System.setProperty(METRICS_RETRY_LOGGER_PROPERTY, "WARN");
if (!isDebugMode()) {
// metrics exporter sometimes logs "Broken pipe (Write failed)" at INFO; usually in
// docker-based environments
// most likely docker resets long-running connections and the exporter has to retry, and it
// always succeeds after retrying and metrics are exported correctly
// limit default logging level to WARN unless debug mode is on or the user has overridden it
setLogLevelIfNotSet("org.apache.http.impl.execchain.RetryExec", "WARN");

// Silence the following warning on jdk21, this warning should go away with an update to jfr
// parser
// [otel.javaagent 2023-10-09 14:38:17:665 +0000] [JFR Recording Sequencer] WARN
// org.openjdk.jmc.flightrecorder.internal.parser.v1.ValueReaders$ReflectiveReader - Could not
// find field with name 'virtual' in reader for 'thread'
setLogLevelIfNotSet(
"org.openjdk.jmc.flightrecorder.internal.parser.v1.ValueReaders$ReflectiveReader",
"ERROR");
}
}

private static void setLogLevelIfNotSet(String className, String logLevel) {
String loggerProperty = LOGGER_PREFIX + className;
breedx-splk marked this conversation as resolved.
Show resolved Hide resolved
String currentLogLevel = System.getProperty(loggerProperty);
if (currentLogLevel == null) {
System.setProperty(loggerProperty, logLevel);
}
}

Expand Down