diff --git a/dubbo-demo/dubbo-demo-spring-boot/dubbo-demo-spring-boot-consumer/pom.xml b/dubbo-demo/dubbo-demo-spring-boot/dubbo-demo-spring-boot-consumer/pom.xml
index 6eec35ee18e6..626b9d98256a 100644
--- a/dubbo-demo/dubbo-demo-spring-boot/dubbo-demo-spring-boot-consumer/pom.xml
+++ b/dubbo-demo/dubbo-demo-spring-boot/dubbo-demo-spring-boot-consumer/pom.xml
@@ -134,15 +134,16 @@
-
- org.apache.dubbo
- dubbo-metrics-default
-
io.micrometer
micrometer-tracing-bridge-otel
+
+ org.apache.dubbo
+ dubbo-spring-boot-observability-starter
+
+
diff --git a/dubbo-demo/dubbo-demo-spring-boot/dubbo-demo-spring-boot-consumer/src/main/java/org/apache/dubbo/springboot/demo/consumer/ObservationConfiguration.java b/dubbo-demo/dubbo-demo-spring-boot/dubbo-demo-spring-boot-consumer/src/main/java/org/apache/dubbo/springboot/demo/consumer/ObservationConfiguration.java
deleted file mode 100644
index 717e36a8f95b..000000000000
--- a/dubbo-demo/dubbo-demo-spring-boot/dubbo-demo-spring-boot-consumer/src/main/java/org/apache/dubbo/springboot/demo/consumer/ObservationConfiguration.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * 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.springboot.demo.consumer;
-
-
-import io.micrometer.core.instrument.MeterRegistry;
-import io.micrometer.core.instrument.observation.DefaultMeterObservationHandler;
-import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
-import io.micrometer.observation.ObservationHandler;
-import io.micrometer.observation.ObservationRegistry;
-import io.micrometer.tracing.Tracer;
-import io.micrometer.tracing.handler.DefaultTracingObservationHandler;
-import io.micrometer.tracing.handler.PropagatingReceiverTracingObservationHandler;
-import io.micrometer.tracing.handler.PropagatingSenderTracingObservationHandler;
-import io.micrometer.tracing.handler.TracingAwareMeterObservationHandler;
-import io.micrometer.tracing.otel.bridge.ArrayListSpanProcessor;
-import io.micrometer.tracing.otel.bridge.EventPublishingContextWrapper;
-import io.micrometer.tracing.otel.bridge.OtelBaggageManager;
-import io.micrometer.tracing.otel.bridge.OtelCurrentTraceContext;
-import io.micrometer.tracing.otel.bridge.OtelPropagator;
-import io.micrometer.tracing.otel.bridge.OtelTracer;
-import io.micrometer.tracing.otel.bridge.Slf4JBaggageEventListener;
-import io.micrometer.tracing.otel.bridge.Slf4JEventListener;
-import io.micrometer.tracing.propagation.Propagator;
-import io.opentelemetry.api.common.Attributes;
-import io.opentelemetry.context.ContextStorage;
-import io.opentelemetry.context.propagation.ContextPropagators;
-import io.opentelemetry.extension.trace.propagation.B3Propagator;
-import io.opentelemetry.sdk.OpenTelemetrySdk;
-import io.opentelemetry.sdk.resources.Resource;
-import io.opentelemetry.sdk.trace.SdkTracerProvider;
-import io.opentelemetry.sdk.trace.export.BatchSpanProcessor;
-import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
-import org.apache.dubbo.rpc.model.ApplicationModel;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.env.Environment;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import java.util.Collections;
-
-import static io.opentelemetry.sdk.trace.samplers.Sampler.alwaysOn;
-
-@Configuration
-public class ObservationConfiguration {
- /**
- * Default value for application name if {@code spring.application.name} is not set.
- */
- private static final String DEFAULT_APPLICATION_NAME = "application";
-
- @javax.annotation.Resource
- private ApplicationModel applicationModel;
-
- @Bean
- ObservationRegistry observationRegistry() {
- ObservationRegistry observationRegistry = ObservationRegistry.create();
- applicationModel.getBeanFactory().registerBean(observationRegistry);
- return observationRegistry;
-
- }
-
- @Bean
- MeterRegistry meterRegistry() {
- return new SimpleMeterRegistry();
- }
-
- @Bean
- ArrayListSpanProcessor spanExporter() {
- return new ArrayListSpanProcessor();
- }
-
- @Bean
- SdkTracerProvider sdkTracerProvider(Environment environment) {
- String applicationName = environment.getProperty("dubbo.application.name", DEFAULT_APPLICATION_NAME);
- return SdkTracerProvider.builder().setSampler(alwaysOn())
- .addSpanProcessor(BatchSpanProcessor.builder(spanExporter()).build())
- .setResource(Resource.create(Attributes.of(ResourceAttributes.SERVICE_NAME, applicationName)))
- .build();
- }
-
- @Bean
- ContextPropagators contextPropagators() {
- return ContextPropagators.create(B3Propagator.injectingSingleHeader());
- }
-
- @Bean
- OpenTelemetrySdk openTelemetrySdk(SdkTracerProvider sdkTracerProvider) {
- return OpenTelemetrySdk.builder().setTracerProvider(sdkTracerProvider)
- .setPropagators(contextPropagators()).build();
- }
-
- @Bean
- io.opentelemetry.api.trace.Tracer otelTracer(OpenTelemetrySdk openTelemetrySdk) {
- return openTelemetrySdk.getTracerProvider()
- .get("io.micrometer.micrometer-tracing");
- }
-
- @Bean
- OtelCurrentTraceContext otelCurrentTraceContext() {
- return new OtelCurrentTraceContext();
- }
-
- Slf4JEventListener slf4JEventListener() {
- return new Slf4JEventListener();
- }
-
- Slf4JBaggageEventListener slf4JBaggageEventListener() {
- return new Slf4JBaggageEventListener(Collections.emptyList());
- }
-
- @Bean
- OtelTracer tracer(io.opentelemetry.api.trace.Tracer otelTracer, OtelCurrentTraceContext otelCurrentTraceContext) {
- Slf4JEventListener slf4JEventListener = slf4JEventListener();
- Slf4JBaggageEventListener slf4JBaggageEventListener = slf4JBaggageEventListener();
- OtelTracer.EventPublisher eventPublisher = event -> {
- slf4JEventListener.onEvent(event);
- slf4JBaggageEventListener.onEvent(event);
- };
- ContextStorage.addWrapper(new EventPublishingContextWrapper(eventPublisher));
- return new OtelTracer(otelTracer, otelCurrentTraceContext, eventPublisher, new OtelBaggageManager(otelCurrentTraceContext, Collections.emptyList(), Collections.emptyList()));
- }
-
- @Bean
- Propagator propagator(io.opentelemetry.api.trace.Tracer otelTracer) {
- return new OtelPropagator(contextPropagators(), otelTracer);
- }
-
- @Bean
- ObservationHandlerRegistrar observationHandlerRegistrar(ObservationRegistry observationRegistry, OtelTracer tracer, Propagator propagator, MeterRegistry meterRegistry) {
- return new ObservationHandlerRegistrar(observationRegistry, tracer, propagator, meterRegistry);
- }
-
- @Bean
- MetricsDumper metricsDumper(MeterRegistry meterRegistry) {
- return new MetricsDumper(meterRegistry);
- }
-
- @Bean
- TracesDumper tracesDumper(ArrayListSpanProcessor arrayListSpanProcessor) {
- return new TracesDumper(arrayListSpanProcessor);
- }
-
- static class ObservationHandlerRegistrar {
-
- private final ObservationRegistry observationRegistry;
-
- private final Tracer tracer;
-
- private final Propagator propagator;
-
- private final MeterRegistry meterRegistry;
-
- ObservationHandlerRegistrar(ObservationRegistry observationRegistry, Tracer tracer, Propagator propagator, MeterRegistry meterRegistry) {
- this.observationRegistry = observationRegistry;
- this.tracer = tracer;
- this.propagator = propagator;
- this.meterRegistry = meterRegistry;
- }
-
- @PostConstruct
- void setup() {
- observationRegistry.observationConfig().observationHandler(new TracingAwareMeterObservationHandler<>(new DefaultMeterObservationHandler(meterRegistry), tracer));
- observationRegistry.observationConfig()
- .observationHandler(new ObservationHandler.FirstMatchingCompositeObservationHandler(new PropagatingReceiverTracingObservationHandler<>(tracer, propagator), new PropagatingSenderTracingObservationHandler<>(tracer, propagator), new DefaultTracingObservationHandler(tracer)));
- }
- }
-
-
- static class MetricsDumper {
- private final MeterRegistry meterRegistry;
-
- MetricsDumper(MeterRegistry meterRegistry) {
- this.meterRegistry = meterRegistry;
- }
-
- @PreDestroy
- void dumpMetrics() {
- System.out.println("==== METRICS ====");
- this.meterRegistry.getMeters().forEach(meter -> System.out.println(" - Metric type \t[" + meter.getId().getType() + "],\tname [" + meter.getId().getName() + "],\ttags " + meter.getId().getTags() + ",\tmeasurements " + meter.measure()));
- System.out.println("=================");
- }
- }
-
-
- static class TracesDumper {
- private final ArrayListSpanProcessor arrayListSpanProcessor;
-
- TracesDumper(ArrayListSpanProcessor arrayListSpanProcessor) {
- this.arrayListSpanProcessor = arrayListSpanProcessor;
- }
-
- @PreDestroy
- void dumpTraces() {
- System.out.println("==== TRACES ====");
- this.arrayListSpanProcessor.spans().forEach(System.out::println);
- System.out.println("=================");
- }
- }
-}
diff --git a/dubbo-demo/dubbo-demo-spring-boot/dubbo-demo-spring-boot-provider/pom.xml b/dubbo-demo/dubbo-demo-spring-boot/dubbo-demo-spring-boot-provider/pom.xml
index fcb8ec1b111e..ba32f8c70ec7 100644
--- a/dubbo-demo/dubbo-demo-spring-boot/dubbo-demo-spring-boot-provider/pom.xml
+++ b/dubbo-demo/dubbo-demo-spring-boot/dubbo-demo-spring-boot-provider/pom.xml
@@ -133,14 +133,14 @@
-
- org.apache.dubbo
- dubbo-metrics-default
-
io.micrometer
micrometer-tracing-bridge-otel
+
+ org.apache.dubbo
+ dubbo-spring-boot-observability-starter
+
diff --git a/dubbo-demo/dubbo-demo-spring-boot/dubbo-demo-spring-boot-provider/src/main/java/org/apache/dubbo/springboot/demo/provider/ObservationConfiguration.java b/dubbo-demo/dubbo-demo-spring-boot/dubbo-demo-spring-boot-provider/src/main/java/org/apache/dubbo/springboot/demo/provider/ObservationConfiguration.java
deleted file mode 100644
index 722427fcc5fb..000000000000
--- a/dubbo-demo/dubbo-demo-spring-boot/dubbo-demo-spring-boot-provider/src/main/java/org/apache/dubbo/springboot/demo/provider/ObservationConfiguration.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * 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.springboot.demo.provider;
-
-
-import io.micrometer.core.instrument.MeterRegistry;
-import io.micrometer.core.instrument.observation.DefaultMeterObservationHandler;
-import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
-import io.micrometer.observation.ObservationHandler;
-import io.micrometer.observation.ObservationRegistry;
-import io.micrometer.tracing.Tracer;
-import io.micrometer.tracing.handler.DefaultTracingObservationHandler;
-import io.micrometer.tracing.handler.PropagatingReceiverTracingObservationHandler;
-import io.micrometer.tracing.handler.PropagatingSenderTracingObservationHandler;
-import io.micrometer.tracing.handler.TracingAwareMeterObservationHandler;
-import io.micrometer.tracing.otel.bridge.ArrayListSpanProcessor;
-import io.micrometer.tracing.otel.bridge.EventPublishingContextWrapper;
-import io.micrometer.tracing.otel.bridge.OtelBaggageManager;
-import io.micrometer.tracing.otel.bridge.OtelCurrentTraceContext;
-import io.micrometer.tracing.otel.bridge.OtelPropagator;
-import io.micrometer.tracing.otel.bridge.OtelTracer;
-import io.micrometer.tracing.otel.bridge.Slf4JBaggageEventListener;
-import io.micrometer.tracing.otel.bridge.Slf4JEventListener;
-import io.micrometer.tracing.propagation.Propagator;
-import io.opentelemetry.api.common.Attributes;
-import io.opentelemetry.context.ContextStorage;
-import io.opentelemetry.context.propagation.ContextPropagators;
-import io.opentelemetry.extension.trace.propagation.B3Propagator;
-import io.opentelemetry.sdk.OpenTelemetrySdk;
-import io.opentelemetry.sdk.resources.Resource;
-import io.opentelemetry.sdk.trace.SdkTracerProvider;
-import io.opentelemetry.sdk.trace.export.BatchSpanProcessor;
-import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
-import org.apache.dubbo.rpc.model.ApplicationModel;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.env.Environment;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import java.util.Collections;
-
-import static io.opentelemetry.sdk.trace.samplers.Sampler.alwaysOn;
-
-@Configuration
-public class ObservationConfiguration {
-
- /**
- * Default value for application name if {@code spring.application.name} is not set.
- */
- private static final String DEFAULT_APPLICATION_NAME = "application";
- @javax.annotation.Resource
- private ApplicationModel applicationModel;
-
- @Bean
- ObservationRegistry observationRegistry() {
- ObservationRegistry observationRegistry = ObservationRegistry.create();
- applicationModel.getBeanFactory().registerBean(observationRegistry);
- return observationRegistry;
- }
-
- @Bean
- MeterRegistry meterRegistry() {
- return new SimpleMeterRegistry();
- }
-
- @Bean
- ArrayListSpanProcessor spanExporter() {
- return new ArrayListSpanProcessor();
- }
-
- @Bean
- SdkTracerProvider sdkTracerProvider(Environment environment) {
- String applicationName = environment.getProperty("dubbo.application.name", DEFAULT_APPLICATION_NAME);
- return SdkTracerProvider.builder().setSampler(alwaysOn())
- .addSpanProcessor(BatchSpanProcessor.builder(spanExporter()).build())
- .setResource(Resource.create(Attributes.of(ResourceAttributes.SERVICE_NAME, applicationName)))
- .build();
- }
-
- @Bean
- ContextPropagators contextPropagators() {
- return ContextPropagators.create(B3Propagator.injectingSingleHeader());
- }
-
- @Bean
- OpenTelemetrySdk openTelemetrySdk(SdkTracerProvider sdkTracerProvider) {
- return OpenTelemetrySdk.builder().setTracerProvider(sdkTracerProvider)
- .setPropagators(contextPropagators()).build();
- }
-
- @Bean
- io.opentelemetry.api.trace.Tracer otelTracer(OpenTelemetrySdk openTelemetrySdk) {
- return openTelemetrySdk.getTracerProvider()
- .get("io.micrometer.micrometer-tracing");
- }
-
- @Bean
- OtelCurrentTraceContext otelCurrentTraceContext() {
- return new OtelCurrentTraceContext();
- }
-
- Slf4JEventListener slf4JEventListener() {
- return new Slf4JEventListener();
- }
-
- Slf4JBaggageEventListener slf4JBaggageEventListener() {
- return new Slf4JBaggageEventListener(Collections.emptyList());
- }
-
- @Bean
- OtelTracer tracer(io.opentelemetry.api.trace.Tracer otelTracer, OtelCurrentTraceContext otelCurrentTraceContext) {
- Slf4JEventListener slf4JEventListener = slf4JEventListener();
- Slf4JBaggageEventListener slf4JBaggageEventListener = slf4JBaggageEventListener();
- OtelTracer.EventPublisher eventPublisher = event -> {
- slf4JEventListener.onEvent(event);
- slf4JBaggageEventListener.onEvent(event);
- };
- ContextStorage.addWrapper(new EventPublishingContextWrapper(eventPublisher));
- return new OtelTracer(otelTracer, otelCurrentTraceContext, eventPublisher, new OtelBaggageManager(otelCurrentTraceContext, Collections.emptyList(), Collections.emptyList()));
- }
-
- @Bean
- Propagator propagator(io.opentelemetry.api.trace.Tracer otelTracer) {
- return new OtelPropagator(contextPropagators(), otelTracer);
- }
-
- @Bean
- ObservationHandlerRegistrar observationHandlerRegistrar(ObservationRegistry observationRegistry, OtelTracer tracer, Propagator propagator, MeterRegistry meterRegistry) {
- return new ObservationHandlerRegistrar(observationRegistry, tracer, propagator, meterRegistry);
- }
-
- @Bean
- MetricsDumper metricsDumper(MeterRegistry meterRegistry) {
- return new MetricsDumper(meterRegistry);
- }
-
- @Bean
- TracesDumper tracesDumper(ArrayListSpanProcessor arrayListSpanProcessor) {
- return new TracesDumper(arrayListSpanProcessor);
- }
-
- static class ObservationHandlerRegistrar {
-
- private final ObservationRegistry observationRegistry;
-
- private final Tracer tracer;
-
- private final Propagator propagator;
-
- private final MeterRegistry meterRegistry;
-
- ObservationHandlerRegistrar(ObservationRegistry observationRegistry, Tracer tracer, Propagator propagator, MeterRegistry meterRegistry) {
- this.observationRegistry = observationRegistry;
- this.tracer = tracer;
- this.propagator = propagator;
- this.meterRegistry = meterRegistry;
- }
-
- @PostConstruct
- void setup() {
- observationRegistry.observationConfig().observationHandler(new TracingAwareMeterObservationHandler<>(new DefaultMeterObservationHandler(meterRegistry), tracer));
- observationRegistry.observationConfig()
- .observationHandler(new ObservationHandler.FirstMatchingCompositeObservationHandler(new PropagatingReceiverTracingObservationHandler<>(tracer, propagator), new PropagatingSenderTracingObservationHandler<>(tracer, propagator), new DefaultTracingObservationHandler(tracer)));
- }
- }
-
-
- static class MetricsDumper {
- private final MeterRegistry meterRegistry;
-
- MetricsDumper(MeterRegistry meterRegistry) {
- this.meterRegistry = meterRegistry;
- }
-
- @PreDestroy
- void dumpMetrics() {
- System.out.println("==== METRICS ====");
- this.meterRegistry.getMeters().forEach(meter -> System.out.println(" - Metric type \t[" + meter.getId().getType() + "],\tname [" + meter.getId().getName() + "],\ttags " + meter.getId().getTags() + ",\tmeasurements " + meter.measure()));
- System.out.println("=================");
- }
- }
-
-
- static class TracesDumper {
- private final ArrayListSpanProcessor arrayListSpanProcessor;
-
- TracesDumper(ArrayListSpanProcessor arrayListSpanProcessor) {
- this.arrayListSpanProcessor = arrayListSpanProcessor;
- }
-
- @PreDestroy
- void dumpTraces() {
- System.out.println("==== TRACES ====");
- this.arrayListSpanProcessor.spans().forEach(System.out::println);
- System.out.println("=================");
- }
- }
-}
diff --git a/dubbo-demo/dubbo-demo-spring-boot/pom.xml b/dubbo-demo/dubbo-demo-spring-boot/pom.xml
index 4cd2703b11e6..18546bdbec79 100644
--- a/dubbo-demo/dubbo-demo-spring-boot/pom.xml
+++ b/dubbo-demo/dubbo-demo-spring-boot/pom.xml
@@ -36,7 +36,27 @@
8
8
true
+ 2.7.8
2.7.8
+ 1.10.4
+
+
+
+ org.springframework.boot
+ spring-boot-dependencies
+ ${spring-boot.version}
+ pom
+ import
+
+
+ io.micrometer
+ micrometer-core
+ ${micrometer-core.version}
+
+
+
+
+
diff --git a/dubbo-dependencies-bom/pom.xml b/dubbo-dependencies-bom/pom.xml
index 7208334a6e67..e5d57f390718 100644
--- a/dubbo-dependencies-bom/pom.xml
+++ b/dubbo-dependencies-bom/pom.xml
@@ -135,6 +135,7 @@
1.8.0
0.1.35
1.10.4
+
1.0.2
3.3
0.16.0
diff --git a/dubbo-distribution/dubbo-bom/pom.xml b/dubbo-distribution/dubbo-bom/pom.xml
index 988e6cc41186..9e04c6874773 100644
--- a/dubbo-distribution/dubbo-bom/pom.xml
+++ b/dubbo-distribution/dubbo-bom/pom.xml
@@ -487,6 +487,11 @@
pom
${project.version}
+
+ org.apache.dubbo
+ dubbo-spring-boot-observability-starter
+ ${project.version}
+
diff --git a/dubbo-spring-boot/pom.xml b/dubbo-spring-boot/pom.xml
index 4c43c0795513..2d6991aac42b 100644
--- a/dubbo-spring-boot/pom.xml
+++ b/dubbo-spring-boot/pom.xml
@@ -36,6 +36,7 @@
dubbo-spring-boot-autoconfigure
dubbo-spring-boot-compatible
dubbo-spring-boot-starter
+ dubbo-spring-boot-observability-starter
@@ -45,6 +46,7 @@
2.19.0
1.13.0
+ 1.10.4
@@ -57,6 +59,11 @@
pom
import
+
+ io.micrometer
+ micrometer-core
+ ${micrometer-core.version}
+
diff --git a/dubbo-test/dubbo-dependencies-all/pom.xml b/dubbo-test/dubbo-dependencies-all/pom.xml
index 5e9a515d5ab4..90e91d7e4d7b 100644
--- a/dubbo-test/dubbo-dependencies-all/pom.xml
+++ b/dubbo-test/dubbo-dependencies-all/pom.xml
@@ -318,6 +318,11 @@
dubbo-spring-boot-starter
+
+ org.apache.dubbo
+ dubbo-spring-boot-observability-starter
+
+
org.apache.dubbo