-
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.
Feature: selfmonitoring instrumented classes (#30)
* feature: add MetricFactory * little refactor * test: add MetricFactoryTest * refactor MetricFactoryTest * test: add self-monitoring int-test * fix sonarcloud issues
- Loading branch information
Showing
10 changed files
with
293 additions
and
32 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
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
27 changes: 27 additions & 0 deletions
27
...pard-agent/src/main/java/rocks/inspectit/gepard/agent/internal/metrics/MetricFactory.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,27 @@ | ||
/* (C) 2024 */ | ||
package rocks.inspectit.gepard.agent.internal.metrics; | ||
|
||
import io.opentelemetry.api.metrics.ObservableDoubleGauge; | ||
import io.opentelemetry.api.metrics.ObservableDoubleMeasurement; | ||
import io.opentelemetry.sdk.metrics.export.PeriodicMetricReader; | ||
import java.util.function.Consumer; | ||
import rocks.inspectit.gepard.agent.internal.otel.OpenTelemetryAccessor; | ||
|
||
/** Creates new OpenTelemetry instruments (metrics). */ | ||
public class MetricFactory { | ||
|
||
private MetricFactory() {} | ||
|
||
/** | ||
* Creates an observable gauge metric. This gauge will record a measurement via calling the | ||
* callback function everytime it is observed by the {@link PeriodicMetricReader}. | ||
* | ||
* @param name the name of the gauge | ||
* @param callback the callback function to record a measurement | ||
* @return the created gauge | ||
*/ | ||
public static ObservableDoubleGauge createObservableDoubleGauge( | ||
String name, Consumer<ObservableDoubleMeasurement> callback) { | ||
return OpenTelemetryAccessor.getMeter().gaugeBuilder(name).buildWithCallback(callback); | ||
} | ||
} |
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
Oops, something went wrong.