Skip to content

Commit

Permalink
Merge pull request wildfly#18428 from rhusar/WFLY-19994
Browse files Browse the repository at this point in the history
WFLY-19994 Micrometer upgrade to 1.14.1 causes regressions with security manager
  • Loading branch information
bstansberry authored Nov 26, 2024
2 parents 1771bf4 + d96ed9d commit 9ccbd4b
Showing 1 changed file with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
*/
package org.wildfly.extension.micrometer;

import java.security.AccessController;
import java.security.PrivilegedAction;
import java.time.Duration;
import java.util.Map;

import io.micrometer.registry.otlp.AggregationTemporality;
import io.micrometer.registry.otlp.HistogramFlavor;
import io.micrometer.registry.otlp.OtlpConfig;
import org.wildfly.security.manager.WildFlySecurityManager;

public final class WildFlyMicrometerConfig implements OtlpConfig {
/**
Expand Down Expand Up @@ -45,7 +50,34 @@ public String url() {

@Override
public Duration step() {
Duration duration = Duration.ofSeconds(step);
return duration;
return Duration.ofSeconds(step);
}

@Override
public AggregationTemporality aggregationTemporality() {
if (WildFlySecurityManager.isChecking()) {
return AccessController.doPrivileged((PrivilegedAction<AggregationTemporality>) OtlpConfig.super::aggregationTemporality);
} else {
return OtlpConfig.super.aggregationTemporality();
}
}

@Override
public HistogramFlavor histogramFlavor() {
if (WildFlySecurityManager.isChecking()) {
return AccessController.doPrivileged((PrivilegedAction<HistogramFlavor>) OtlpConfig.super::histogramFlavor);
} else {
return OtlpConfig.super.histogramFlavor();
}
}

@Override
public Map<String, String> headers() {
if (WildFlySecurityManager.isChecking()) {
return AccessController.doPrivileged((PrivilegedAction<Map<String, String>>) OtlpConfig.super::headers);
} else {
return OtlpConfig.super.headers();
}
}

}

0 comments on commit 9ccbd4b

Please sign in to comment.