Move ResourceNameDecorator to ResourceNameRule
MODIFY
dd-trace-ot/src/main/java/datadog/opentracing/decorators/DDDecoratorsFactory.java
dd-trace-ot/src/main/java/datadog/opentracing/decorators/DDDecoratorsFactory.java
@@ -22,7 +22,6 @@ public class DDDecoratorsFactory {
new ForceManualKeepDecorator(),
new OperationDecorator(),
new PeerServiceDecorator(),
- new ResourceNameDecorator(),
new ServiceNameDecorator(),
new ServiceNameDecorator("service", false),
new ServletContextDecorator())) {

DELETE
dd-trace-ot/src/main/java/datadog/opentracing/decorators/ResourceNameDecorator.java
-package datadog.opentracing.decorators;
-
-import datadog.opentracing.DDSpanContext;
-import datadog.trace.api.DDTags;
-
-public class ResourceNameDecorator extends AbstractDecorator {
-
- public ResourceNameDecorator() {
- super();
- this.setMatchingTag(DDTags.RESOURCE_NAME);
- }
-
- @Override
- public boolean shouldSetTag(final DDSpanContext context, final String tag, final Object value) {
- context.setResourceName(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.ResourceNameRule;
import datadog.trace.common.processor.rule.SpanTypeRule;
import datadog.trace.common.processor.rule.Status404Rule;
import datadog.trace.common.processor.rule.Status5XXRule;
@@ -18,6 +19,7 @@ public class TraceProcessor {
final Rule[] DEFAULT_RULES =
new Rule[] {
// Rules are applied in order.
+ new ResourceNameRule(),
new SpanTypeRule(),
new Status5XXRule(),
new ErrorRule(),

ADD
dd-trace-ot/src/main/java/datadog/trace/common/processor/rule/ResourceNameRule.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 resource name tag to field */
+public class ResourceNameRule implements TraceProcessor.Rule {
+ @Override
+ public String[] aliases() {
+ return new String[] {"ResourceNameDecorator"};
+ }
+
+ @Override
+ public void processSpan(
+ final DDSpan span, final Map<String, Object> tags, final Collection<DDSpan> trace) {
+ if (tags.containsKey(DDTags.RESOURCE_NAME)) {
+ span.setResourceName(tags.get(DDTags.RESOURCE_NAME).toString());
+ span.setTag(DDTags.RESOURCE_NAME, (String) null); // Remove the tag
+ }
+ }
+}

Move ResourceNameDecorator to ResourceNameRule