temporalio / temporalio/samples-java
Sample for a test verifying published metrics in unit tests
Open
@tsurdilo is already working on this.
Since May 9, 2022.
enhancement
- Dominant language
- Java
- Stars
- 258
- Forks
- 189
- Avg merge
- 6d 4h
- Merged PRs (30d)
- 4
Description
Temporal should provide a sample for users on how they may check the metrics in unit tests.
I propose to wire MetricsScope with our standard MicrometerClientStatsReporter initialized with SimpleMeterRegistry micrometer.
A little bit like micrometer does in one of their tests:
https://www.programcreek.com/java-api-examples/?code=micrometer-metrics%2Fmicrometer%2Fmicrometer-master%2Fmicrometer-test%2Fsrc%2Fmain%2Fjava%2Fio%2Fmicrometer%2Fcore%2Ftck%2FTimerTest.java
MeterRegistry registry = new SimpleMeterRegistry();
try (Timer.ResourceSample sample = Timer.resource(registry, "requests")
.description("This is an operation")
.publishPercentileHistogram()) {
try {
if (outcome.equals("error")) {
throw new IllegalArgumentException("boom");
}
sample.tag("outcome", "success");
} catch (Throwable t) {
sample.tag("outcome", "error");
}
}
assertThat(registry.get("requests").tag("outcome", outcome).timer().count())
.isEqualTo(1);
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.