Skip to content

Commit

Permalink
Revert "refactor: migrate tracing core from boot-start to dubbo deplo…
Browse files Browse the repository at this point in the history
…yer (apache#12453)"

This reverts commit a613cae
  • Loading branch information
AlbumenJ committed Jun 20, 2023
1 parent 8ad792c commit ea35f7e
Show file tree
Hide file tree
Showing 67 changed files with 250 additions and 1,452 deletions.
1 change: 0 additions & 1 deletion .artifacts
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,4 @@ dubbo-nacos-spring-boot-starter
dubbo-zookeeper-spring-boot-starter
dubbo-zookeeper-curator5-spring-boot-starter
dubbo-spring-security
dubbo-tracing
dubbo-xds
5 changes: 5 additions & 0 deletions dubbo-cluster/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,10 @@
<version>${project.parent.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-integration-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.tracing.filter;
package org.apache.dubbo.rpc.cluster.filter.support;

import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.metrics.observation.DefaultDubboClientObservationConvention;
import org.apache.dubbo.metrics.observation.DubboClientContext;
import org.apache.dubbo.metrics.observation.DubboClientObservationConvention;
import org.apache.dubbo.metrics.observation.DubboObservationDocumentation;
import org.apache.dubbo.rpc.BaseFilter;
import org.apache.dubbo.rpc.Filter;
import org.apache.dubbo.rpc.Invocation;
Expand All @@ -26,10 +30,6 @@
import org.apache.dubbo.rpc.cluster.filter.ClusterFilter;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.rpc.model.ScopeModelAware;
import org.apache.dubbo.tracing.DefaultDubboClientObservationConvention;
import org.apache.dubbo.tracing.DubboClientObservationConvention;
import org.apache.dubbo.tracing.DubboObservationDocumentation;
import org.apache.dubbo.tracing.context.DubboClientContext;

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

private ObservationRegistry observationRegistry;

private DubboClientObservationConvention clientObservationConvention;

public ObservationSenderFilter(ApplicationModel applicationModel) {
observationRegistry = applicationModel.getBeanFactory().getBean(ObservationRegistry.class);
clientObservationConvention = applicationModel.getBeanFactory().getBean(DubboClientObservationConvention.class);
applicationModel.getApplicationConfigManager().getTracing().ifPresent(cfg -> {
if (Boolean.TRUE.equals(cfg.getEnabled())) {
observationRegistry = applicationModel.getBeanFactory().getBean(ObservationRegistry.class);
clientObservationConvention = applicationModel.getBeanFactory().getBean(DubboClientObservationConvention.class);
}
});
}

@Override
Expand All @@ -71,9 +75,6 @@ public void onResponse(Result appResponse, Invoker<?> invoker, Invocation invoca
if (observation == null) {
return;
}
if (appResponse != null && appResponse.hasException()) {
observation.error(appResponse.getException());
}
observation.stop();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
consumercontext=org.apache.dubbo.rpc.cluster.filter.support.ConsumerContextFilter
consumer-classloader=org.apache.dubbo.rpc.cluster.filter.support.ConsumerClassLoaderFilter
router-snapshot=org.apache.dubbo.rpc.cluster.router.RouterSnapshotFilter
observationsender=org.apache.dubbo.rpc.cluster.filter.support.ObservationSenderFilter
metricsClusterFilter=org.apache.dubbo.rpc.cluster.filter.support.MetricsClusterFilter
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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
*
* http://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 org.apache.dubbo.rpc.cluster.filter;

import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.TracingConfig;
import org.apache.dubbo.rpc.AppResponse;
import org.apache.dubbo.rpc.BaseFilter;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.RpcInvocation;
import org.apache.dubbo.rpc.model.ApplicationModel;

import io.micrometer.tracing.test.SampleTestRunner;
import org.junit.jupiter.api.AfterEach;

import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;

abstract class AbstractObservationFilterTest extends SampleTestRunner {

ApplicationModel applicationModel;
RpcInvocation invocation;

BaseFilter filter;

Invoker<?> invoker = mock(Invoker.class);

static final String INTERFACE_NAME = "org.apache.dubbo.MockInterface";
static final String METHOD_NAME = "mockMethod";
static final String GROUP = "mockGroup";
static final String VERSION = "1.0.0";

@AfterEach
public void teardown() {
if (applicationModel != null) {
applicationModel.destroy();
}
}

abstract BaseFilter createFilter(ApplicationModel applicationModel);

void setupConfig() {
ApplicationConfig config = new ApplicationConfig();
config.setName("MockObservations");

applicationModel = ApplicationModel.defaultModel();
applicationModel.getApplicationConfigManager().setApplication(config);

invocation = new RpcInvocation(new MockInvocation());
invocation.addInvokedInvoker(invoker);

applicationModel.getBeanFactory().registerBean(getObservationRegistry());
TracingConfig tracingConfig = new TracingConfig();
tracingConfig.setEnabled(true);
applicationModel.getApplicationConfigManager().setTracing(tracingConfig);

filter = createFilter(applicationModel);

given(invoker.invoke(invocation)).willReturn(new AppResponse("success"));

initParam();
}

private void initParam() {
invocation.setTargetServiceUniqueName(GROUP + "/" + INTERFACE_NAME + ":" + VERSION);
invocation.setMethodName(METHOD_NAME);
invocation.setParameterTypes(new Class[] {String.class});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@
* limitations under the License.
*/

package org.apache.dubbo.tracing.filter;
package org.apache.dubbo.rpc.cluster.filter;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.rpc.RpcContext;
import org.apache.dubbo.rpc.cluster.filter.ClusterFilter;
import org.apache.dubbo.rpc.cluster.filter.support.ObservationSenderFilter;
import org.apache.dubbo.rpc.model.ApplicationModel;

import io.micrometer.common.KeyValues;
import io.micrometer.core.tck.MeterRegistryAssert;
import io.micrometer.tracing.test.SampleTestRunner;
import io.micrometer.tracing.test.simple.SpansAssert;
import org.assertj.core.api.BDDAssertions;

class ObservationSenderFilterTest extends AbstractObservationFilterTest {

@Override
public SampleTestRunnerConsumer yourCode() {
public SampleTestRunner.SampleTestRunnerConsumer yourCode() {
return (buildingBlocks, meterRegistry) -> {
setupConfig();
setupAttachments();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ public interface LoggerCodeConstants {

String VULNERABILITY_WARNING = "0-28";

String COMMON_NOT_FOUND_TRACER_DEPENDENCY = "0-29";


// Registry module

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,6 @@ public class BaggageConfig implements Serializable {
*/
private List<String> remoteFields = new ArrayList<>();

public BaggageConfig() {
}

public BaggageConfig(Boolean enabled) {
this.enabled = enabled;
}

public BaggageConfig(Boolean enabled, Correlation correlation, List<String> remoteFields) {
this.enabled = enabled;
this.correlation = correlation;
this.remoteFields = remoteFields;
}

public Boolean getEnabled() {
return enabled;
}
Expand Down Expand Up @@ -89,18 +76,6 @@ public static class Correlation implements Serializable {
*/
private List<String> fields = new ArrayList<>();

public Correlation() {
}

public Correlation(boolean enabled) {
this.enabled = enabled;
}

public Correlation(boolean enabled, List<String> fields) {
this.enabled = enabled;
this.fields = fields;
}

public boolean isEnabled() {
return this.enabled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,15 @@ public static class ZipkinConfig implements Serializable {
private String endpoint;

/**
* Connection timeout for requests to Zipkin. (seconds)
* Connection timeout for requests to Zipkin.
*/
private Duration connectTimeout = Duration.ofSeconds(1);

/**
* Read timeout for requests to Zipkin. (seconds)
* Read timeout for requests to Zipkin.
*/
private Duration readTimeout = Duration.ofSeconds(10);

public ZipkinConfig() {
}

public ZipkinConfig(String endpoint) {
this.endpoint = endpoint;
}

public ZipkinConfig(String endpoint, Duration connectTimeout, Duration readTimeout) {
this.endpoint = endpoint;
this.connectTimeout = connectTimeout;
this.readTimeout = readTimeout;
}

public String getEndpoint() {
return endpoint;
}
Expand Down Expand Up @@ -111,7 +98,7 @@ public static class OtlpConfig implements Serializable {
private String endpoint;

/**
* The maximum time to wait for the collector to process an exported batch of spans. (seconds)
* The maximum time to wait for the collector to process an exported batch of spans.
*/
private Duration timeout = Duration.ofSeconds(10);

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

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

public OtlpConfig() {
}

public OtlpConfig(String endpoint) {
this.endpoint = endpoint;
}

public OtlpConfig(String endpoint, Duration timeout) {
this.endpoint = endpoint;
this.timeout = timeout;
}

public OtlpConfig(String endpoint, Duration timeout, String compressionMethod) {
this.endpoint = endpoint;
this.timeout = timeout;
this.compressionMethod = compressionMethod;
}

public String getEndpoint() {
return endpoint;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ public class PropagationConfig implements Serializable {
*/
private String type = W3C;

public PropagationConfig() {
}

public PropagationConfig(String type) {
this.type = type;
}

public String getType() {
return type;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ public class SamplingConfig implements Serializable {
*/
private float probability = 0.10f;

public SamplingConfig() {
}

public SamplingConfig(float probability) {
this.probability = probability;
}

public float getProbability() {
return this.probability;
}
Expand Down
6 changes: 0 additions & 6 deletions dubbo-config/dubbo-config-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-tracing</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-monitor-api</artifactId>
Expand Down
Loading

0 comments on commit ea35f7e

Please sign in to comment.