use of io.opencensus.trace.export.RunningSpanStore in project instrumentation-java by census-instrumentation.
the class TracezZPageHandler method emitSummaryTable.
// Emits the summary table with links to all samples.
private void emitSummaryTable(PrintWriter out, Formatter formatter) throws UnsupportedEncodingException {
if (runningSpanStore == null || sampledSpanStore == null) {
return;
}
RunningSpanStore.Summary runningSpanStoreSummary = runningSpanStore.getSummary();
SampledSpanStore.Summary sampledSpanStoreSummary = sampledSpanStore.getSummary();
out.write("<table style='border-spacing: 0;\n");
out.write("border-left:1px solid #3D3D3D;border-right:1px solid #3D3D3D;'>\n");
emitSummaryTableHeader(out, formatter);
Set<String> spanNames = new TreeSet<>(runningSpanStoreSummary.getPerSpanNameSummary().keySet());
spanNames.addAll(sampledSpanStoreSummary.getPerSpanNameSummary().keySet());
boolean zebraColor = true;
for (String spanName : spanNames) {
out.write("<tr class=\"border\">\n");
if (!zebraColor) {
out.write("<tr class=\"border\">\n");
} else {
formatter.format("<tr class=\"border\" style=\"background: %s\">%n", ZEBRA_STRIPE_COLOR);
}
zebraColor = !zebraColor;
formatter.format("<td>%s</td>%n", htmlEscaper().escape(spanName));
// Running
out.write("<td class=\"borderRL\"> </td>");
RunningSpanStore.PerSpanNameSummary runningSpanStorePerSpanNameSummary = runningSpanStoreSummary.getPerSpanNameSummary().get(spanName);
// subtype ignored for running requests.
emitSingleCell(out, formatter, spanName, runningSpanStorePerSpanNameSummary == null ? 0 : runningSpanStorePerSpanNameSummary.getNumRunningSpans(), RequestType.RUNNING, 0);
SampledSpanStore.PerSpanNameSummary sampledSpanStorePerSpanNameSummary = sampledSpanStoreSummary.getPerSpanNameSummary().get(spanName);
// Latency based samples
out.write("<td class=\"borderLC\"> </td>");
Map<LatencyBucketBoundaries, Integer> latencyBucketsSummaries = sampledSpanStorePerSpanNameSummary != null ? sampledSpanStorePerSpanNameSummary.getNumbersOfLatencySampledSpans() : null;
int subtype = 0;
for (LatencyBucketBoundaries latencyBucketsBoundaries : LatencyBucketBoundaries.values()) {
if (latencyBucketsSummaries != null) {
int numSamples = latencyBucketsSummaries.containsKey(latencyBucketsBoundaries) ? latencyBucketsSummaries.get(latencyBucketsBoundaries) : 0;
emitSingleCell(out, formatter, spanName, numSamples, RequestType.FINISHED, subtype++);
} else {
// numSamples < -1 means "Not Available".
emitSingleCell(out, formatter, spanName, -1, RequestType.FINISHED, subtype++);
}
}
// Error based samples.
out.write("<td class=\"borderRL\"> </td>");
if (sampledSpanStorePerSpanNameSummary != null) {
Map<CanonicalCode, Integer> errorBucketsSummaries = sampledSpanStorePerSpanNameSummary.getNumbersOfErrorSampledSpans();
int numErrorSamples = 0;
for (Map.Entry<CanonicalCode, Integer> it : errorBucketsSummaries.entrySet()) {
numErrorSamples += it.getValue();
}
// subtype 0 means all;
emitSingleCell(out, formatter, spanName, numErrorSamples, RequestType.FAILED, 0);
} else {
// numSamples < -1 means "Not Available".
emitSingleCell(out, formatter, spanName, -1, RequestType.FAILED, 0);
}
out.write("</tr>\n");
}
out.write("</table>");
}
Aggregations