Skip to content

Commit ea35f7e

Browse files
committed
Revert "refactor: migrate tracing core from boot-start to dubbo deployer (#12453)"
This reverts commit a613cae
1 parent 8ad792c commit ea35f7e

File tree

67 files changed

+250
-1452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+250
-1452
lines changed

.artifacts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,4 @@ dubbo-nacos-spring-boot-starter
114114
dubbo-zookeeper-spring-boot-starter
115115
dubbo-zookeeper-curator5-spring-boot-starter
116116
dubbo-spring-security
117-
dubbo-tracing
118117
dubbo-xds

dubbo-cluster/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,10 @@
8686
<version>${project.parent.version}</version>
8787
<optional>true</optional>
8888
</dependency>
89+
<dependency>
90+
<groupId>io.micrometer</groupId>
91+
<artifactId>micrometer-tracing-integration-test</artifactId>
92+
<scope>test</scope>
93+
</dependency>
8994
</dependencies>
9095
</project>
Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
package org.apache.dubbo.tracing.filter;
17+
package org.apache.dubbo.rpc.cluster.filter.support;
1818

1919
import org.apache.dubbo.common.extension.Activate;
20+
import org.apache.dubbo.metrics.observation.DefaultDubboClientObservationConvention;
21+
import org.apache.dubbo.metrics.observation.DubboClientContext;
22+
import org.apache.dubbo.metrics.observation.DubboClientObservationConvention;
23+
import org.apache.dubbo.metrics.observation.DubboObservationDocumentation;
2024
import org.apache.dubbo.rpc.BaseFilter;
2125
import org.apache.dubbo.rpc.Filter;
2226
import org.apache.dubbo.rpc.Invocation;
@@ -26,10 +30,6 @@
2630
import org.apache.dubbo.rpc.cluster.filter.ClusterFilter;
2731
import org.apache.dubbo.rpc.model.ApplicationModel;
2832
import org.apache.dubbo.rpc.model.ScopeModelAware;
29-
import org.apache.dubbo.tracing.DefaultDubboClientObservationConvention;
30-
import org.apache.dubbo.tracing.DubboClientObservationConvention;
31-
import org.apache.dubbo.tracing.DubboObservationDocumentation;
32-
import org.apache.dubbo.tracing.context.DubboClientContext;
3333

