From 489de243b657f9fcebd149f0671366c7a77bf727 Mon Sep 17 00:00:00 2001 From: Stuart McCulloch Date: Fri, 31 May 2024 00:52:20 +0100 Subject: [PATCH] Add a TracingFactory (added in opentracing-tracerresolver 0.1.5) which resolves our tracer (#7102) --- .../opentracing/resolver/DDTracerFactory.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 dd-trace-ot/src/main/java/datadog/opentracing/resolver/DDTracerFactory.java diff --git a/dd-trace-ot/src/main/java/datadog/opentracing/resolver/DDTracerFactory.java b/dd-trace-ot/src/main/java/datadog/opentracing/resolver/DDTracerFactory.java new file mode 100644 index 00000000000..9bd70fc18d2 --- /dev/null +++ b/dd-trace-ot/src/main/java/datadog/opentracing/resolver/DDTracerFactory.java @@ -0,0 +1,26 @@ +package datadog.opentracing.resolver; + +import com.google.auto.service.AutoService; +import datadog.opentracing.DDTracer; +import datadog.trace.api.Config; +import io.opentracing.Tracer; +import io.opentracing.contrib.tracerresolver.TracerFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@AutoService(TracerFactory.class) +public class DDTracerFactory implements TracerFactory { + + private static final Logger log = LoggerFactory.getLogger(DDTracerFactory.class); + + @Override + public Tracer getTracer() { + if (Config.get().isTraceResolverEnabled()) { + log.info("Creating DDTracer with DDTracerFactory"); + return DDTracer.builder().build(); + } else { + log.info("DDTracerFactory disabled"); + return null; + } + } +}