Skip to content

Commit

Permalink
fix: fix license
Browse files Browse the repository at this point in the history
fix: recover tracing config name

fix: fix meterRegistry

fix: fix response error & change sender filter location

fix: fix error code
  • Loading branch information
conghuhu committed Jun 5, 2023
1 parent ee36985 commit 92e4f86
Show file tree
Hide file tree
Showing 26 changed files with 139 additions and 149 deletions.
11 changes: 0 additions & 11 deletions dubbo-cluster/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,5 @@
<version>${project.parent.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-integration-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-tracing</artifactId>
<version>${project.parent.version}</version>
<optional>true</optional>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ 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 @@ -55,7 +55,7 @@ public class TracingConfig extends AbstractConfig {
* Exporter configuration.
*/
@Nested
private ExporterConfig exporter = new ExporterConfig();
private ExporterConfig tracingExporter = new ExporterConfig();

public TracingConfig() {
}
Expand Down Expand Up @@ -96,11 +96,11 @@ public void setPropagation(PropagationConfig propagation) {
this.propagation = propagation;
}

public ExporterConfig getExporter() {
return exporter;
public ExporterConfig getTracingExporter() {
return tracingExporter;
}

public void setExporter(ExporterConfig exporter) {
this.exporter = exporter;
public void setTracingExporter(ExporterConfig tracingExporter) {
this.tracingExporter = tracingExporter;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ 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 @@ -76,6 +89,18 @@ 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 @@ -26,25 +26,25 @@
public class ExporterConfig implements Serializable {

@Nested
private ZipkinConfig zipkin;
private ZipkinConfig zipkinConfig;

@Nested
private OtlpConfig otlp;
private OtlpConfig otlpConfig;

public ZipkinConfig getZipkin() {
return zipkin;
public ZipkinConfig getZipkinConfig() {
return zipkinConfig;
}

public void setZipkin(ZipkinConfig zipkin) {
this.zipkin = zipkin;
public void setZipkinConfig(ZipkinConfig zipkinConfig) {
this.zipkinConfig = zipkinConfig;
}

public OtlpConfig getOtlp() {
return otlp;
public OtlpConfig getOtlpConfig() {
return otlpConfig;
}

public void setOtlp(OtlpConfig otlp) {
this.otlp = otlp;
public void setOtlpConfig(OtlpConfig otlpConfig) {
this.otlpConfig = otlpConfig;
}

public static class ZipkinConfig implements Serializable {
Expand All @@ -64,6 +64,19 @@ public static class ZipkinConfig implements Serializable {
*/
private Integer readTimeout = 10;

public ZipkinConfig() {
}

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

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

public String getEndpoint() {
return endpoint;
}
Expand Down Expand Up @@ -109,6 +122,24 @@ 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, Integer timeout) {
this.endpoint = endpoint;
this.timeout = timeout;
}

public OtlpConfig(String endpoint, Integer 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,6 +29,13 @@ 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,6 +25,13 @@ 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
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
import static org.apache.dubbo.common.constants.CommonConstants.REGISTRY_SPLIT_PATTERN;
import static org.apache.dubbo.common.constants.CommonConstants.REMOTE_METADATA_STORAGE_TYPE;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_METRICS_COLLECTOR_EXCEPTION;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_NOT_FOUND_TRACER_DEPENDENCY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_EXECUTE_DESTROY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_INIT_CONFIG_CENTER;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_START_MODEL;
Expand Down Expand Up @@ -470,7 +471,7 @@ private void initObservationRegistry() {

TracerProvider tracerProvider = TracerProviderFactory.getProvider(applicationModel, configOptional.get());
if (tracerProvider == null) {
logger.warn("Can not found OpenTelemetry/Brave tracer dependencies, skip init ObservationRegistry.");
logger.warn(COMMON_NOT_FOUND_TRACER_DEPENDENCY,"","","Can not found OpenTelemetry/Brave tracer dependencies, skip init ObservationRegistry.");
return;
}
// The real tracer will come from tracer implementation (OTel / Brave)
Expand All @@ -480,18 +481,20 @@ private void initObservationRegistry() {
PropagatorProvider propagatorProvider = PropagatorProviderFactory.getPropagatorProvider();
Propagator propagator = propagatorProvider != null ? propagatorProvider.getPropagator() : Propagator.NOOP;

MeterRegistry meterRegistry = MetricsGlobalRegistry.getCompositeRegistry(applicationModel);

ObservationRegistry registry = ObservationRegistry.create();
registry.observationConfig()
.observationHandler(new DefaultMeterObservationHandler(meterRegistry))
// set up a first matching handler that creates spans - it comes from Micrometer Tracing.
// set up spans for sending and receiving data over the wire and a default one.
.observationHandler(new ObservationHandler.FirstMatchingCompositeObservationHandler(
new PropagatingSenderTracingObservationHandler<>(tracer, propagator),
new PropagatingReceiverTracingObservationHandler<>(tracer, propagator),
new DefaultTracingObservationHandler(tracer)));

if (isSupportMetrics()) {
MeterRegistry meterRegistry = MetricsGlobalRegistry.getCompositeRegistry(applicationModel);
registry.observationConfig().observationHandler(new DefaultMeterObservationHandler(meterRegistry));
}

applicationModel.getBeanFactory().registerBean(registry);
applicationModel.getBeanFactory().registerBean(tracer);
applicationModel.getBeanFactory().registerBean(propagator);
Expand Down
1 change: 1 addition & 0 deletions dubbo-distribution/dubbo-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@
<include>org.apache.dubbo:dubbo-metrics-metadata</include>
<include>org.apache.dubbo:dubbo-metrics-config-center</include>
<include>org.apache.dubbo:dubbo-metrics-prometheus</include>
<include>org.apache.dubbo:dubbo-tracing</include>
<include>org.apache.dubbo:dubbo-monitor-api</include>
<include>org.apache.dubbo:dubbo-monitor-default</include>
<include>org.apache.dubbo:dubbo-qos</include>
Expand Down
1 change: 1 addition & 0 deletions dubbo-distribution/dubbo-core-spi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
<include>org.apache.dubbo:dubbo-metadata-api</include>
<include>org.apache.dubbo:dubbo-metrics-api</include>
<include>org.apache.dubbo:dubbo-metrics-default</include>
<include>org.apache.dubbo:dubbo-tracing</include>
<include>org.apache.dubbo:dubbo-monitor-api</include>
<include>org.apache.dubbo:dubbo-registry-api</include>
<include>org.apache.dubbo:dubbo-remoting-api</include>
Expand Down
5 changes: 5 additions & 0 deletions dubbo-metrics/dubbo-tracing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
<artifactId>dubbo-common</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-cluster</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-rpc-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public class TraceExporterFactory {
* for OTel
*/
public static List<SpanExporter> getSpanExporters(ApplicationModel applicationModel, ExporterConfig exporterConfig) {
ExporterConfig.ZipkinConfig zipkinConfig = exporterConfig.getZipkin();
ExporterConfig.OtlpConfig otlpConfig = exporterConfig.getOtlp();
ExporterConfig.ZipkinConfig zipkinConfig = exporterConfig.getZipkinConfig();
ExporterConfig.OtlpConfig otlpConfig = exporterConfig.getOtlpConfig();
List<SpanExporter> res = new ArrayList<>();
if (zipkinConfig != null && StringUtils.isNotEmpty(zipkinConfig.getEndpoint())) {
ZipkinExporter zipkinExporter = new ZipkinExporter(applicationModel, zipkinConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,8 @@ public class ObservationReceiverFilter implements Filter, BaseFilter.Listener, S
private DubboServerObservationConvention serverObservationConvention;

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

@Override
Expand All @@ -74,6 +70,9 @@ 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
Loading

0 comments on commit 92e4f86

Please sign in to comment.