use of io.opentracing.tag.Tag in project Payara by payara.
the class MonitoringConsoleRuntimeImpl method selectAll.
@Override
public Collection<GroupData> selectAll(String source, String group) {
if (!"requesttracing".equals(source)) {
return emptyList();
}
List<GroupData> matches = new ArrayList<>();
for (RequestTrace trace : requestTracingService.getRequestTraceStore().getTraces()) {
if (RequestTracingService.metricGroupName(trace).equals(group)) {
GroupData data = new GroupData();
data.addField("id", trace.getTraceId()).addField("startTime", trace.getStartTime().toEpochMilli()).addField("endTime", trace.getEndTime().toEpochMilli()).addField("elapsedTime", trace.getElapsedTime());
for (RequestTraceSpan span : trace.getTraceSpans()) {
GroupData tags = data.addChild(span.getId().toString()).addField("id", span.getId()).addField("operation", RequestTracingService.stripPackageName(span.getEventName())).addField("startTime", span.getTimeOccured()).addField("endTime", span.getTraceEndTime().toEpochMilli()).addField("duration", span.getSpanDuration()).addChild("tags");
for (Entry<Object, String> tag : span.getSpanTags().entrySet()) {
if (tag.getKey() instanceof Tag) {
tags.addField(((Tag) tag.getKey()).getKey(), tag.getValue());
} else {
tags.addField(tag.getKey().toString(), tag.getValue());
}
}
}
matches.add(data);
}
}
return matches;
}
use of io.opentracing.tag.Tag in project Payara by payara.
the class RequestTracingService method collectTrace.
private static String collectTrace(MonitoringDataCollector tracingCollector, RequestTrace trace, long threshold) {
try {
UUID traceId = trace.getTraceId();
if (traceId != null) {
String group = metricGroupName(trace);
long durationMillis = trace.getTraceSpans().getFirst().getSpanDuration() / 1000000;
RequestTraceSpan annotationSpan = trace.getTraceSpans().getLast();
List<String> attrs = new ArrayList<>();
attrs.add("Threshold");
attrs.add(String.valueOf(threshold));
attrs.add("Operation");
attrs.add(annotationSpan.getEventName());
attrs.add("Start");
attrs.add(String.valueOf(annotationSpan.getStartInstant().toEpochMilli()));
attrs.add("End");
attrs.add(String.valueOf(annotationSpan.getTraceEndTime().toEpochMilli()));
for (Entry<Object, String> tag : annotationSpan.getSpanTags().entrySet()) {
if (tag.getKey() instanceof Tag) {
attrs.add(((Tag) tag.getKey()).getKey());
} else {
attrs.add(tag.getKey().toString());
}
attrs.add(tag.getValue());
}
tracingCollector.group(group).collect(DURATION, durationMillis).annotate(DURATION, durationMillis, attrs.toArray(new String[0]));
return group;
}
} catch (Exception ex) {
logger.log(Level.FINE, "Failed to collect trace", ex);
}
return null;
}
Aggregations