Merge branch 'apache-3.2' into 3.2.0-beta.5-release
This commit is contained in:
commit
e83fea7e69
|
|
@ -18,11 +18,6 @@
|
|||
package org.apache.dubbo.springboot.demo.consumer;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import io.micrometer.core.instrument.observation.DefaultMeterObservationHandler;
|
||||
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
|
||||
|
|
@ -34,6 +29,7 @@ import io.micrometer.tracing.handler.PropagatingReceiverTracingObservationHandle
|
|||
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;
|
||||
|
|
@ -42,6 +38,7 @@ 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;
|
||||
|
|
@ -54,26 +51,28 @@ 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";
|
||||
|
||||
@Bean
|
||||
ApplicationModel applicationModel() {
|
||||
ApplicationModel applicationModel = ApplicationModel.defaultModel();
|
||||
applicationModel.getBeanFactory().registerBean(observationRegistry());
|
||||
return applicationModel;
|
||||
}
|
||||
@javax.annotation.Resource
|
||||
private ApplicationModel applicationModel;
|
||||
|
||||
@Bean
|
||||
ObservationRegistry observationRegistry() {
|
||||
return ObservationRegistry.create();
|
||||
ObservationRegistry observationRegistry = ObservationRegistry.create();
|
||||
applicationModel.getBeanFactory().registerBean(observationRegistry);
|
||||
return observationRegistry;
|
||||
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
@ -129,10 +128,12 @@ public class ObservationConfiguration {
|
|||
OtelTracer tracer(io.opentelemetry.api.trace.Tracer otelTracer, OtelCurrentTraceContext otelCurrentTraceContext) {
|
||||
Slf4JEventListener slf4JEventListener = slf4JEventListener();
|
||||
Slf4JBaggageEventListener slf4JBaggageEventListener = slf4JBaggageEventListener();
|
||||
return new OtelTracer(otelTracer, otelCurrentTraceContext, event -> {
|
||||
OtelTracer.EventPublisher eventPublisher = event -> {
|
||||
slf4JEventListener.onEvent(event);
|
||||
slf4JBaggageEventListener.onEvent(event);
|
||||
}, new OtelBaggageManager(otelCurrentTraceContext, Collections.emptyList(), Collections.emptyList()));
|
||||
};
|
||||
ContextStorage.addWrapper(new EventPublishingContextWrapper(eventPublisher));
|
||||
return new OtelTracer(otelTracer, otelCurrentTraceContext, eventPublisher, new OtelBaggageManager(otelCurrentTraceContext, Collections.emptyList(), Collections.emptyList()));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
|||
|
|
@ -14,9 +14,13 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
dubbo:
|
||||
spring:
|
||||
application:
|
||||
name: dubbo-springboot-demo-consumer
|
||||
|
||||
dubbo:
|
||||
application:
|
||||
name: ${spring.application.name}
|
||||
protocol:
|
||||
name: dubbo
|
||||
port: -1
|
||||
|
|
@ -27,3 +31,8 @@ dubbo:
|
|||
address: zookeeper://127.0.0.1:2181
|
||||
metadata-report:
|
||||
address: zookeeper://127.0.0.1:2181
|
||||
|
||||
logging:
|
||||
pattern:
|
||||
level: '%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]'
|
||||
|
||||
|
|
|
|||
|
|
@ -20,14 +20,18 @@ package org.apache.dubbo.springboot.demo.provider;
|
|||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.apache.dubbo.rpc.RpcContext;
|
||||
import org.apache.dubbo.springboot.demo.DemoService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@DubboService
|
||||
public class DemoServiceImpl implements DemoService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DemoServiceImpl.class);
|
||||
@Override
|
||||
public String sayHello(String name) {
|
||||
System.out.println("Hello " + name + ", request from consumer: " + RpcContext.getContext().getRemoteAddress());
|
||||
logger.info("Hello " + name + ", request from consumer: " + RpcContext.getContext().getRemoteAddress());
|
||||
return "Hello " + name;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -18,11 +18,6 @@
|
|||
package org.apache.dubbo.springboot.demo.provider;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import io.micrometer.core.instrument.observation.DefaultMeterObservationHandler;
|
||||
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
|
||||
|
|
@ -34,6 +29,7 @@ import io.micrometer.tracing.handler.PropagatingReceiverTracingObservationHandle
|
|||
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;
|
||||
|
|
@ -42,6 +38,7 @@ 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;
|
||||
|
|
@ -50,11 +47,14 @@ 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
|
||||
|
|
@ -64,17 +64,14 @@ public class ObservationConfiguration {
|
|||
* Default value for application name if {@code spring.application.name} is not set.
|
||||
*/
|
||||
private static final String DEFAULT_APPLICATION_NAME = "application";
|
||||
|
||||
@Bean
|
||||
ApplicationModel applicationModel() {
|
||||
ApplicationModel applicationModel = ApplicationModel.defaultModel();
|
||||
applicationModel.getBeanFactory().registerBean(observationRegistry());
|
||||
return applicationModel;
|
||||
}
|
||||
@javax.annotation.Resource
|
||||
private ApplicationModel applicationModel;
|
||||
|
||||
@Bean
|
||||
ObservationRegistry observationRegistry() {
|
||||
return ObservationRegistry.create();
|
||||
ObservationRegistry observationRegistry = ObservationRegistry.create();
|
||||
applicationModel.getBeanFactory().registerBean(observationRegistry);
|
||||
return observationRegistry;
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
@ -130,10 +127,12 @@ public class ObservationConfiguration {
|
|||
OtelTracer tracer(io.opentelemetry.api.trace.Tracer otelTracer, OtelCurrentTraceContext otelCurrentTraceContext) {
|
||||
Slf4JEventListener slf4JEventListener = slf4JEventListener();
|
||||
Slf4JBaggageEventListener slf4JBaggageEventListener = slf4JBaggageEventListener();
|
||||
return new OtelTracer(otelTracer, otelCurrentTraceContext, event -> {
|
||||
OtelTracer.EventPublisher eventPublisher = event -> {
|
||||
slf4JEventListener.onEvent(event);
|
||||
slf4JBaggageEventListener.onEvent(event);
|
||||
}, new OtelBaggageManager(otelCurrentTraceContext, Collections.emptyList(), Collections.emptyList()));
|
||||
};
|
||||
ContextStorage.addWrapper(new EventPublishingContextWrapper(eventPublisher));
|
||||
return new OtelTracer(otelTracer, otelCurrentTraceContext, eventPublisher, new OtelBaggageManager(otelCurrentTraceContext, Collections.emptyList(), Collections.emptyList()));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
|||
|
|
@ -14,9 +14,13 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
dubbo:
|
||||
spring:
|
||||
application:
|
||||
name: dubbo-springboot-demo-provider
|
||||
|
||||
dubbo:
|
||||
application:
|
||||
name: ${spring.application.name}
|
||||
protocol:
|
||||
name: dubbo
|
||||
port: -1
|
||||
|
|
@ -27,3 +31,8 @@ dubbo:
|
|||
address: zookeeper://127.0.0.1:2181
|
||||
metadata-report:
|
||||
address: zookeeper://127.0.0.1:2181
|
||||
|
||||
logging:
|
||||
pattern:
|
||||
level: '%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]'
|
||||
|
||||
|
|
|
|||
|
|
@ -149,10 +149,10 @@
|
|||
<grpc_contrib_verdion>0.8.1</grpc_contrib_verdion>
|
||||
<jprotoc_version>1.2.1</jprotoc_version>
|
||||
<!-- Log libs -->
|
||||
<slf4j_version>2.0.6</slf4j_version>
|
||||
<slf4j_version>1.7.36</slf4j_version>
|
||||
<jcl_version>1.2</jcl_version>
|
||||
<log4j_version>1.2.17</log4j_version>
|
||||
<logback_version>1.4.5</logback_version>
|
||||
<logback_version>1.2.11</logback_version>
|
||||
<!-- Fix the bug of log4j refer:https://github.com/apache/logging-log4j2/pull/608 -->
|
||||
<log4j2_version>2.19.0</log4j2_version>
|
||||
<commons_io_version>2.11.0</commons_io_version>
|
||||
|
|
|
|||
Loading…
Reference in New Issue