-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable oshi ProcessMetrics in javaagent (and refactor oshi instrument…
…ation) (open-telemetry#5281) * Enable oshi ProcessMetrics in javaagent (and refactor oshi instrumentation) * Get rid of double async instrument registration logs * spotless
- Loading branch information
Showing
16 changed files
with
259 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...nt/src/main/java/io/opentelemetry/javaagent/instrumentation/oshi/MetricsRegistration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.oshi; | ||
|
||
import io.opentelemetry.instrumentation.api.config.Config; | ||
import io.opentelemetry.instrumentation.oshi.ProcessMetrics; | ||
import io.opentelemetry.instrumentation.oshi.SystemMetrics; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
public final class MetricsRegistration { | ||
|
||
private static final AtomicBoolean registered = new AtomicBoolean(); | ||
|
||
public static void register() { | ||
if (registered.compareAndSet(false, true)) { | ||
SystemMetrics.registerObservers(); | ||
|
||
// ProcessMetrics don't follow the spec | ||
if (Config.get() | ||
.getBoolean("otel.instrumentation.oshi.experimental-metrics.enabled", false)) { | ||
ProcessMetrics.registerObservers(); | ||
} | ||
} | ||
} | ||
|
||
private MetricsRegistration() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
...javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/oshi/OshiTest.groovy
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
...ent/src/test/java/io/opentelemetry/javaagent/instrumentation/oshi/ProcessMetricsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.oshi; | ||
|
||
import io.opentelemetry.instrumentation.oshi.AbstractProcessMetricsTest; | ||
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; | ||
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
class ProcessMetricsTest extends AbstractProcessMetricsTest { | ||
|
||
@RegisterExtension | ||
public static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); | ||
|
||
@Override | ||
protected void registerMetrics() {} | ||
|
||
@Override | ||
protected InstrumentationExtension testing() { | ||
return testing; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...gent/src/test/java/io/opentelemetry/javaagent/instrumentation/oshi/SystemMetricsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.oshi; | ||
|
||
import io.opentelemetry.instrumentation.oshi.AbstractSystemMetricsTest; | ||
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; | ||
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
class SystemMetricsTest extends AbstractSystemMetricsTest { | ||
|
||
@RegisterExtension | ||
public static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); | ||
|
||
@Override | ||
protected void registerMetrics() {} | ||
|
||
@Override | ||
protected InstrumentationExtension testing() { | ||
return testing; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 0 additions & 55 deletions
55
...oshi/library/src/test/java/io/opentelemetry/instrumentation/oshi/AbstractMetricsTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
plugins { | ||
id("otel.java-conventions") | ||
} | ||
|
||
dependencies { | ||
api(project(":testing-common")) | ||
} |
Oops, something went wrong.