Split up MessagePropertyTextMap
MODIFY
dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/JMSMessageConsumerInstrumentation.java
dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/JMSMessageConsumerInstrumentation.java
@@ -5,7 +5,7 @@ import static datadog.trace.instrumentation.api.AgentTracer.activateSpan;
import static datadog.trace.instrumentation.api.AgentTracer.propagate;
import static datadog.trace.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.instrumentation.jms.JMSDecorator.CONSUMER_DECORATE;
-import static datadog.trace.instrumentation.jms.MessagePropertyTextMap.GETTER;
+import static datadog.trace.instrumentation.jms.MessageExtractAdapter.GETTER;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
@@ -48,7 +48,8 @@ public final class JMSMessageConsumerInstrumentation extends Instrumenter.Defaul
packageName + ".JMSDecorator",
packageName + ".JMSDecorator$1",
packageName + ".JMSDecorator$2",
- packageName + ".MessagePropertyTextMap",
+ packageName + ".MessageExtractAdapter",
+ packageName + ".MessageInjectAdapter"
};
}

MODIFY
dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/JMSMessageListenerInstrumentation.java
dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/JMSMessageListenerInstrumentation.java
@@ -5,7 +5,7 @@ import static datadog.trace.instrumentation.api.AgentTracer.activateSpan;
import static datadog.trace.instrumentation.api.AgentTracer.propagate;
import static datadog.trace.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.instrumentation.jms.JMSDecorator.CONSUMER_DECORATE;
-import static datadog.trace.instrumentation.jms.MessagePropertyTextMap.GETTER;
+import static datadog.trace.instrumentation.jms.MessageExtractAdapter.GETTER;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
@@ -46,7 +46,8 @@ public final class JMSMessageListenerInstrumentation extends Instrumenter.Defaul
packageName + ".JMSDecorator",
packageName + ".JMSDecorator$1",
packageName + ".JMSDecorator$2",
- packageName + ".MessagePropertyTextMap",
+ packageName + ".MessageExtractAdapter",
+ packageName + ".MessageInjectAdapter"
};
}

MODIFY
dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/JMSMessageProducerInstrumentation.java
dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/JMSMessageProducerInstrumentation.java
@@ -5,7 +5,7 @@ import static datadog.trace.instrumentation.api.AgentTracer.activateSpan;
import static datadog.trace.instrumentation.api.AgentTracer.propagate;
import static datadog.trace.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.instrumentation.jms.JMSDecorator.PRODUCER_DECORATE;
-import static datadog.trace.instrumentation.jms.MessagePropertyTextMap.SETTER;
+import static datadog.trace.instrumentation.jms.MessageInjectAdapter.SETTER;
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
@@ -48,7 +48,8 @@ public final class JMSMessageProducerInstrumentation extends Instrumenter.Defaul
packageName + ".JMSDecorator",
packageName + ".JMSDecorator$1",
packageName + ".JMSDecorator$2",
- packageName + ".MessagePropertyTextMap",
+ packageName + ".MessageExtractAdapter",
+ packageName + ".MessageInjectAdapter"
};
}

RENAME
dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/MessagePropertyTextMap.java
dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/MessageExtractAdapter.java
@@ -9,13 +9,9 @@ import javax.jms.Message;
import lombok.extern.slf4j.Slf4j;
@Slf4j
-public class MessagePropertyTextMap
- implements AgentPropagation.Getter<Message>, AgentPropagation.Setter<Message> {
+public class MessageExtractAdapter implements AgentPropagation.Getter<Message> {
- public static final MessagePropertyTextMap GETTER = new MessagePropertyTextMap();
- public static final MessagePropertyTextMap SETTER = new MessagePropertyTextMap();
-
- static final String DASH = "__dash__";
+ public static final MessageExtractAdapter GETTER = new MessageExtractAdapter();
@Override
public Iterable<String> keys(final Message carrier) {
@@ -27,7 +23,7 @@ public class MessagePropertyTextMap
final String key = (String) enumeration.nextElement();
final Object value = carrier.getObjectProperty(key);
if (value instanceof String) {
- keys.add(key.replace(DASH, "-"));
+ keys.add(key.replace(MessageInjectAdapter.DASH, "-"));
}
}
}
@@ -39,7 +35,7 @@ public class MessagePropertyTextMap
@Override
public String get(final Message carrier, final String key) {
- final String propName = key.replace("-", DASH);
+ final String propName = key.replace("-", MessageInjectAdapter.DASH);
final Object value;
try {
value = carrier.getObjectProperty(propName);
@@ -52,16 +48,4 @@ public class MessagePropertyTextMap
return null;
}
}
-
- @Override
- public void set(final Message carrier, final String key, final String value) {
- final String propName = key.replace("-", DASH);
- try {
- carrier.setStringProperty(propName, value);
- } catch (final JMSException e) {
- if (log.isDebugEnabled()) {
- log.debug("Failure setting jms property: " + propName, e);
- }
- }
- }
}

ADD
dd-java-agent/instrumentation/jms/src/main/java/datadog/trace/instrumentation/jms/MessageInjectAdapter.java
+package datadog.trace.instrumentation.jms;
+
+import datadog.trace.instrumentation.api.AgentPropagation;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class MessageInjectAdapter implements AgentPropagation.Setter<Message> {
+
+ public static final MessageInjectAdapter SETTER = new MessageInjectAdapter();
+
+ static final String DASH = "__dash__";
+
+ @Override
+ public void set(final Message carrier, final String key, final String value) {
+ final String propName = key.replace("-", DASH);
+ try {
+ carrier.setStringProperty(propName, value);
+ } catch (final JMSException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Failure setting jms property: " + propName, e);
+ }
+ }
+ }
+}

Split up MessagePropertyTextMap