Fix default enabled for runtime and oshi metrics (#5989)
This commit is contained in:
parent
c89297f250
commit
cef9e1925c
|
@ -19,10 +19,14 @@ import java.util.Collections;
|
||||||
*/
|
*/
|
||||||
@AutoService(AgentListener.class)
|
@AutoService(AgentListener.class)
|
||||||
public class OshiMetricsInstaller implements AgentListener {
|
public class OshiMetricsInstaller implements AgentListener {
|
||||||
|
|
||||||
|
private static final boolean DEFAULT_ENABLED =
|
||||||
|
Config.get().getBoolean("otel.instrumentation.common.default-enabled", true);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterAgent(Config config, AutoConfiguredOpenTelemetrySdk unused) {
|
public void afterAgent(Config config, AutoConfiguredOpenTelemetrySdk unused) {
|
||||||
if (new AgentConfig(config)
|
if (new AgentConfig(config)
|
||||||
.isInstrumentationEnabled(Collections.singleton("oshi"), /* defaultEnabled= */ true)) {
|
.isInstrumentationEnabled(Collections.singleton("oshi"), DEFAULT_ENABLED)) {
|
||||||
try {
|
try {
|
||||||
// Call oshi.SystemInfo.getCurrentPlatformEnum() to activate SystemMetrics.
|
// Call oshi.SystemInfo.getCurrentPlatformEnum() to activate SystemMetrics.
|
||||||
// Oshi instrumentation will intercept this call and enable SystemMetrics.
|
// Oshi instrumentation will intercept this call and enable SystemMetrics.
|
||||||
|
|
|
@ -18,11 +18,14 @@ import java.util.Collections;
|
||||||
/** An {@link AgentListener} that enables runtime metrics during agent startup. */
|
/** An {@link AgentListener} that enables runtime metrics during agent startup. */
|
||||||
@AutoService(AgentListener.class)
|
@AutoService(AgentListener.class)
|
||||||
public class RuntimeMetricsInstaller implements AgentListener {
|
public class RuntimeMetricsInstaller implements AgentListener {
|
||||||
|
|
||||||
|
private static final boolean DEFAULT_ENABLED =
|
||||||
|
Config.get().getBoolean("otel.instrumentation.common.default-enabled", true);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterAgent(Config config, AutoConfiguredOpenTelemetrySdk unused) {
|
public void afterAgent(Config config, AutoConfiguredOpenTelemetrySdk unused) {
|
||||||
if (new AgentConfig(config)
|
if (new AgentConfig(config)
|
||||||
.isInstrumentationEnabled(
|
.isInstrumentationEnabled(Collections.singleton("runtime-metrics"), DEFAULT_ENABLED)) {
|
||||||
Collections.singleton("runtime-metrics"), /* defaultEnabled= */ true)) {
|
|
||||||
GarbageCollector.registerObservers(GlobalOpenTelemetry.get());
|
GarbageCollector.registerObservers(GlobalOpenTelemetry.get());
|
||||||
MemoryPools.registerObservers(GlobalOpenTelemetry.get());
|
MemoryPools.registerObservers(GlobalOpenTelemetry.get());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue