Skip to content
Browse files
wrapping json for zipkin tracing
  • Loading branch information
rmannibucau committed May 21, 2018
1 parent 23647ae commit ca655103e914658de9d67bb198cd6993be3478ed
Showing 2 changed files with 12 additions and 1 deletion.
@@ -30,4 +30,5 @@ NOTE: if you are using Microprofile Config it is used, otherwise it uses system
||`counter` (to generate longs), `uuid` (to generate random uuids) or `hex` (to use the hexa representation of the uuid generator). Specifies which kind of trace and span id are in use.|hex
||Should spans converted to a zipkin representation. True until there is a standard opentracing format.|true
||Should a logger named `org.apache.geronimo.opentracing.zipkin` log each span as a Zipkin JSON. This allows to use a logger implementation to push the spans to any backend (like log4j2 kafka appender). It uses JUL as a facade.|true
|geronimo.opentracing.span.converter.zipkin.logger.wrapAsList|Should zipkin JSON be logged wrapped in a list.|true
@@ -22,20 +22,29 @@
import javax.annotation.PreDestroy;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
import javax.inject.Inject;
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;

import org.apache.geronimo.microprofile.opentracing.config.GeronimoOpenTracingConfig;

// this allows to integrate with any backend using appenders.
public class ZipkinLogger {

private final Logger logger = Logger.getLogger(ZipkinLogger.class.getName());

private GeronimoOpenTracingConfig config;

private Jsonb jsonb;

private boolean wrapAsList;

private void init() {
jsonb = JsonbBuilder.create();
wrapAsList = Boolean.parseBoolean("span.converter.zipkin.logger.wrapAsList", "true"));

@@ -48,6 +57,7 @@ private void destroy() {

public void onZipkinSpan(@Observes final ZipkinSpan zipkinSpan) {;
final String json = jsonb.toJson(zipkinSpan); ? '[' + json + ']' : json);

0 comments on commit ca65510

Please sign in to comment.