Skip to content

Commit

Permalink
Fix spring jms listener instrumentation (#3359)
Browse files Browse the repository at this point in the history
* Fix Spring JMS listener instrumentation

* Comment

* More allows
  • Loading branch information
trask authored and Anuraag Agrawal committed Jun 23, 2021
1 parent 5242ef2 commit 1deb81a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ public class AdditionalLibraryIgnoredTypesConfigurer implements IgnoredTypesConf

@Override
public void configure(Config config, IgnoredTypesBuilder builder) {
if (!config.getBooleanProperty(ADDITIONAL_LIBRARY_IGNORES_ENABLED, true)) {
return;
if (config.getBooleanProperty(ADDITIONAL_LIBRARY_IGNORES_ENABLED, true)) {
configure(builder);
}
}

// only used by tests (to bypass the ignores check)
public void configure(IgnoredTypesBuilder builder) {
builder
.ignoreClass("com.beust.jcommander.")
.ignoreClass("com.fasterxml.classmate.")
Expand Down Expand Up @@ -76,7 +79,14 @@ public void configure(Config config, IgnoredTypesBuilder builder) {

builder
.ignoreClass("org.springframework.amqp.")
.allowClass("org.springframework.amqp.rabbit.connection.");
.allowClass("org.springframework.amqp.rabbit.connection.")
.allowClass("org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer")
// these implement Runnable, so tests currently force these allows
// though not sure if it's important or not that they get instrumented
.allowClass(
"org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer")
.allowClass(
"org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry$AggregatingCallback");

builder
.ignoreClass("org.springframework.beans.")
Expand Down Expand Up @@ -146,8 +156,8 @@ public void configure(Config config, IgnoredTypesBuilder builder) {

builder
.ignoreClass("org.springframework.jms.")
.ignoreClass("org.springframework.jms.listener.")
.ignoreClass(
.allowClass("org.springframework.jms.listener.")
.allowClass(
"org.springframework.jms.config.JmsListenerEndpointRegistry$AggregatingCallback");

builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public void afterTestClass() {
assert TestAgentListenerAccess.getInstrumentationErrorCount() == 0
: TestAgentListenerAccess.getInstrumentationErrorCount()
+ " Instrumentation errors during test";
// additional library ignores are ignored during tests, because they can make it really
// confusing for contributors wondering why their instrumentation is not applied
//
// but we then need to make sure that the additional library ignores won't then silently prevent
// the instrumentation from being applied in real life outside of these tests
assert TestAgentListenerAccess.getIgnoredButTransformedClassNames().isEmpty()
: "Transformed classes match global libraries ignore matcher: "
+ TestAgentListenerAccess.getIgnoredButTransformedClassNames();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package io.opentelemetry.javaagent.testing.bytebuddy;

import io.opentelemetry.instrumentation.api.config.Config;
import io.opentelemetry.javaagent.tooling.ignore.AdditionalLibraryIgnoredTypesConfigurer;
import io.opentelemetry.javaagent.tooling.ignore.IgnoreAllow;
import io.opentelemetry.javaagent.tooling.ignore.IgnoredTypesBuilderImpl;
Expand Down Expand Up @@ -33,7 +32,7 @@ public class TestAgentListener implements AgentBuilder.Listener {

static {
IgnoredTypesBuilderImpl builder = new IgnoredTypesBuilderImpl();
new AdditionalLibraryIgnoredTypesConfigurer().configure(Config.get(), builder);
new AdditionalLibraryIgnoredTypesConfigurer().configure(builder);
ADDITIONAL_LIBRARIES_TRIE = builder.buildIgnoredTypesTrie();
}

Expand Down

0 comments on commit 1deb81a

Please sign in to comment.