new stat: client.sendAckTime containing the average time to get an ack for a client message send

this stat is published in the netDb, but the quantity fields (how many acks the stat is averaged over) is h4x0red
(it always reads "666", since otherwise it'd be fairly easy to identify what routers run servers, and i can live without knowing the quantity)
This commit is contained in:
jrandom
2004-04-30 07:56:05 +00:00
committed by zzz
parent 2745ff727f
commit e5ab5d6a5a
2 changed files with 28 additions and 8 deletions

View File

@ -111,6 +111,7 @@ public class StatisticsManager implements Service {
includeRate("netDb.successPeers", stats, new long[] { 60*60*1000 });
includeRate("transport.receiveMessageSize", stats, new long[] { 5*60*1000, 60*60*1000 });
includeRate("transport.sendMessageSize", stats, new long[] { 5*60*1000, 60*60*1000 });
includeRate("client.sendAckTime", stats, new long[] { 60*60*1000, 24*60*60*1000l }, true);
stats.setProperty("stat_uptime", DataHelper.formatDuration(_context.router().getUptime()));
stats.setProperty("stat__rateKey", "avg;maxAvg;pctLifetime;[sat;satLim;maxSat;maxSatLim;][num;lifetimeFreq;maxFreq]");
_log.debug("Publishing peer rankings");
@ -127,6 +128,15 @@ public class StatisticsManager implements Service {
includeRate(rateName, stats, null);
}
private void includeRate(String rateName, Properties stats, long selectedPeriods[]) {
includeRate(rateName, stats, selectedPeriods, false);
}
/**
* @param fudgeQuantity the data being published in this stat is too sensitive to, uh
* publish, so we're kludge the quantity (allowing the fairly safe
* publication of the average values
*/
private void includeRate(String rateName, Properties stats, long selectedPeriods[],
boolean fudgeQuantity) {
RateStat rate = _context.statManager().getRate(rateName);
if (rate == null) return;
long periods[] = rate.getPeriods();
@ -144,11 +154,11 @@ public class StatisticsManager implements Service {
Rate curRate = rate.getRate(periods[i]);
if (curRate == null) continue;
stats.setProperty("stat_" + rateName + '.' + getPeriod(curRate), renderRate(curRate));
stats.setProperty("stat_" + rateName + '.' + getPeriod(curRate), renderRate(curRate, fudgeQuantity));
}
}
private static String renderRate(Rate rate) {
private static String renderRate(Rate rate, boolean fudgeQuantity) {
StringBuffer buf = new StringBuffer(255);
buf.append(num(rate.getAverageValue())).append(';');
buf.append(num(rate.getExtremeAverageValue())).append(';');
@ -159,13 +169,21 @@ public class StatisticsManager implements Service {
buf.append(pct(rate.getExtremeEventSaturation())).append(';');
buf.append(num(rate.getExtremeSaturationLimit())).append(';');
}
buf.append(num(rate.getLastEventCount())).append(';');
long numPeriods = rate.getLifetimePeriods();
if (numPeriods > 0) {
double avgFrequency = rate.getLifetimeEventCount() / (double)numPeriods;
double peakFrequency = rate.getExtremeEventCount();
buf.append(num(avgFrequency)).append(';');
buf.append(num(rate.getExtremeEventCount())).append(';');
if (fudgeQuantity) {
buf.append("666").append(';');
if (numPeriods > 0) {
buf.append("666").append(';');
buf.append("666").append(';');
}
} else {
buf.append(num(rate.getLastEventCount())).append(';');
if (numPeriods > 0) {
double avgFrequency = rate.getLifetimeEventCount() / (double)numPeriods;
double peakFrequency = rate.getExtremeEventCount();
buf.append(num(avgFrequency)).append(';');
buf.append(num(rate.getExtremeEventCount())).append(';');
}
}
return buf.toString();
}

View File

@ -87,6 +87,7 @@ public class OutboundClientMessageJob extends JobImpl {
ctx.statManager().createFrequencyStat("client.sendMessageFailFrequency", "How often does a client fail to send a message?", "Client Messages", new long[] { 60*1000l, 60*60*1000l, 24*60*60*1000l });
ctx.statManager().createRateStat("client.sendMessageSize", "How large are messages sent by the client?", "Client Messages", new long[] { 60*1000l, 60*60*1000l, 24*60*60*1000l });
ctx.statManager().createRateStat("client.sendAttemptAverage", "How many different tunnels do we have to try when sending a client message?", "Client Messages", new long[] { 60*1000l, 60*60*1000l, 24*60*60*1000l });
ctx.statManager().createRateStat("client.sendAckTime", "How long does it take to get an ACK back from a message?", "Client Messages", new long[] { 5*60*1000l, 60*60*1000l, 24*60*60*1000l });
long timeoutMs = OVERALL_TIMEOUT_MS_DEFAULT;
@ -606,6 +607,7 @@ public class OutboundClientMessageJob extends JobImpl {
_context.clientManager().messageDeliveryStatusUpdate(_status.getFrom(), msgId, true);
_lease.setNumSuccess(_lease.getNumSuccess()+1);
_context.statManager().addRateData("client.sendAckTime", sendTime, 0);
_context.statManager().addRateData("client.sendMessageSize", _status.getMessage().getPayload().getSize(), sendTime);
_context.statManager().addRateData("client.sendAttemptAverage", _status.getNumSent(), sendTime);
}