Skip to content

Commit fbc63c1

Browse files
authored
Merge branch 'main' into otel-resource
2 parents 2d28591 + a133d76 commit fbc63c1

File tree

2 files changed

+20
-17
lines changed
  • prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/metrics
  • simpleclient-archive/simpleclient_jetty

2 files changed

+20
-17
lines changed

prometheus-metrics-core/src/main/java/io/prometheus/metrics/core/metrics/Buffer.java

+19-16
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ void reset() {
5757
reset = true;
5858
}
5959

60+
@SuppressWarnings("ThreadPriorityCheck")
6061
<T extends DataPointSnapshot> T run(
6162
Function<Long, Boolean> complete,
6263
Supplier<T> createResult,
@@ -70,24 +71,26 @@ <T extends DataPointSnapshot> T run(
7071
// Signal that the buffer is active.
7172
Long expectedCount = observationCount.getAndAdd(bufferActiveBit);
7273

73-
appendLock.lock();
74-
try {
75-
while (!complete.apply(expectedCount)) {
76-
// Wait until all in-flight threads have added their observations to the buffer.
77-
bufferFilled.await();
78-
}
79-
result = createResult.get();
74+
while (!complete.apply(expectedCount)) {
75+
// Wait until all in-flight threads have added their observations to the histogram
76+
// we can't use a condition here, because the other thread doesn't have a lock as it's on
77+
// the fast path.
78+
Thread.yield();
79+
}
80+
result = createResult.get();
8081

81-
// Signal that the buffer is inactive.
82-
int expectedBufferSize;
83-
if (reset) {
84-
expectedBufferSize =
85-
(int) ((observationCount.getAndSet(0) & ~bufferActiveBit) - expectedCount);
86-
reset = false;
87-
} else {
88-
expectedBufferSize = (int) (observationCount.addAndGet(bufferActiveBit) - expectedCount);
89-
}
82+
// Signal that the buffer is inactive.
83+
int expectedBufferSize;
84+
if (reset) {
85+
expectedBufferSize =
86+
(int) ((observationCount.getAndSet(0) & ~bufferActiveBit) - expectedCount);
87+
reset = false;
88+
} else {
89+
expectedBufferSize = (int) (observationCount.addAndGet(bufferActiveBit) - expectedCount);
90+
}
9091

92+
appendLock.lock();
93+
try {
9194
while (bufferPos < expectedBufferSize) {
9295
// Wait until all in-flight threads have added their observations to the buffer.
9396
bufferFilled.await();

simpleclient-archive/simpleclient_jetty/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</description>
1818

1919
<properties>
20-
<jetty.version>10.0.10</jetty.version>
20+
<jetty.version>10.0.24</jetty.version>
2121
</properties>
2222

2323
<dependencies>

0 commit comments

Comments
 (0)