forked from micrometer-metrics/micrometer
-
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.
- Loading branch information
1 parent
41ce1be
commit 046bf08
Showing
5 changed files
with
126 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
description 'Micrometer core classes that require Java 21' | ||
|
||
dependencies { | ||
api project(":micrometer-core") | ||
|
||
testImplementation 'org.awaitility:awaitility' | ||
testImplementation project(":micrometer-observation-test") | ||
} | ||
|
||
java { | ||
targetCompatibility = 21 | ||
} | ||
|
||
tasks.withType(JavaCompile).configureEach { | ||
sourceCompatibility = JavaVersion.VERSION_21 | ||
targetCompatibility = JavaVersion.VERSION_21 | ||
options.release = 21 | ||
} |
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
58 changes: 58 additions & 0 deletions
58
...st/java/io/micrometer/java21/instrument/binder/jfr/JfrVirtualThreadEventMetricsTests.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,58 @@ | ||
package io.micrometer.java21.instrument.binder.jfr; | ||
|
||
import io.micrometer.core.instrument.MeterRegistry; | ||
import io.micrometer.core.instrument.Tags; | ||
import io.micrometer.core.instrument.simple.SimpleMeterRegistry; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.time.Duration; | ||
|
||
import static org.awaitility.Awaitility.await; | ||
|
||
class JfrVirtualThreadEventMetricsTests { | ||
|
||
private static final Tags USER_TAGS = Tags.of("k", "v"); | ||
|
||
private MeterRegistry registry; | ||
|
||
private JfrVirtualThreadEventMetrics jfrMetrics; | ||
|
||
@BeforeEach | ||
void setup() { | ||
registry = new SimpleMeterRegistry(); | ||
jfrMetrics = new JfrVirtualThreadEventMetrics(USER_TAGS); | ||
jfrMetrics.bindTo(registry); | ||
} | ||
|
||
@Test | ||
void registerPinnedEvent() throws Exception { | ||
Thread.ofVirtual() | ||
.name("vt-test") | ||
.start(() -> { | ||
synchronized (this) { | ||
sleep(Duration.ofMillis(100)); | ||
} | ||
}) | ||
.join(); | ||
|
||
await().atMost(Duration.ofSeconds(2)) | ||
.until(() -> registry.get("jvm.virtual.thread.pinned").timer().count() == 1); | ||
} | ||
|
||
private void sleep(Duration duration) { | ||
try { | ||
Thread.sleep(duration); | ||
} | ||
catch (InterruptedException ignored) { | ||
} | ||
} | ||
|
||
@AfterEach | ||
void cleanup() throws IOException { | ||
jfrMetrics.close(); | ||
} | ||
|
||
} |
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