Skip to content

Commit 072bce0

Browse files
authored
Review fixes for jms-3.0:javaagent (#18095)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
1 parent ce6751c commit 072bce0

3 files changed

Lines changed: 15 additions & 13 deletions

File tree

instrumentation/jms/jms-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jms/v3_0/JmsSingletons.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
public class JmsSingletons {
1515
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jms-3.0";
1616

17-
private static final Instrumenter<MessageWithDestination, Void> PRODUCER_INSTRUMENTER;
18-
private static final Instrumenter<MessageWithDestination, Void> CONSUMER_RECEIVE_INSTRUMENTER;
19-
private static final Instrumenter<MessageWithDestination, Void> CONSUMER_PROCESS_INSTRUMENTER;
17+
private static final Instrumenter<MessageWithDestination, Void> producerInstrumenter;
18+
private static final Instrumenter<MessageWithDestination, Void> consumerReceiveInstrumenter;
19+
private static final Instrumenter<MessageWithDestination, Void> consumerProcessInstrumenter;
2020

2121
static {
2222
JmsInstrumenterFactory factory =
@@ -25,21 +25,21 @@ public class JmsSingletons {
2525
.setMessagingReceiveTelemetryEnabled(
2626
ExperimentalConfig.get().messagingReceiveInstrumentationEnabled());
2727

28-
PRODUCER_INSTRUMENTER = factory.createProducerInstrumenter();
29-
CONSUMER_RECEIVE_INSTRUMENTER = factory.createConsumerReceiveInstrumenter();
30-
CONSUMER_PROCESS_INSTRUMENTER = factory.createConsumerProcessInstrumenter(false);
28+
producerInstrumenter = factory.createProducerInstrumenter();
29+
consumerReceiveInstrumenter = factory.createConsumerReceiveInstrumenter();
30+
consumerProcessInstrumenter = factory.createConsumerProcessInstrumenter(false);
3131
}
3232

3333
public static Instrumenter<MessageWithDestination, Void> producerInstrumenter() {
34-
return PRODUCER_INSTRUMENTER;
34+
return producerInstrumenter;
3535
}
3636

3737
public static Instrumenter<MessageWithDestination, Void> consumerReceiveInstrumenter() {
38-
return CONSUMER_RECEIVE_INSTRUMENTER;
38+
return consumerReceiveInstrumenter;
3939
}
4040

4141
public static Instrumenter<MessageWithDestination, Void> consumerProcessInstrumenter() {
42-
return CONSUMER_PROCESS_INSTRUMENTER;
42+
return consumerProcessInstrumenter;
4343
}
4444

4545
private JmsSingletons() {}

instrumentation/jms/jms-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jms/v3_0/AbstractJms3Test.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static void tearDown() throws JMSException {
108108
@ParameterizedTest
109109
@MethodSource("destinationArguments")
110110
void testMessageListener(DestinationFactory destinationFactory, boolean isTemporary)
111-
throws Exception {
111+
throws JMSException {
112112

113113
// given
114114
Destination destination = destinationFactory.create(session);
@@ -129,7 +129,7 @@ void testMessageListener(DestinationFactory destinationFactory, boolean isTempor
129129
testing.runWithSpan("parent", () -> producer.send(destination, sentMessage));
130130

131131
// then
132-
TextMessage receivedMessage = receivedMessageFuture.get(10, SECONDS);
132+
TextMessage receivedMessage = receivedMessageFuture.orTimeout(10, SECONDS).join();
133133
assertThat(receivedMessage.getText()).isEqualTo(sentMessage.getText());
134134

135135
String actualDestinationName = ((ActiveMQDestination) destination).getName();
@@ -186,7 +186,7 @@ void shouldNotEmitTelemetryOnEmptyReceive(
186186
@ParameterizedTest
187187
@MethodSource("destinationArguments")
188188
void shouldCaptureMessageHeaders(DestinationFactory destinationFactory, boolean isTemporary)
189-
throws Exception {
189+
throws JMSException {
190190

191191
// given
192192
Destination destination = destinationFactory.create(session);
@@ -209,7 +209,7 @@ void shouldCaptureMessageHeaders(DestinationFactory destinationFactory, boolean
209209
testing.runWithSpan("parent", () -> producer.send(sentMessage));
210210

211211
// then
212-
TextMessage receivedMessage = receivedMessageFuture.get(10, SECONDS);
212+
TextMessage receivedMessage = receivedMessageFuture.orTimeout(10, SECONDS).join();
213213
assertThat(receivedMessage.getText()).isEqualTo(sentMessage.getText());
214214

215215
String actualDestinationName = ((ActiveMQDestination) destination).getName();

instrumentation/jms/jms-3.0/metadata.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ semantic_conventions:
77
library_link: https://jakarta.ee/specifications/messaging/3.0/
88
configurations:
99
- name: otel.instrumentation.messaging.experimental.receive-telemetry.enabled
10+
declarative_name: java.common.messaging.receive_telemetry/development.enabled
1011
description: >
1112
Enables experimental receive telemetry, which will cause consumers to start a new trace, with
1213
only a span link connecting it to the producer trace.
1314
type: boolean
1415
default: false
1516
- name: otel.instrumentation.messaging.experimental.capture-headers
17+
declarative_name: java.common.messaging.capture_headers/development
1618
description: >
1719
Enables capturing messaging headers as span attributes. Provide a comma-separated list of
1820
header names to capture.

0 commit comments

Comments
 (0)