Skip to content

Commit

Permalink
fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtyomGabeev committed Sep 7, 2024
1 parent 046bf08 commit 6f4efdb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,15 @@ public void bindTo(MeterRegistry registry) {
started = true;
recordingStream = createRecordingStream(settings);

final Timer pinnedTimer =
Timer.builder("jvm.virtual.thread.pinned")
.tags(tags)
.description("The duration of virtual threads that were pinned to a physical thread")
.register(registry);

final Counter submitFailedCounter =
Counter.builder("jvm.virtual.thread.submit.failed")
.tags(tags)
.description("The number of virtual thread submissions that failed")
.register(registry);
final Timer pinnedTimer = Timer.builder("jvm.virtual.thread.pinned")
.tags(tags)
.description("The duration of virtual threads that were pinned to a physical thread")
.register(registry);

final Counter submitFailedCounter = Counter.builder("jvm.virtual.thread.submit.failed")
.tags(tags)
.description("The number of virtual thread submissions that failed")
.register(registry);

recordingStream.onEvent(PINNED_EVENT, event -> pinnedTimer.record(event.getDuration()));
recordingStream.onEvent(SUBMIT_FAILED_EVENT, event -> submitFailedCounter.increment());
Expand Down Expand Up @@ -103,8 +101,10 @@ public record RecordingSettings(Duration maxAge, long maxSize, Duration pinnedTh
Objects.requireNonNull(maxAge, "maxAge parameter must not be null");
Objects.requireNonNull(pinnedThreshold, "pinnedThreshold must not be null");
}

public RecordingSettings() {
this(Duration.ofSeconds(5), 10L * 1024 * 1024, Duration.ofMillis(1));
}
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2022 VMware, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micrometer.java21.instrument.binder.jfr;

import io.micrometer.core.instrument.MeterRegistry;
Expand Down Expand Up @@ -29,17 +44,14 @@ void setup() {

@Test
void registerPinnedEvent() throws Exception {
Thread.ofVirtual()
.name("vt-test")
.start(() -> {
synchronized (this) {
sleep(Duration.ofMillis(100));
}
})
.join();
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);
.until(() -> registry.get("jvm.virtual.thread.pinned").tags(USER_TAGS).timer().count() == 1);
}

private void sleep(Duration duration) {
Expand Down

0 comments on commit 6f4efdb

Please sign in to comment.