Wind down the verboseness of logging of OpenTelemetry spans
import io.opentelemetry.exporters.logging.LoggingExporter;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.trace.MultiSpanProcessor;
+import io.opentelemetry.sdk.trace.SpanData;
import io.opentelemetry.sdk.trace.SpanProcessor;
import io.opentelemetry.sdk.trace.TracerSdkFactory;
import io.opentelemetry.sdk.trace.export.SimpleSpansProcessor;
public class LoggingOptions {
private final Config config;
+ private static final Logger LOGGER = Logger.getLogger(LoggingOptions.class.getName());
public LoggingOptions(Config config) {
this.config = Objects.requireNonNull(config);
@@ -56,7 +58,18 @@ public Tracer getTracer() {
TracerSdkFactory tracerFactory = OpenTelemetrySdk.getTracerFactory();
List<SpanProcessor> exporters = new LinkedList<>();
- exporters.add(SimpleSpansProcessor.newBuilder(new LoggingExporter()).build());
+ exporters.add(SimpleSpansProcessor.newBuilder(new SpanExporter() {
+ @Override
+ public ResultCode export(List<SpanData> spans) {
+ spans.forEach(span -> LOGGER.fine("span: " + spans));
+ return ResultCode.SUCCESS;
+ }
+
+ @Override
+ public void shutdown() {
+
+ }
+ }).build());
// 2020-01-28: The Jaeger exporter doesn't yet have a
// `TracerFactoryProvider`, so we shall look up the class using
