Skip to content

Commit d55a9af

Browse files
authored
Review fixes for jms-common:javaagent (#18097)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
1 parent 5449673 commit d55a9af

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

instrumentation/jms/jms-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jms/MessagePropertyGetter.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,23 @@
66
package io.opentelemetry.javaagent.instrumentation.jms;
77

88
import static java.util.Collections.emptyList;
9+
import static java.util.logging.Level.FINE;
910

1011
import io.opentelemetry.context.propagation.TextMapGetter;
12+
import java.util.logging.Logger;
1113
import javax.annotation.Nullable;
1214

1315
enum MessagePropertyGetter implements TextMapGetter<MessageWithDestination> {
1416
INSTANCE;
1517

18+
private static final Logger logger = Logger.getLogger(MessagePropertyGetter.class.getName());
19+
1620
@Override
1721
public Iterable<String> keys(MessageWithDestination message) {
1822
try {
1923
return message.message().getPropertyNames();
2024
} catch (Exception e) {
25+
logger.log(FINE, "Failure getting JMS property names", e);
2126
return emptyList();
2227
}
2328
}
@@ -33,7 +38,8 @@ public String get(@Nullable MessageWithDestination carrier, String key) {
3338
try {
3439
value = carrier.message().getObjectProperty(propName);
3540
} catch (Exception e) {
36-
throw new IllegalStateException(e);
41+
logger.log(FINE, "Failure getting JMS property: " + propName, e);
42+
return null;
3743
}
3844
if (value instanceof String) {
3945
return (String) value;

instrumentation/jms/jms-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jms/MessageWithDestination.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@
55

66
package io.opentelemetry.javaagent.instrumentation.jms;
77

8+
import static java.util.logging.Level.FINE;
9+
810
import com.google.auto.value.AutoValue;
11+
import java.util.logging.Logger;
912
import javax.annotation.Nullable;
1013

1114
@AutoValue
1215
public abstract class MessageWithDestination {
1316

17+
private static final Logger logger = Logger.getLogger(MessageWithDestination.class.getName());
18+
1419
// visible for tests
1520
static final String TIBCO_TMP_PREFIX = "$TMP$";
1621

@@ -25,8 +30,8 @@ public static MessageWithDestination create(
2530
DestinationAdapter jmsDestination = null;
2631
try {
2732
jmsDestination = message.getJmsDestination();
28-
} catch (Exception ignored) {
29-
// Ignore
33+
} catch (Exception e) {
34+
logger.log(FINE, "Failure getting JMS destination", e);
3035
}
3136
if (jmsDestination == null) {
3237
jmsDestination = fallbackDestination;
@@ -66,6 +71,7 @@ private static String getDestinationName(DestinationAdapter destination, NameGet
6671
try {
6772
return nameGetter.getName(destination);
6873
} catch (Exception e) {
74+
logger.log(FINE, "Failure getting JMS destination name", e);
6975
return "unknown";
7076
}
7177
}

0 commit comments

Comments
 (0)