Search in sources :

Example 1 with LogData

use of com.uber.jaeger.LogData in project jaeger-client-java by jaegertracing.

the class JaegerThriftSpanConverter method buildLogs.

static List<Log> buildLogs(List<LogData> logs) {
    List<Log> thriftLogs = new ArrayList<Log>();
    if (logs != null) {
        for (LogData logData : logs) {
            Log thriftLog = new Log();
            thriftLog.setTimestamp(logData.getTime());
            if (logData.getFields() != null) {
                thriftLog.setFields(buildTags(logData.getFields()));
            } else {
                List<Tag> tags = new ArrayList<Tag>();
                if (logData.getMessage() != null) {
                    tags.add(buildTag("event", logData.getMessage()));
                }
                thriftLog.setFields(tags);
            }
            thriftLogs.add(thriftLog);
        }
    }
    return thriftLogs;
}
Also used : LogData(com.uber.jaeger.LogData) Log(com.uber.jaeger.thriftjava.Log) ArrayList(java.util.ArrayList) Tag(com.uber.jaeger.thriftjava.Tag)

Example 2 with LogData

use of com.uber.jaeger.LogData in project jaeger-client-java by jaegertracing.

the class ThriftSpanConverter method buildAnnotations.

private static List<Annotation> buildAnnotations(Span span, Endpoint host) {
    List<Annotation> annotations = new ArrayList<Annotation>();
    if (isRpc(span)) {
        String startLabel = zipkincoreConstants.SERVER_RECV;
        String endLabel = zipkincoreConstants.SERVER_SEND;
        if (isRpcClient(span)) {
            startLabel = zipkincoreConstants.CLIENT_SEND;
            endLabel = zipkincoreConstants.CLIENT_RECV;
        }
        annotations.add(new Annotation(span.getStart(), startLabel).setHost(host));
        annotations.add(new Annotation(span.getStart() + span.getDuration(), endLabel).setHost(host));
    }
    List<LogData> logs = span.getLogs();
    if (logs != null) {
        for (LogData logData : logs) {
            String logMessage = logData.getMessage();
            Map<String, ?> logFields = logData.getFields();
            if (logMessage != null) {
                annotations.add(new Annotation(logData.getTime(), logMessage));
            } else if (logFields != null) {
                annotations.add(new Annotation(logData.getTime(), gson.toJson(logFields)));
            }
        }
    }
    return annotations;
}
Also used : LogData(com.uber.jaeger.LogData) ArrayList(java.util.ArrayList) BinaryAnnotation(com.twitter.zipkin.thriftjava.BinaryAnnotation) Annotation(com.twitter.zipkin.thriftjava.Annotation)

Aggregations

LogData (com.uber.jaeger.LogData)2 ArrayList (java.util.ArrayList)2 Annotation (com.twitter.zipkin.thriftjava.Annotation)1 BinaryAnnotation (com.twitter.zipkin.thriftjava.BinaryAnnotation)1 Log (com.uber.jaeger.thriftjava.Log)1 Tag (com.uber.jaeger.thriftjava.Tag)1