Skip to content

Commit 6353393

Browse files
committed
Refactor zipkin properties in separate class
See spring-projectsgh-30156
1 parent 17b9f69 commit 6353393

File tree

3 files changed

+49
-32
lines changed

3 files changed

+49
-32
lines changed

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

-26
Original file line numberDiff line numberDiff line change
@@ -27,41 +27,15 @@
2727
@ConfigurationProperties("management.tracing")
2828
public class TracingProperties {
2929

30-
/**
31-
* Zipkin configuration.
32-
*/
33-
private final Zipkin zipkin = new Zipkin();
34-
3530
/**
3631
* Sampling configuration.
3732
*/
3833
private final Sampling sampling = new Sampling();
3934

40-
public Zipkin getZipkin() {
41-
return this.zipkin;
42-
}
43-
4435
public Sampling getSampling() {
4536
return this.sampling;
4637
}
4738

48-
public static class Zipkin {
49-
50-
/**
51-
* URL to the Zipkin API.
52-
*/
53-
private String endpoint = "http://localhost:9411/api/v2/spans";
54-
55-
public String getEndpoint() {
56-
return this.endpoint;
57-
}
58-
59-
public void setEndpoint(String endpoint) {
60-
this.endpoint = endpoint;
61-
}
62-
63-
}
64-
6539
public static class Sampling {
6640

6741
/**

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import zipkin2.reporter.brave.ZipkinSpanHandler;
2828
import zipkin2.reporter.urlconnection.URLConnectionSender;
2929

30-
import org.springframework.boot.actuate.autoconfigure.tracing.TracingProperties;
3130
import org.springframework.boot.autoconfigure.AutoConfiguration;
3231
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
3332
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
@@ -50,22 +49,23 @@
5049
public class ZipkinAutoConfiguration {
5150

5251
@Configuration(proxyBeanMethods = false)
53-
@EnableConfigurationProperties(TracingProperties.class)
52+
@EnableConfigurationProperties(ZipkinProperties.class)
5453
static class SenderConfiguration {
5554

5655
@Bean
5756
@ConditionalOnMissingBean
5857
@ConditionalOnClass(URLConnectionSender.class)
59-
public Sender urlConnectionSender(TracingProperties properties) {
60-
return URLConnectionSender.newBuilder().endpoint(properties.getZipkin().getEndpoint()).build();
58+
public Sender urlConnectionSender(ZipkinProperties properties) {
59+
return URLConnectionSender.newBuilder().endpoint(properties.getEndpoint()).build();
6160
}
6261

6362
@Bean
6463
@ConditionalOnMissingBean
6564
@ConditionalOnClass(RestTemplate.class)
66-
public Sender restTemplateSender(TracingProperties properties) {
67-
return new ZipkinRestTemplateSender(properties.getZipkin().getEndpoint(), new RestTemplate());
65+
public Sender restTemplateSender(ZipkinProperties properties) {
66+
return new ZipkinRestTemplateSender(properties.getEndpoint(), new RestTemplate());
6867
}
68+
6969
}
7070

7171
@Configuration(proxyBeanMethods = false)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2012-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.actuate.autoconfigure.tracing.zipkin;
18+
19+
import org.springframework.boot.context.properties.ConfigurationProperties;
20+
21+
/**
22+
* Configuration properties for {@link ZipkinAutoConfiguration}.
23+
*
24+
* @author Moritz Halbritter
25+
* @since 3.0.0
26+
*/
27+
@ConfigurationProperties("management.tracing.zipkin")
28+
public class ZipkinProperties {
29+
30+
/**
31+
* URL to the Zipkin API.
32+
*/
33+
private String endpoint = "http://localhost:9411/api/v2/spans";
34+
35+
public String getEndpoint() {
36+
return this.endpoint;
37+
}
38+
39+
public void setEndpoint(String endpoint) {
40+
this.endpoint = endpoint;
41+
}
42+
43+
}

0 commit comments

Comments
 (0)