Skip to content

Commit

Permalink
Only log in app service env
Browse files Browse the repository at this point in the history
  • Loading branch information
heyams committed Nov 18, 2021
1 parent fd95394 commit 68812bd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ public void start() {
StatusFile.putValue("EtwProviderError", e.getLocalizedMessage());
StatusFile.write();
} else {
LoggerFactory.getLogger(DiagnosticsHelper.DIAGNOSTICS_LOGGER_NAME)
.info(
"Detected running on a read-only file system. Status json file won't be created. If this is unexpected, please check that process has write access to the directory: {}",
StatusFile.directory);
if (DiagnosticsHelper.useAppSvcRpIntegrationLogging()) {
LoggerFactory.getLogger(DiagnosticsHelper.DIAGNOSTICS_LOGGER_NAME)
.info(
"Detected running on a read-only file system. Status json file won't be created. If this is unexpected, please check that process has write access to the directory: {}",
StatusFile.directory);
}
}

return; // appender fails to start
Expand All @@ -79,10 +81,12 @@ public void start() {
if (StatusFile.shouldWrite) {
StatusFile.putValueAndWrite("EtwProviderInitialized", "true");
} else {
LoggerFactory.getLogger(DiagnosticsHelper.DIAGNOSTICS_LOGGER_NAME)
.info(
"Detected running on a read-only file system. Status json file won't be created. If this is unexpected, please check that process has write access to the directory: {}",
StatusFile.directory);
if (DiagnosticsHelper.useAppSvcRpIntegrationLogging()) {
LoggerFactory.getLogger(DiagnosticsHelper.DIAGNOSTICS_LOGGER_NAME)
.info(
"Detected running on a read-only file system. Status json file won't be created. If this is unexpected, please check that process has write access to the directory: {}",
StatusFile.directory);
}
}

super.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ public static void start(Instrumentation instrumentation, File javaagentFile) {
StatusFile.putValueAndWrite(
"AgentInitializedSuccessfully", success, startupLogger != null);
} else {
startupLogger.info(
"Detected running on a read-only file system. Status json file won't be created. If this is unexpected, please check that process has write access to the directory: {}",
StatusFile.directory);
if (DiagnosticsHelper.useAppSvcRpIntegrationLogging()) {
startupLogger.info(
"Detected running on a read-only file system. Status json file won't be created. If this is unexpected, please check that process has write access to the directory: {}",
StatusFile.directory);
}
}
} catch (Throwable t) {
if (startupLogger != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import static net.bytebuddy.jar.asm.Opcodes.NEW;
import static net.bytebuddy.jar.asm.Opcodes.RETURN;

import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.DiagnosticsHelper;
import com.microsoft.applicationinsights.agent.bootstrap.diagnostics.status.StatusFile;
import java.lang.instrument.ClassFileTransformer;
import java.security.ProtectionDomain;
Expand Down Expand Up @@ -90,9 +91,11 @@ public class TelemetryClientClassFileTransformer implements ClassFileTransformer
StatusFile.putValueAndWrite(
"SDKPresent", true); // TODO (heya) track this via FeatureStatsbeat
} else {
logger.info(
"Detected running on a read-only file system. Status json file won't be created. If this is unexpected, please check that process has write access to the directory: {}",
StatusFile.directory);
if (DiagnosticsHelper.useAppSvcRpIntegrationLogging()) {
logger.info(
"Detected running on a read-only file system. Status json file won't be created. If this is unexpected, please check that process has write access to the directory: {}",
StatusFile.directory);
}
}
try {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
Expand Down

0 comments on commit 68812bd

Please sign in to comment.