Skip to content

Commit

Permalink
exposes part of the Stats API
Browse files Browse the repository at this point in the history
Signed-off-by: Oleh Dokuka <[email protected]>
  • Loading branch information
OlegDokuka committed Aug 24, 2020
1 parent a3016ce commit 1c8bdad
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions rsocket-core/src/main/java/io/rsocket/loadbalance/Stats.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ synchronized long instantaneous(long now) {
return duration + (now - stamp0) * pending;
}

void startStream() {
public void startStream() {
PENDING_STREAMS.incrementAndGet(this);
}

void stopStream() {
public void stopStream() {
PENDING_STREAMS.decrementAndGet(this);
}

synchronized long startRequest() {
public synchronized long startRequest() {
long now = Clock.now();
interArrivalTime.insert(now - stamp);
duration += Math.max(0, now - stamp0) * pending;
Expand All @@ -156,26 +156,26 @@ synchronized long startRequest() {
return now;
}

synchronized long stopRequest(long timestamp) {
public synchronized long stopRequest(long timestamp) {
long now = Clock.now();
duration += Math.max(0, now - stamp0) * pending - (now - timestamp);
pending -= 1;
stamp0 = now;
return now;
}

synchronized void record(double roundTripTime) {
public synchronized void record(double roundTripTime) {
median.insert(roundTripTime);
lowerQuantile.insert(roundTripTime);
higherQuantile.insert(roundTripTime);
}

synchronized void recordError(double value) {
public synchronized void recordError(double value) {
errorPercentage.insert(value);
errorStamp = Clock.now();
}

void setAvailability(double availability) {
public void setAvailability(double availability) {
this.availability = availability;
}

Expand Down Expand Up @@ -270,26 +270,26 @@ long instantaneous(long now) {
}

@Override
void startStream() {}
public void startStream() {}

@Override
void stopStream() {}
public void stopStream() {}

@Override
long startRequest() {
public long startRequest() {
return 0;
}

@Override
long stopRequest(long timestamp) {
public long stopRequest(long timestamp) {
return 0;
}

@Override
void record(double roundTripTime) {}
public void record(double roundTripTime) {}

@Override
void recordError(double value) {}
public void recordError(double value) {}

@Override
public String toString() {
Expand Down

0 comments on commit 1c8bdad

Please sign in to comment.