3434
import io.micrometer.observation.Observation;
3535
import io.micrometer.observation.ObservationRegistry;
@@ -39,16 +39,20 @@
3939
/**
4040
* A {@link Filter} that creates an {@link Observation} around the outgoing message.
4141
*/
42-
@Activate(group = CONSUMER, order = Integer.MIN_VALUE + 50, onClass = "io.micrometer.observation.NoopObservationRegistry")
42+
@Activate(group = CONSUMER, order = -1, onClass = "io.micrometer.observation.NoopObservationRegistry")
4343
public class ObservationSenderFilter implements ClusterFilter, BaseFilter.Listener, ScopeModelAware {
4444

4545
private ObservationRegistry observationRegistry;
4646

4747
private DubboClientObservationConvention clientObservationConvention;
4848

4949
public ObservationSenderFilter(ApplicationModel applicationModel) {
50-
observationRegistry = applicationModel.getBeanFactory().getBean(ObservationRegistry.class);
51-
clientObservationConvention = applicationModel.getBeanFactory().getBean(DubboClientObservationConvention.class);
50+
applicationModel.getApplicationConfigManager().getTracing().ifPresent(cfg -> {
51+
if (Boolean.TRUE.equals(cfg.getEnabled())) {
52+
observationRegistry = applicationModel.getBeanFactory().getBean(ObservationRegistry.class);
53+
clientObservationConvention = applicationModel.getBeanFactory().getBean(DubboClientObservationConvention.class);
54+
}
55+
});
5256
}
5357

5458
@Override
@@ -71,9 +75,6 @@ public void onResponse(Result appResponse, Invoker<?> invoker, Invocation invoca
7175
if (observation == null) {
7276
return;
7377
}
74-
if (appResponse != null && appResponse.hasException()) {
75-
observation.error(appResponse.getException());
76-
}
7778
observation.stop();
7879
}
7980

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
consumercontext=org.apache.dubbo.rpc.cluster.filter.support.ConsumerContextFilter
22
consumer-classloader=org.apache.dubbo.rpc.cluster.filter.support.ConsumerClassLoaderFilter
33
router-snapshot=org.apache.dubbo.rpc.cluster.router.RouterSnapshotFilter
4+
observationsender=org.apache.dubbo.rpc.cluster.filter.support.ObservationSenderFilter
45
metricsClusterFilter=org.apache.dubbo.rpc.cluster.filter.support.MetricsClusterFilter
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.dubbo.rpc.cluster.filter;
18+
19+
import org.apache.dubbo.config.ApplicationConfig;
20+
import org.apache.dubbo.config.TracingConfig;
21+
import org.apache.dubbo.rpc.AppResponse;
22+
import org.apache.dubbo.rpc.BaseFilter;
23+
import org.apache.dubbo.rpc.Invoker;
24+
import org.apache.dubbo.rpc.RpcInvocation;
25+
import org.apache.dubbo.rpc.model.ApplicationModel;
26+
27+
import io.micrometer.tracing.test.SampleTestRunner;
28+
import org.junit.jupiter.api.AfterEach;
29+
30+
import static org.mockito.BDDMockito.given;
31+
import static org.mockito.Mockito.mock;
32+
33+
abstract class AbstractObservationFilterTest extends SampleTestRunner {
34+
35+
ApplicationModel applicationModel;
36+
RpcInvocation invocation;
37+
38+
BaseFilter filter;
39+
40+
Invoker<?> invoker = mock(Invoker.class);
41+
42+
static final String INTERFACE_NAME = "org.apache.dubbo.MockInterface";
43+
static final String METHOD_NAME = "mockMethod";
44+
static final String GROUP = "mockGroup";
45+
static final String VERSION = "1.0.0";
46+
47+
@AfterEach
48+
public void teardown() {
49+
if (applicationModel != null) {
50+
applicationModel.destroy();
51+
}
52+
}
53+
54+
abstract BaseFilter createFilter(ApplicationModel applicationModel);
55+
56+
void setupConfig() {
57+
ApplicationConfig config = new ApplicationConfig();
58+
config.setName("MockObservations");
59+
60+
applicationModel = ApplicationModel.defaultModel();
61+
applicationModel.getApplicationConfigManager().setApplication(config);
62+
63+
invocation = new RpcInvocation(new MockInvocation());
64+
invocation.addInvokedInvoker(invoker);
65+
66+
applicationModel.getBeanFactory().registerBean(getObservationRegistry());
67+
TracingConfig tracingConfig = new TracingConfig();
68+
tracingConfig.setEnabled(true);
69+
applicationModel.getApplicationConfigManager().setTracing(tracingConfig);
70+
71+
filter = createFilter(applicationModel);
72+
73+
given(invoker.invoke(invocation)).willReturn(new AppResponse("success"));
74+
75+
initParam();
76+
}
77+
78+
private void initParam() {
79+
invocation.setTargetServiceUniqueName(GROUP + "/" + INTERFACE_NAME + ":" + VERSION);
80+
invocation.setMethodName(METHOD_NAME);
81+
invocation.setParameterTypes(new Class[] {String.class});
82+
}
83+
84+
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,23 @@
1515
* limitations under the License.
1616
*/
1717

18-
package org.apache.dubbo.tracing.filter;
18+
package org.apache.dubbo.rpc.cluster.filter;
1919

2020
import org.apache.dubbo.common.URL;
2121
import org.apache.dubbo.rpc.RpcContext;
22-
import org.apache.dubbo.rpc.cluster.filter.ClusterFilter;
22+
import org.apache.dubbo.rpc.cluster.filter.support.ObservationSenderFilter;
2323
import org.apache.dubbo.rpc.model.ApplicationModel;
2424

2525
import io.micrometer.common.KeyValues;
2626
import io.micrometer.core.tck.MeterRegistryAssert;
27+
import io.micrometer.tracing.test.SampleTestRunner;
2728
import io.micrometer.tracing.test.simple.SpansAssert;
2829
import org.assertj.core.api.BDDAssertions;
2930

3031
class ObservationSenderFilterTest extends AbstractObservationFilterTest {
3132

3233
@Override
33-
public SampleTestRunnerConsumer yourCode() {
34+
public SampleTestRunner.SampleTestRunnerConsumer yourCode() {
3435
return (buildingBlocks, meterRegistry) -> {
3536
setupConfig();
3637
setupAttachments();

dubbo-common/src/main/java/org/apache/dubbo/common/constants/LoggerCodeConstants.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ public interface LoggerCodeConstants {
9292

9393
String VULNERABILITY_WARNING = "0-28";
9494

95-
String COMMON_NOT_FOUND_TRACER_DEPENDENCY = "0-29";
96-
9795

9896
// Registry module
9997

dubbo-common/src/main/java/org/apache/dubbo/config/nested/BaggageConfig.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,6 @@ public class BaggageConfig implements Serializable {
3939
*/
4040
private List<String> remoteFields = new ArrayList<>();
4141

42-
public BaggageConfig() {
43-
}
44-
45-
public BaggageConfig(Boolean enabled) {
46-
this.enabled = enabled;
47-
}
48-
49-
public BaggageConfig(Boolean enabled, Correlation correlation, List<String> remoteFields) {
50-
this.enabled = enabled;
51-
this.correlation = correlation;
52-
this.remoteFields = remoteFields;
53-
}
54-
5542
public Boolean getEnabled() {
5643
return enabled;
5744
}
@@ -89,18 +76,6 @@ public static class Correlation implements Serializable {
8976
*/
9077
private List<String> fields = new ArrayList<>();
9178

92-
public Correlation() {
93-
}
94-
95-
public Correlation(boolean enabled) {
96-
this.enabled = enabled;
97-
}
98-
99-
public Correlation(boolean enabled, List<String> fields) {
100-
this.enabled = enabled;
101-
this.fields = fields;
102-
}
103-
10479
public boolean isEnabled() {
10580
return this.enabled;
10681
}

dubbo-common/src/main/java/org/apache/dubbo/config/nested/ExporterConfig.java

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,15 @@ public static class ZipkinConfig implements Serializable {
5656
private String endpoint;
5757

5858
/**
59-
* Connection timeout for requests to Zipkin. (seconds)
59+
* Connection timeout for requests to Zipkin.
6060
*/
6161
private Duration connectTimeout = Duration.ofSeconds(1);
6262

6363
/**
64-
* Read timeout for requests to Zipkin. (seconds)
64+
* Read timeout for requests to Zipkin.
6565
*/
6666
private Duration readTimeout = Duration.ofSeconds(10);
6767

68-
public ZipkinConfig() {
69-
}
70-
71-
public ZipkinConfig(String endpoint) {
72-
this.endpoint = endpoint;
73-
}
74-
75-
public ZipkinConfig(String endpoint, Duration connectTimeout, Duration readTimeout) {
76-
this.endpoint = endpoint;
77-
this.connectTimeout = connectTimeout;
78-
this.readTimeout = readTimeout;
79-
}
80-
8168
public String getEndpoint() {
8269
return endpoint;
8370
}
@@ -111,7 +98,7 @@ public static class OtlpConfig implements Serializable {
11198
private String endpoint;
11299

113100
/**
114-
* The maximum time to wait for the collector to process an exported batch of spans. (seconds)
101+
* The maximum time to wait for the collector to process an exported batch of spans.
115102
*/
116103
private Duration timeout = Duration.ofSeconds(10);
117104

@@ -123,24 +110,6 @@ public static class OtlpConfig implements Serializable {
123110

124111
private Map<String, String> headers = new HashMap<>();
125112

126-
public OtlpConfig() {
127-
}
128-
129-
public OtlpConfig(String endpoint) {
130-
this.endpoint = endpoint;
131-
}
132-
133-
public OtlpConfig(String endpoint, Duration timeout) {
134-
this.endpoint = endpoint;
135-
this.timeout = timeout;
136-
}
137-
138-
public OtlpConfig(String endpoint, Duration timeout, String compressionMethod) {
139-
this.endpoint = endpoint;
140-
this.timeout = timeout;
141-
this.compressionMethod = compressionMethod;
142-
}
143-
144113
public String getEndpoint() {
145114
return endpoint;
146115
}

dubbo-common/src/main/java/org/apache/dubbo/config/nested/PropagationConfig.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ public class PropagationConfig implements Serializable {
2929
*/
3030
private String type = W3C;
3131

32-
public PropagationConfig() {
33-
}
34-
35-
public PropagationConfig(String type) {
36-
this.type = type;
37-
}
38-
3932
public String getType() {
4033
return type;
4134
}

0 commit comments

Comments
 (0)