Skip to content

Commit aeb8689

Browse files
committed
Add tests validating the behavior of service.namespace configuration to OpenTelemetryAutoconfiguration
Signed-off-by: Vanio Begic <vanio.begic123@gmail.com>
1 parent 7e21d52 commit aeb8689

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/opentelemetry/OpenTelemetryAutoConfigurationTests.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,22 @@ void shouldNotApplySpringApplicationGroupIfNotSet() {
106106
});
107107
}
108108

109+
@Test
110+
void shouldApplyServiceNamespaceIfApplicationGroupIsSet() {
111+
this.runner.withPropertyValues("spring.application.group=my-group").run((context) -> {
112+
Resource resource = context.getBean(Resource.class);
113+
assertThat(resource.getAttributes().asMap()).containsEntry(AttributeKey.stringKey("service.namespace"), "my-group");
114+
});
115+
}
116+
117+
@Test
118+
void shouldNOtApplyServiceNamespaceIfApplicationGroupIsNotSet() {
119+
this.runner.run((context -> {
120+
Resource resource = context.getBean(Resource.class);
121+
assertThat(resource.getAttributes().asMap()).doesNotContainKey(AttributeKey.stringKey("service.namespace"));
122+
}));
123+
}
124+
109125
@Test
110126
void shouldFallbackToDefaultApplicationNameIfSpringApplicationNameIsNotSet() {
111127
this.runner.run((context) -> {

0 commit comments

Comments
 (0)