Skip to content

Commit e8730ac

Browse files
Applied changes following the review
1 parent a257408 commit e8730ac

File tree

7 files changed

+56
-35
lines changed

7 files changed

+56
-35
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,11 @@ Propagation.Factory micrometerTracingPropagationWithBaggage(
258258
@Bean
259259
@ConditionalOnMissingBean(CorrelationScopeDecorator.class)
260260
@ConditionalOnBean(CorrelationScopeDecorator.Builder.class)
261-
@ConditionalOnProperty(value = "management.tracing.baggage.correlation-enabled", matchIfMissing = true)
261+
@ConditionalOnProperty(value = "management.tracing.baggage.correlation.enabled", matchIfMissing = true)
262262
ScopeDecorator correlationFieldsCorrelationScopeDecorator(TracingProperties properties,
263263
ObjectProvider<List<CorrelationScopeCustomizer>> correlationScopeCustomizers,
264264
CorrelationScopeDecorator.Builder builder) {
265-
List<String> correlationFields = properties.getBaggage().getCorrelationFields();
265+
List<String> correlationFields = properties.getBaggage().getCorrelation().getFields();
266266
for (String field : correlationFields) {
267267
builder.add(CorrelationScopeConfig.SingleCorrelationField.newBuilder(BaggageField.create(field))
268268
.flushOnUpdate().build());
@@ -275,7 +275,7 @@ ScopeDecorator correlationFieldsCorrelationScopeDecorator(TracingProperties prop
275275
@Bean
276276
@ConditionalOnMissingBean(CorrelationScopeDecorator.class)
277277
@ConditionalOnBean(CorrelationScopeDecorator.Builder.class)
278-
@ConditionalOnProperty(value = "management.tracing.baggage.correlation-enabled", havingValue = "false")
278+
@ConditionalOnProperty(value = "management.tracing.baggage.correlation.enabled", havingValue = "false")
279279
ScopeDecorator noCorrelationFieldsCorrelationScopeDecorator(CorrelationScopeDecorator.Builder builder,
280280
ObjectProvider<List<CorrelationScopeCustomizer>> correlationScopeCustomizers) {
281281
correlationScopeCustomizers.ifAvailable(

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/OpenTelemetryConfigurations.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,11 @@ static class Slf4jConfiguration {
274274

275275
@Bean
276276
@ConditionalOnMissingBean
277-
@ConditionalOnProperty(value = "management.tracing.baggage.correlation-enabled",
277+
@ConditionalOnProperty(value = "management.tracing.baggage.correlation.enabled",
278278
matchIfMissing = true)
279279
Slf4JBaggageEventListener otelSlf4JBaggageEventListener(TracingProperties tracingProperties) {
280-
return new Slf4JBaggageEventListener(tracingProperties.getBaggage().getCorrelationFields());
280+
return new Slf4JBaggageEventListener(
281+
tracingProperties.getBaggage().getCorrelation().getFields());
281282
}
282283

283284
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/TracingProperties.java

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,14 @@ public void setProbability(float probability) {
7777
public static class Baggage {
7878

7979
/**
80-
* Whether to enable correlation of the baggage context with logging contexts.
80+
* Whether to enable Micrometer Tracing baggage propagation.
8181
*/
82-
private boolean correlationEnabled = true;
82+
private boolean enabled;
8383

8484
/**
85-
* List of fields that should be correlated with the logging context. That means
86-
* that these fields would end up as key-value pairs in e.g. MDC.
85+
* Correlation configuration.
8786
*/
88-
private List<String> correlationFields = new ArrayList<>();
87+
private Correlation correlation = new Correlation();
8988

9089
/**
9190
* List of fields that are referenced the same in-process as it is on the wire.
@@ -94,20 +93,20 @@ public static class Baggage {
9493
*/
9594
private List<String> remoteFields = new ArrayList<>();
9695

97-
public boolean isCorrelationEnabled() {
98-
return this.correlationEnabled;
96+
public boolean isEnabled() {
97+
return this.enabled;
9998
}
10099

101-
public void setCorrelationEnabled(boolean correlationEnabled) {
102-
this.correlationEnabled = correlationEnabled;
100+
public void setEnabled(boolean enabled) {
101+
this.enabled = enabled;
103102
}
104103

105-
public List<String> getCorrelationFields() {
106-
return this.correlationFields;
104+
public Correlation getCorrelation() {
105+
return this.correlation;
107106
}
108107

109-
public void setCorrelationFields(List<String> correlationFields) {
110-
this.correlationFields = correlationFields;
108+
public void setCorrelation(Correlation correlation) {
109+
this.correlation = correlation;
111110
}
112111

113112
public List<String> getRemoteFields() {
@@ -118,6 +117,37 @@ public void setRemoteFields(List<String> remoteFields) {
118117
this.remoteFields = remoteFields;
119118
}
120119

120+
public static class Correlation {
121+
122+
/**
123+
* Whether to enable correlation of the baggage context with logging contexts.
124+
*/
125+
private boolean enabled = true;
126+
127+
/**
128+
* List of fields that should be correlated with the logging context. That
129+
* means that these fields would end up as key-value pairs in e.g. MDC.
130+
*/
131+
private List<String> fields = new ArrayList<>();
132+
133+
public boolean isEnabled() {
134+
return this.enabled;
135+
}
136+
137+
public void setEnabled(boolean enabled) {
138+
this.enabled = enabled;
139+
}
140+
141+
public List<String> getFields() {
142+
return this.fields;
143+
}
144+
145+
public void setFields(List<String> fields) {
146+
this.fields = fields;
147+
}
148+
149+
}
150+
121151
}
122152

123153
public static class Propagation {

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,19 +2087,9 @@
20872087
"level": "error"
20882088
}
20892089
},
2090-
{
2091-
"name": "management.tracing.baggage.enabled",
2092-
"type": "java.lang.Boolean",
2093-
"description": "Whether to enable Micrometer Tracing baggage propagation.",
2094-
"defaultValue": true
2095-
},
20962090
{
20972091
"name": "management.tracing.propagation.type",
20982092
"defaultValue": "W3C"
2099-
},
2100-
{
2101-
"name": "management.tracing.sampling.probability",
2102-
"defaultValue": "0.10"
21032093
}
21042094
],
21052095
"hints": [

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/BaggageAutoConfigurationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public ApplicationContextRunner get() {
140140
return new ApplicationContextRunner()
141141
.withConfiguration(AutoConfigurations.of(BraveAutoConfiguration.class)).withPropertyValues(
142142
"management.tracing.baggage.remote-fields=x-vcap-request-id,country-code,bp",
143-
"management.tracing.baggage.correlation-fields=country-code,bp");
143+
"management.tracing.baggage.correlation.fields=country-code,bp");
144144
}
145145
},
146146

@@ -151,7 +151,7 @@ public ApplicationContextRunner get() {
151151
.withConfiguration(AutoConfigurations.of(OpenTelemetryAutoConfiguration.class))
152152
.withPropertyValues(
153153
"management.tracing.baggage.remote-fields=x-vcap-request-id,country-code,bp",
154-
"management.tracing.baggage.correlation-fields=country-code,bp");
154+
"management.tracing.baggage.correlation.fields=country-code,bp");
155155
}
156156
},
157157

@@ -162,7 +162,7 @@ public ApplicationContextRunner get() {
162162
.withConfiguration(AutoConfigurations.of(BraveAutoConfiguration.class))
163163
.withPropertyValues("management.tracing.propagation.type=B3",
164164
"management.tracing.baggage.remote-fields=x-vcap-request-id,country-code,bp",
165-
"management.tracing.baggage.correlation-fields=country-code,bp");
165+
"management.tracing.baggage.correlation.fields=country-code,bp");
166166
}
167167
},
168168

@@ -173,7 +173,7 @@ public ApplicationContextRunner get() {
173173
.withConfiguration(AutoConfigurations.of(OpenTelemetryAutoConfiguration.class))
174174
.withPropertyValues("management.tracing.propagation.type=B3",
175175
"management.tracing.baggage.remote-fields=x-vcap-request-id,country-code,bp",
176-
"management.tracing.baggage.correlation-fields=country-code,bp");
176+
"management.tracing.baggage.correlation.fields=country-code,bp");
177177
}
178178
}
179179

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfigurationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,13 @@ void shouldSupplyB3WithoutBaggageIfBaggageDisabledAndB3Picked() {
230230

231231
@Test
232232
void shouldNotSupplyCorrelationScopeDecoratorIfBaggageCorrelationDisabled() {
233-
this.contextRunner.withPropertyValues("management.tracing.baggage.correlation-enabled=false")
233+
this.contextRunner.withPropertyValues("management.tracing.baggage.correlation.enabled=false")
234234
.run((context) -> assertThat(context).doesNotHaveBean("correlationFieldsCorrelationScopeDecorator"));
235235
}
236236

237237
@Test
238238
void shouldSupplyMdcCorrelationScopeDecoratorIfBaggageCorrelationDisabled() {
239-
this.contextRunner.withPropertyValues("management.tracing.baggage.correlation-enabled=false")
239+
this.contextRunner.withPropertyValues("management.tracing.baggage.correlation.enabled=false")
240240
.run((context) -> assertThat(context).hasBean("mdcCorrelationScopeDecoratorBuilder"));
241241
}
242242

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/OpenTelemetryConfigurationsMicrometerConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void shouldSupplyBaggageAndSlf4jEventListenersWhenMdcOnClasspath() {
119119
@Test
120120
void shouldSupplySlf4jEventListenersWhenMdcOnClasspathAndBaggageCorrelationDisabled() {
121121
this.contextRunner.withUserConfiguration(TracerConfiguration.class)
122-
.withPropertyValues("management.tracing.baggage.correlation-enabled=false").run((context) -> {
122+
.withPropertyValues("management.tracing.baggage.correlation.enabled=false").run((context) -> {
123123
assertThat(context).hasSingleBean(Slf4JEventListener.class);
124124
assertThat(context).doesNotHaveBean(Slf4JBaggageEventListener.class);
125125
});

0 commit comments

Comments
 (0)