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

Fix ETW init failure #3571

Merged
merged 18 commits into from
Mar 6, 2024
2 changes: 1 addition & 1 deletion .github/workflows/build-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jobs:
run: |
modules=$(ls -d smoke-tests/apps/* | sed 's/\/$//' | sed 's/\//:/g' | sed 's/^/:/')
inner_json=$(echo $modules | xargs echo | sed 's/ /","/g')
echo "::set-output name=matrix::{\"module\":[\"$inner_json\"]}"
echo "{matrix}={\"module\":[\"$inner_json\"]}" >> $GITHUB_OUTPUT
trask marked this conversation as resolved.
Show resolved Hide resolved

smoke-test:
needs: setup-smoke-test-matrix
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
$VERSION \
applicationinsights-agent-$VERSION.jar

echo "::set-output name=version::$VERSION"
echo "{version}={$VERSION}" >> $GITHUB_OUTPUT

create-docs-pull-request:
needs:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## Version 3.5.1 GA (03/05/2024)

### Bug fixes:

* Fix ETW initialization failure for App Service Windows ([#3571](https://github.com/microsoft/ApplicationInsights-Java/pull/3571))

## Version 3.5.0 GA (02/29/2024)

### Breaking changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public static File buildDllLocalPath(@Nullable String versionDirectory) {

/** Assumes dllOnDisk is non-null and exists. */
public static void extractToLocalFolder(File dllOnDisk, String libraryToLoad) throws IOException {
LOGGER.debug("#### extractToLocalFolder start");
ClassLoader classLoader = DllFileUtils.class.getClassLoader();
if (classLoader == null) {
classLoader = ClassLoader.getSystemClassLoader();
Expand All @@ -64,23 +65,31 @@ public static void extractToLocalFolder(File dllOnDisk, String libraryToLoad) th
byte[] buffer = new byte[8192];
try (OutputStream out = new FileOutputStream(dllOnDisk, false)) {
if (dllOnDisk.exists()) {
LOGGER.debug("#### dllOnDisk exists: '{}'", dllOnDisk);
if (dllOnDisk.isDirectory()) {
LOGGER.debug("#### dllOnDisk is a directory: '{}'", dllOnDisk.isDirectory());
throw new IOException(
"Cannot extract dll: " + dllOnDisk.getAbsolutePath() + " exists as a directory");
}
if (!dllOnDisk.canWrite()) {
LOGGER.debug("#### dllOnDisk is not writeable: '{}'", dllOnDisk.canWrite());
throw new IOException(
"Cannote extract dll: " + dllOnDisk.getAbsolutePath() + " is not writeable.");
} else {
LOGGER.debug("#### dllOnDisk is writeable: '{}'", dllOnDisk.canWrite());
}
} else {
LOGGER.debug("#### dllOnDisk does not exist: '{}'", dllOnDisk);
}

int bytesRead;
while ((bytesRead = in.read(buffer)) != -1) { // while not EOF
out.write(buffer, 0, bytesRead);
}
LOGGER.debug("#### Successfully extracted '{}' to local folder", libraryToLoad);
}
}
LOGGER.debug("Successfully extracted '{}' to local folder", libraryToLoad);
heyams marked this conversation as resolved.
Show resolved Hide resolved
LOGGER.debug("#### extractToLocalFolder done");
}

private static final List<String> CANDIDATE_USERNAME_ENVIRONMENT_VARIABLES =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@ private static File loadLibrary(String sdkVersion) throws IOException {
File dllPath = new File(targetDir, fileName);

if (!dllPath.exists()) {
LOGGER.debug("#### default dllPath doesn't exist" + dllPath.getAbsolutePath());
LOGGER.debug("#### extract to local folder instead");
DllFileUtils.extractToLocalFolder(dllPath, fileName);
} else {
LOGGER.debug("#### default dllPath exists" + dllPath.getAbsolutePath());
}

LOGGER.debug("#### finally load dll from " + dllPath.getAbsolutePath());
System.load(dllPath.getAbsolutePath());

return dllPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ public List<String> getUnexpectedEntries() throws IOException {
expectedEntries.add("rp-logger-config/");
expectedEntries.add("rp-logger-config/diagnostics\\.appender\\.xml");
expectedEntries.add("rp-logger-config/etw\\.appender\\.xml");
expectedEntries.add("applicationinsights-java-etw-provider-x86-64\\.dll");
expectedEntries.add("applicationinsights-java-etw-provider-x86\\.dll");
expectedEntries.add("inst/.*");
JarFile jarFile = new JarFile(AGENT_JAR);
List<String> unexpected = new ArrayList<>();
Expand Down