Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always create a JMS consumer span #10604

Merged
merged 5 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions instrumentation/jms/jms-1.1/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,40 @@ testing {
implementation("org.hornetq:hornetq-jms-client:2.4.7.Final")
implementation("org.hornetq:hornetq-jms-server:2.4.7.Final")
}

targets {
all {
testTask.configure {
jvmArgs("-Dotel.instrumentation.messaging.experimental.receive-telemetry.enabled=true")
}
}
}
}
}
}

tasks.withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
jvmArgs("-Dotel.instrumentation.messaging.experimental.receive-telemetry.enabled=true")
}

tasks {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}

val testReceiveSpansDisabled by registering(Test::class) {
filter {
includeTestsMatching("Jms1SuppressReceiveSpansTest")
}
include("**/Jms1SuppressReceiveSpansTest.*")
}

test {
filter {
excludeTestsMatching("Jms1SuppressReceiveSpansTest")
}
jvmArgs("-Dotel.instrumentation.messaging.experimental.receive-telemetry.enabled=true")
}

check {
dependsOn(testing.suites)
dependsOn(testReceiveSpansDisabled)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
import static io.opentelemetry.javaagent.instrumentation.jms.JmsReceiveSpanUtil.createReceiveSpan;
import static io.opentelemetry.javaagent.instrumentation.jms.v1_1.JmsSingletons.consumerReceiveInstrumenter;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.returns;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;

import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.internal.InstrumenterUtil;
import io.opentelemetry.instrumentation.api.internal.Timer;
import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
Expand Down Expand Up @@ -75,16 +75,7 @@ public static void stopSpan(
MessageWithDestination request =
MessageWithDestination.create(JavaxMessageAdapter.create(message), null);

if (consumerReceiveInstrumenter().shouldStart(parentContext, request)) {
InstrumenterUtil.startAndEnd(
consumerReceiveInstrumenter(),
parentContext,
request,
null,
throwable,
timer.startTime(),
timer.now());
}
createReceiveSpan(consumerReceiveInstrumenter(), request, timer, throwable);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public final class JmsSingletons {

PRODUCER_INSTRUMENTER = factory.createProducerInstrumenter();
CONSUMER_RECEIVE_INSTRUMENTER = factory.createConsumerReceiveInstrumenter();
CONSUMER_PROCESS_INSTRUMENTER = factory.createConsumerProcessInstrumenter();
CONSUMER_PROCESS_INSTRUMENTER = factory.createConsumerProcessInstrumenter(false);
}

public static Instrumenter<MessageWithDestination, Void> producerInstrumenter() {
Expand Down
Loading
Loading