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

Fix spring jms listener instrumentation #3359

Merged
merged 3 commits into from
Jun 21, 2021
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
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(
Comment on lines +159 to +160
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops 🙈

"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