chore: recover dubbo-spring-boot-observability-starter to compatible … (#12124)
* chore: recover dubbo-spring-boot-observability-starter to compatible with v3.2.0 * add license * fix: change tracing
This commit is contained in:
parent
3fdd66752a
commit
48bd823253
|
|
@ -102,10 +102,11 @@ dubbo-spring-boot-actuator-compatible
|
|||
dubbo-spring-boot-autoconfigure
|
||||
dubbo-spring-boot-autoconfigure-compatible
|
||||
dubbo-spring-boot-compatible
|
||||
dubbo-spring-boot-observability-starter
|
||||
dubbo-spring-boot-observability-starters
|
||||
dubbo-spring-boot-observability-autoconfigure
|
||||
dubbo-spring-boot-tracing-brave-zipkin-starter
|
||||
dubbo-spring-boot-tracing-otel-zipkin-starter
|
||||
dubbo-spring-boot-observability-starter
|
||||
dubbo-spring-boot-starter
|
||||
dubbo-spring-security
|
||||
dubbo-xds
|
||||
|
|
|
|||
|
|
@ -504,7 +504,7 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-spring-boot-observability-starter</artifactId>
|
||||
<artifactId>dubbo-spring-boot-observability-starters</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
@ -522,6 +522,11 @@
|
|||
<artifactId>dubbo-spring-boot-tracing-brave-zipkin-starter</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-spring-boot-observability-starter</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- test -->
|
||||
<dependency>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>dubbo-spring-boot-observability-starter</artifactId>
|
||||
<artifactId>dubbo-spring-boot-observability-starters</artifactId>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.apache.dubbo.spring.boot.observability.autoconfigure.brave;
|
||||
|
||||
import org.apache.dubbo.config.ApplicationConfig;
|
||||
import org.apache.dubbo.rpc.model.ModuleModel;
|
||||
import org.apache.dubbo.spring.boot.autoconfigure.DubboConfigurationProperties;
|
||||
import org.apache.dubbo.spring.boot.observability.autoconfigure.DubboMicrometerTracingAutoConfiguration;
|
||||
import org.apache.dubbo.spring.boot.observability.autoconfigure.ObservabilityUtils;
|
||||
|
|
@ -31,7 +33,6 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
|
@ -54,6 +55,12 @@ public class BraveAutoConfiguration {
|
|||
*/
|
||||
private static final String DEFAULT_APPLICATION_NAME = "application";
|
||||
|
||||
private final ModuleModel moduleModel;
|
||||
|
||||
public BraveAutoConfiguration(ModuleModel moduleModel) {
|
||||
this.moduleModel = moduleModel;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
|
|
@ -66,10 +73,12 @@ public class BraveAutoConfiguration {
|
|||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public brave.Tracing braveTracing(Environment environment, List<brave.handler.SpanHandler> spanHandlers,
|
||||
public brave.Tracing braveTracing(List<brave.handler.SpanHandler> spanHandlers,
|
||||
List<brave.TracingCustomizer> tracingCustomizers, brave.propagation.CurrentTraceContext currentTraceContext,
|
||||
brave.propagation.Propagation.Factory propagationFactory, brave.sampler.Sampler sampler) {
|
||||
String applicationName = environment.getProperty("spring.application.name", DEFAULT_APPLICATION_NAME);
|
||||
String applicationName = moduleModel.getApplicationModel().getApplicationConfigManager().getApplication()
|
||||
.map(ApplicationConfig::getName)
|
||||
.orElse(DEFAULT_APPLICATION_NAME);
|
||||
brave.Tracing.Builder builder = brave.Tracing.newBuilder().currentTraceContext(currentTraceContext).traceId128Bit(true)
|
||||
.supportsJoin(false).propagationFactory(propagationFactory).sampler(sampler)
|
||||
.localServiceName(applicationName);
|
||||
|
|
@ -18,10 +18,12 @@ package org.apache.dubbo.spring.boot.observability.autoconfigure.otel;
|
|||
|
||||
|
||||
import org.apache.dubbo.common.Version;
|
||||
import org.apache.dubbo.config.ApplicationConfig;
|
||||
import org.apache.dubbo.rpc.model.ModuleModel;
|
||||
import org.apache.dubbo.spring.boot.autoconfigure.DubboConfigurationProperties;
|
||||
import org.apache.dubbo.spring.boot.observability.autoconfigure.annotation.ConditionalOnDubboTracingEnable ;
|
||||
import org.apache.dubbo.spring.boot.observability.autoconfigure.DubboMicrometerTracingAutoConfiguration;
|
||||
import org.apache.dubbo.spring.boot.observability.autoconfigure.ObservabilityUtils;
|
||||
import org.apache.dubbo.spring.boot.observability.autoconfigure.annotation.ConditionalOnDubboTracingEnable;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
|
|
@ -31,7 +33,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
|
@ -43,8 +44,8 @@ import java.util.stream.Collectors;
|
|||
@AutoConfiguration(before = DubboMicrometerTracingAutoConfiguration.class, afterName = "org.springframework.boot.actuate.autoconfigure.tracing.OpenTelemetryAutoConfiguration")
|
||||
@ConditionalOnDubboTracingEnable
|
||||
@ConditionalOnClass(name = {"io.micrometer.tracing.otel.bridge.OtelTracer",
|
||||
"io.opentelemetry.sdk.trace.SdkTracerProvider", "io.opentelemetry.api.OpenTelemetry"
|
||||
, "io.micrometer.tracing.SpanCustomizer"})
|
||||
"io.opentelemetry.sdk.trace.SdkTracerProvider", "io.opentelemetry.api.OpenTelemetry"
|
||||
, "io.micrometer.tracing.SpanCustomizer"})
|
||||
@EnableConfigurationProperties(DubboConfigurationProperties.class)
|
||||
public class OpenTelemetryAutoConfiguration {
|
||||
|
||||
|
|
@ -55,24 +56,29 @@ public class OpenTelemetryAutoConfiguration {
|
|||
|
||||
private final DubboConfigurationProperties dubboConfigProperties;
|
||||
|
||||
OpenTelemetryAutoConfiguration(DubboConfigurationProperties dubboConfigProperties) {
|
||||
private final ModuleModel moduleModel;
|
||||
|
||||
OpenTelemetryAutoConfiguration(DubboConfigurationProperties dubboConfigProperties, ModuleModel moduleModel) {
|
||||
this.dubboConfigProperties = dubboConfigProperties;
|
||||
this.moduleModel = moduleModel;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
io.opentelemetry.api.OpenTelemetry openTelemetry(io.opentelemetry.sdk.trace.SdkTracerProvider sdkTracerProvider, io.opentelemetry.context.propagation.ContextPropagators contextPropagators) {
|
||||
return io.opentelemetry.sdk.OpenTelemetrySdk.builder().setTracerProvider(sdkTracerProvider).setPropagators(contextPropagators)
|
||||
.build();
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
io.opentelemetry.sdk.trace.SdkTracerProvider otelSdkTracerProvider(Environment environment, ObjectProvider<io.opentelemetry.sdk.trace.SpanProcessor> spanProcessors,
|
||||
io.opentelemetry.sdk.trace.SdkTracerProvider otelSdkTracerProvider(ObjectProvider<io.opentelemetry.sdk.trace.SpanProcessor> spanProcessors,
|
||||
io.opentelemetry.sdk.trace.samplers.Sampler sampler) {
|
||||
String applicationName = environment.getProperty("spring.application.name", DEFAULT_APPLICATION_NAME);
|
||||
String applicationName = moduleModel.getApplicationModel().getApplicationConfigManager().getApplication()
|
||||
.map(ApplicationConfig::getName)
|
||||
.orElse(DEFAULT_APPLICATION_NAME);
|
||||
io.opentelemetry.sdk.trace.SdkTracerProviderBuilder builder = io.opentelemetry.sdk.trace.SdkTracerProvider.builder().setSampler(sampler)
|
||||
.setResource(io.opentelemetry.sdk.resources.Resource.create(io.opentelemetry.api.common.Attributes.of(io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME, applicationName)));
|
||||
.setResource(io.opentelemetry.sdk.resources.Resource.create(io.opentelemetry.api.common.Attributes.of(io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME, applicationName)));
|
||||
spanProcessors.orderedStream().forEach(builder::addSpanProcessor);
|
||||
return builder.build();
|
||||
}
|
||||
|
|
@ -93,11 +99,11 @@ public class OpenTelemetryAutoConfiguration {
|
|||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
io.opentelemetry.sdk.trace.SpanProcessor otelSpanProcessor(ObjectProvider<io.opentelemetry.sdk.trace.export.SpanExporter> spanExporters,
|
||||
ObjectProvider<io.micrometer.tracing.exporter.SpanExportingPredicate> spanExportingPredicates, ObjectProvider<io.micrometer.tracing.exporter.SpanReporter> spanReporters,
|
||||
ObjectProvider<io.micrometer.tracing.exporter.SpanFilter> spanFilters) {
|
||||
ObjectProvider<io.micrometer.tracing.exporter.SpanExportingPredicate> spanExportingPredicates, ObjectProvider<io.micrometer.tracing.exporter.SpanReporter> spanReporters,
|
||||
ObjectProvider<io.micrometer.tracing.exporter.SpanFilter> spanFilters) {
|
||||
return io.opentelemetry.sdk.trace.export.BatchSpanProcessor.builder(new io.micrometer.tracing.otel.bridge.CompositeSpanExporter(spanExporters.orderedStream().collect(Collectors.toList()),
|
||||
spanExportingPredicates.orderedStream().collect(Collectors.toList()), spanReporters.orderedStream().collect(Collectors.toList()),
|
||||
spanFilters.orderedStream().collect(Collectors.toList()))).build();
|
||||
spanExportingPredicates.orderedStream().collect(Collectors.toList()), spanReporters.orderedStream().collect(Collectors.toList()),
|
||||
spanFilters.orderedStream().collect(Collectors.toList()))).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
@ -163,7 +169,7 @@ public class OpenTelemetryAutoConfiguration {
|
|||
io.opentelemetry.context.propagation.TextMapPropagator w3cTextMapPropagatorWithBaggage(io.micrometer.tracing.otel.bridge.OtelCurrentTraceContext otelCurrentTraceContext) {
|
||||
List<String> remoteFields = this.dubboConfigProperties.getTracing().getBaggage().getRemoteFields();
|
||||
return io.opentelemetry.context.propagation.TextMapPropagator.composite(io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator.getInstance(),
|
||||
io.opentelemetry.api.baggage.propagation.W3CBaggagePropagator.getInstance(), new io.micrometer.tracing.otel.propagation.BaggageTextMapPropagator(remoteFields,
|
||||
io.opentelemetry.api.baggage.propagation.W3CBaggagePropagator.getInstance(), new io.micrometer.tracing.otel.propagation.BaggageTextMapPropagator(remoteFields,
|
||||
new io.micrometer.tracing.otel.bridge.OtelBaggageManager(otelCurrentTraceContext, remoteFields, Collections.emptyList())));
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>dubbo-spring-boot-observability-starters</artifactId>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>dubbo-spring-boot-observability-starter</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<description>Apache Dubbo Spring Boot Observability Starter</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-spring-boot-observability-autoconfigure</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>dubbo-spring-boot-observability-starter</artifactId>
|
||||
<artifactId>dubbo-spring-boot-observability-starters</artifactId>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>dubbo-spring-boot-observability-starter</artifactId>
|
||||
<artifactId>dubbo-spring-boot-observability-starters</artifactId>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
|
|
@ -27,12 +27,13 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<artifactId>dubbo-spring-boot-observability-starter</artifactId>
|
||||
<artifactId>dubbo-spring-boot-observability-starters</artifactId>
|
||||
|
||||
<modules>
|
||||
<module>dubbo-spring-boot-observability-autoconfigure</module>
|
||||
<module>dubbo-spring-boot-tracing-otel-zipkin-starter</module>
|
||||
<module>dubbo-spring-boot-tracing-brave-zipkin-starter</module>
|
||||
<module>dubbo-spring-boot-observability-starter</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
<module>dubbo-spring-boot-autoconfigure</module>
|
||||
<module>dubbo-spring-boot-compatible</module>
|
||||
<module>dubbo-spring-boot-starter</module>
|
||||
<module>dubbo-spring-boot-observability-starter</module>
|
||||
<module>dubbo-spring-boot-observability-starters</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
|
|
|||
|
|
@ -343,6 +343,10 @@
|
|||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-spring-boot-tracing-brave-zipkin-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-spring-boot-observability-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- test -->
|
||||
<dependency>
|
||||
|
|
|
|||
Loading…
Reference in New Issue