Skip to content

Add pseudo monitoring option 'none' to disable all monitoring options #48872

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -334,6 +334,7 @@ default String getEffectiveImage() {
* <li><code>jmxserver</code> for JMX server support (experimental)</li>
* <li><code>nmt</code> for native memory tracking support</li>
* <li><code>all</code> for all monitoring features</li>
* <li><code>none</code> for explicitly turning off all monitoring features</li>
* </ul>
*/
Optional<List<MonitoringOption>> monitoring();
Expand Down Expand Up @@ -590,7 +591,8 @@ enum MonitoringOption {
JMXSERVER,
JMXCLIENT,
NMT,
ALL
ALL,
NONE
}

enum ImagePullStrategy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -951,11 +951,6 @@ public NativeImageInvokerInfo build() {
}

Set<NativeConfig.MonitoringOption> monitoringOptions = new LinkedHashSet<>();
if (!OS.WINDOWS.isCurrent() || containerBuild) {
// --enable-monitoring=heapdump is not supported on Windows
monitoringOptions.add(NativeConfig.MonitoringOption.HEAPDUMP);
}

if (nativeMonitoringItems != null && !nativeMonitoringItems.isEmpty()) {
monitoringOptions.addAll(nativeMonitoringItems.stream()
.map(NativeMonitoringBuildItem::getOption)
Expand All @@ -965,6 +960,30 @@ public NativeImageInvokerInfo build() {
if (nativeConfig.monitoring().isPresent()) {
monitoringOptions.addAll(nativeConfig.monitoring().get());
}

if (monitoringOptions.remove(NativeConfig.MonitoringOption.NONE)) {
// Don't add any monitoring options since 'none' was present.
// Only log a warning when additional options were present as well
if (!monitoringOptions.isEmpty()) {
String otherOpts = monitoringOptions.stream()
.map(o -> o.name().toLowerCase(Locale.ROOT))
.collect(Collectors.joining(","));
log.warn(
"Your application is setting monitoring option 'quarkus.native.monitoring' to 'none' AND '"
+ otherOpts + "'"
+ " Please consider removing options '" + otherOpts + "' as they will be ignored."
+ " Monitoring option 'none' disables all monitoring options regardless of other settings.");
// Explicitly clear all monitoring options otherwise specified
monitoringOptions.clear();
}
} else {
// Add heapdump monitoring option if and only if 'none' wasn't included
if (!OS.WINDOWS.isCurrent() || containerBuild) {
// --enable-monitoring=heapdump is not supported on Windows
monitoringOptions.add(NativeConfig.MonitoringOption.HEAPDUMP);
}
}

if (!monitoringOptions.isEmpty()) {
nativeImageArgs.add("--enable-monitoring=" + monitoringOptions.stream()
.map(o -> o.name().toLowerCase(Locale.ROOT)).collect(Collectors.joining(",")));
Expand Down
4 changes: 4 additions & 0 deletions docs/src/main/asciidoc/building-native-image.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,10 @@ include at build time.
|Adds support for native memory tracking.
|GraalVM for JDK 23 Mandrel 24.1

|none
|Disables support for all monitoring options that would be enabled by default in Quarkus
|Pseudo option used by Quarkus

|all
|Adds all monitoring options.
|GraalVM 22.3, GraalVM CE 17.0.7 Mandrel 22.3 Mandrel 23.0 (17.0.7)
Expand Down
Loading