GH-332 - Avoid proxying configuration classes for observability purposes.

We now skip configuration classes for observability-related proxying as it's hard to detect those during the ProxyFactory setup to configure target class proxying. Also, configuration classes are usually no targets of inter-module communication and thus don't need to be observed at all.
This commit is contained in:
Oliver Drotbohm
2023-10-16 21:11:30 +02:00
parent 1482ba01f5
commit 752b5d7cf3
4 changed files with 46 additions and 7 deletions

View File

@@ -0,0 +1,24 @@
/*
* Copyright 2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package example.sample;
import org.springframework.context.annotation.Configuration;
/**
* @author Oliver Drotbohm
*/
@Configuration
public class SampleConfiguration {}

View File

@@ -18,6 +18,7 @@ package org.springframework.modulith.observability;
import static org.assertj.core.api.Assertions.*;
import example.sample.SampleComponent;
import example.sample.SampleConfiguration;
import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.Advised;
@@ -55,6 +56,15 @@ public class ObservedModuleTypeUnitTests {
@Test // GH-106
void considersExposedTypeAsToBeIntercepted() {
assertThat(observedType.shouldBeTraced()).isTrue();
assertThat(observedType.shouldBeObserved()).isTrue();
}
@Test // GH-332
void doesNotObserveConfigurationClasses() {
var type = module.getArchitecturallyEvidentType(SampleConfiguration.class);
var observedType = new ObservedModuleType(modules, new DefaultObservedModule(module), type);
assertThat(observedType.shouldBeObserved()).isFalse();
}
}