Move SpanTypeDecorator to SpanTypeRule
MODIFY
dd-trace-ot/src/main/java/datadog/opentracing/decorators/DDDecoratorsFactory.java
dd-trace-ot/src/main/java/datadog/opentracing/decorators/DDDecoratorsFactory.java
@@ -25,8 +25,7 @@ public class DDDecoratorsFactory {
new ResourceNameDecorator(),
new ServiceNameDecorator(),
new ServiceNameDecorator("service", false),
- new ServletContextDecorator(),
- new SpanTypeDecorator())) {
+ new ServletContextDecorator())) {
if (Config.get().isDecoratorEnabled(decorator.getClass().getSimpleName())) {
decorators.add(decorator);

DELETE
dd-trace-ot/src/main/java/datadog/opentracing/decorators/SpanTypeDecorator.java
-package datadog.opentracing.decorators;
-
-import datadog.opentracing.DDSpanContext;
-import datadog.trace.api.DDTags;
-
-public class SpanTypeDecorator extends AbstractDecorator {
-
- public SpanTypeDecorator() {
- super();
- setMatchingTag(DDTags.SPAN_TYPE);
- }
-
- @Override
- public boolean shouldSetTag(final DDSpanContext context, final String tag, final Object value) {
- context.setSpanType(String.valueOf(value));
- return false;
- }
-}

MODIFY
dd-trace-ot/src/main/java/datadog/trace/common/processor/TraceProcessor.java
dd-trace-ot/src/main/java/datadog/trace/common/processor/TraceProcessor.java
@@ -3,6 +3,7 @@ package datadog.trace.common.processor;
import datadog.opentracing.DDSpan;
import datadog.trace.api.Config;
import datadog.trace.common.processor.rule.ErrorRule;
+import datadog.trace.common.processor.rule.SpanTypeRule;
import datadog.trace.common.processor.rule.Status404Rule;
import datadog.trace.common.processor.rule.Status5XXRule;
import datadog.trace.common.processor.rule.URLAsResourceNameRule;
@@ -17,7 +18,11 @@ public class TraceProcessor {
final Rule[] DEFAULT_RULES =
new Rule[] {
// Rules are applied in order.
- new Status5XXRule(), new ErrorRule(), new URLAsResourceNameRule(), new Status404Rule(),
+ new SpanTypeRule(),
+ new Status5XXRule(),
+ new ErrorRule(),
+ new URLAsResourceNameRule(),
+ new Status404Rule(),
};
private final List<Rule> rules;

MODIFY
dd-trace-ot/src/main/java/datadog/trace/common/processor/rule/ErrorRule.java
dd-trace-ot/src/main/java/datadog/trace/common/processor/rule/ErrorRule.java
@@ -6,7 +6,7 @@ import io.opentracing.tag.Tags;
import java.util.Collection;
import java.util.Map;
-/** Converts error tag to error field */
+/** Converts error tag to field */
public class ErrorRule implements TraceProcessor.Rule {
@Override
public String[] aliases() {

ADD
dd-trace-ot/src/main/java/datadog/trace/common/processor/rule/SpanTypeRule.java
+package datadog.trace.common.processor.rule;
+
+import datadog.opentracing.DDSpan;
+import datadog.trace.api.DDTags;
+import datadog.trace.common.processor.TraceProcessor;
+import java.util.Collection;
+import java.util.Map;
+
+/** Converts span type tag to field */
+public class SpanTypeRule implements TraceProcessor.Rule {
+ @Override
+ public String[] aliases() {
+ return new String[] {"SpanTypeDecorator"};
+ }
+
+ @Override
+ public void processSpan(
+ final DDSpan span, final Map<String, String> meta, final Collection<DDSpan> trace) {
+ if (meta.containsKey(DDTags.SPAN_TYPE)) {
+ span.setSpanType(meta.get(DDTags.SPAN_TYPE));
+ span.setTag(DDTags.SPAN_TYPE, (String) null); // Remove the tag
+ }
+ }
+}

Move SpanTypeDecorator to SpanTypeRule