opencensus-java
opencensus-java copied to clipboard
opencensus annotation is incompatible with jaeger logs
I use span.addAnnotation and hope it can add key-value logs in the jaeger log, but it show the result on the following graph, anyone know how to add logs in jaeger UI by opencensus library?
Map<String, AttributeValue> logs = new HashMap<>(6);
logs.put("logger", AttributeValue.stringAttributeValue(event.getLoggerName()));
logs.put("level", AttributeValue.stringAttributeValue(event.getLevel().toString()));
logs.put("thread", AttributeValue.stringAttributeValue(event.getThreadName()));
logs.put("message", AttributeValue.stringAttributeValue(event.getFormattedMessage()));
logs.put("timeStamp", AttributeValue.longAttributeValue(event.getTimeStamp()));
span.addAnnotation(Annotation.fromDescriptionAndAttributes("logs", logs));

OpenCensus span attributes will be converted to Jaeger tags, and timed events will be converted to Jaeger logs: https://github.com/census-instrumentation/opencensus-java/blob/48106bca7df7bf547fc857afd835be3a7a659253/exporters/trace/jaeger/src/main/java/io/opencensus/exporter/trace/jaeger/JaegerExporterHandler.java#L265-L322
So if you want to add custom Jaeger tags, you should use span.addAnnotation or span.addMessageEvent.