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 default enabled for runtime and oshi metrics #5989

Merged
merged 1 commit into from
May 6, 2022
Merged
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 @@ -19,10 +19,14 @@
*/
@AutoService(AgentListener.class)
public class OshiMetricsInstaller implements AgentListener {

private static final boolean DEFAULT_ENABLED =
Config.get().getBoolean("otel.instrumentation.common.default-enabled", true);

@Override
public void afterAgent(Config config, AutoConfiguredOpenTelemetrySdk unused) {
if (new AgentConfig(config)
.isInstrumentationEnabled(Collections.singleton("oshi"), /* defaultEnabled= */ true)) {
.isInstrumentationEnabled(Collections.singleton("oshi"), DEFAULT_ENABLED)) {
try {
// Call oshi.SystemInfo.getCurrentPlatformEnum() to activate SystemMetrics.
// Oshi instrumentation will intercept this call and enable SystemMetrics.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
/** An {@link AgentListener} that enables runtime metrics during agent startup. */
@AutoService(AgentListener.class)
public class RuntimeMetricsInstaller implements AgentListener {

private static final boolean DEFAULT_ENABLED =
Config.get().getBoolean("otel.instrumentation.common.default-enabled", true);

@Override
public void afterAgent(Config config, AutoConfiguredOpenTelemetrySdk unused) {
if (new AgentConfig(config)
.isInstrumentationEnabled(
Collections.singleton("runtime-metrics"), /* defaultEnabled= */ true)) {
.isInstrumentationEnabled(Collections.singleton("runtime-metrics"), DEFAULT_ENABLED)) {
GarbageCollector.registerObservers(GlobalOpenTelemetry.get());
MemoryPools.registerObservers(GlobalOpenTelemetry.get());
}
Expand Down