Skip to content

Commit

Permalink
Merge pull request #30410 from geoand/#30408
Browse files Browse the repository at this point in the history
Introduce support for GraalVM `--enable-monitoring`
  • Loading branch information
geoand authored Jan 17, 2023
2 parents 9c09042 + 6cc0446 commit 7f1ccb7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,20 @@ public String getEffectiveBuilderImage() {
public Optional<List<String>> containerRuntimeOptions;

/**
* If the resulting image should allow VM introspection
* If the resulting image should allow VM introspection.
*
* @deprecated Use {@code quarkus.native.monitoring} instead.
*/
@ConfigItem
@Deprecated
public boolean enableVmInspection;

/**
* Enable monitoring options that allow the VM to be inspected at run time.
*/
@ConfigItem
public Optional<List<MonitoringOption>> monitoring;

/**
* If full stack traces are enabled in the resulting image
*/
Expand Down Expand Up @@ -452,4 +461,12 @@ public static enum BuilderImageProvider {
GRAALVM,
MANDREL;
}

public enum MonitoringOption {
HEAPDUMP,
JVMSTAT,
JFR,
ALL,
TRUE // only needed to support -Dquarkus.native.monitoring
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.apache.commons.lang3.SystemUtils;
import org.eclipse.microprofile.config.ConfigProvider;
import org.jboss.logging.Logger;

import io.quarkus.bootstrap.util.IoUtils;
Expand Down Expand Up @@ -623,6 +625,7 @@ public Builder setNativeImageName(String nativeImageName) {
return this;
}

@SuppressWarnings("deprecation")
public NativeImageInvokerInfo build() {
List<String> nativeImageArgs = new ArrayList<>();
boolean enableSslNative = false;
Expand Down Expand Up @@ -824,6 +827,21 @@ public NativeImageInvokerInfo build() {
if (nativeConfig.enableVmInspection) {
nativeImageArgs.add("-H:+AllowVMInspection");
}

if (nativeConfig.monitoring.isPresent()) {
List<NativeConfig.MonitoringOption> monitoringOptions = nativeConfig.monitoring.get();
if (monitoringOptions.stream().anyMatch(o -> o == NativeConfig.MonitoringOption.TRUE
|| o == NativeConfig.MonitoringOption.ALL)) {
nativeImageArgs.add("--enable-monitoring");
}
nativeImageArgs
.add("--enable-monitoring=" + monitoringOptions.stream().map(o -> o.name().toLowerCase(
Locale.ROOT)).collect(Collectors.joining(",")));
} else if (ConfigProvider.getConfig().getConfigValue("quarkus.native.monitoring").getValue() != null) {
// this only happens when a user has configured 'quarkus.native.monitoring='
// we want to support this use case as GraalVM allows the use of '--enable-monitoring' without an argument
nativeImageArgs.add("--enable-monitoring");
}
if (nativeConfig.autoServiceLoaderRegistration) {
nativeImageArgs.add("-H:+UseServiceLoaderFeature");
//When enabling, at least print what exactly is being added:
Expand Down

0 comments on commit 7f1ccb7

Please sign in to comment.