feat: add dubbo-spring-boot-tracing-otel-otlp-starter (#12299)
* feat: dubbo-spring-boot-tracing-otel-otlp-starter * style * chore: add otel-otlp-exporter to pom * feat: add headers cfg in otlp * fix: add license --------- Co-authored-by: Albumen Kevin <jhq0812@gmail.com> Co-authored-by: songxiaosheng <songxiaosheng@elastic.link>
This commit is contained in:
parent
906517149b
commit
76d4982e1e
|
|
@ -106,6 +106,7 @@ 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-tracing-otel-otlp-starter
|
||||
dubbo-spring-boot-observability-starter
|
||||
dubbo-spring-boot-starter
|
||||
dubbo-spring-security
|
||||
|
|
|
|||
|
|
@ -17,16 +17,21 @@
|
|||
|
||||
package org.apache.dubbo.config.nested;
|
||||
|
||||
import org.apache.dubbo.config.support.Nested;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.dubbo.config.support.Nested;
|
||||
|
||||
public class ExporterConfig implements Serializable {
|
||||
|
||||
@Nested
|
||||
private ZipkinConfig zipkinConfig;
|
||||
|
||||
@Nested
|
||||
private OtlpConfig otlpConfig;
|
||||
|
||||
public ZipkinConfig getZipkinConfig() {
|
||||
return zipkinConfig;
|
||||
}
|
||||
|
|
@ -35,6 +40,14 @@ public class ExporterConfig implements Serializable {
|
|||
this.zipkinConfig = zipkinConfig;
|
||||
}
|
||||
|
||||
public OtlpConfig getOtlpConfig() {
|
||||
return otlpConfig;
|
||||
}
|
||||
|
||||
public void setOtlpConfig(OtlpConfig otlpConfig) {
|
||||
this.otlpConfig = otlpConfig;
|
||||
}
|
||||
|
||||
public static class ZipkinConfig implements Serializable {
|
||||
|
||||
/**
|
||||
|
|
@ -76,4 +89,57 @@ public class ExporterConfig implements Serializable {
|
|||
this.readTimeout = readTimeout;
|
||||
}
|
||||
}
|
||||
|
||||
public static class OtlpConfig implements Serializable {
|
||||
|
||||
/**
|
||||
* URL to the Otlp API.
|
||||
*/
|
||||
private String endpoint;
|
||||
|
||||
/**
|
||||
* The maximum time to wait for the collector to process an exported batch of spans.
|
||||
*/
|
||||
private Duration timeout = Duration.ofSeconds(10);
|
||||
|
||||
/**
|
||||
* The method used to compress payloads. If unset, compression is disabled. Currently
|
||||
* supported compression methods include "gzip" and "none".
|
||||
*/
|
||||
private String compressionMethod = "none";
|
||||
|
||||
private Map<String, String> headers = new HashMap<>();
|
||||
|
||||
public String getEndpoint() {
|
||||
return endpoint;
|
||||
}
|
||||
|
||||
public void setEndpoint(String endpoint) {
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
|
||||
public Duration getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public void setTimeout(Duration timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public String getCompressionMethod() {
|
||||
return compressionMethod;
|
||||
}
|
||||
|
||||
public void setCompressionMethod(String compressionMethod) {
|
||||
this.compressionMethod = compressionMethod;
|
||||
}
|
||||
|
||||
public Map<String, String> getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
|
||||
public void setHeaders(Map<String, String> headers) {
|
||||
this.headers = headers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -517,6 +517,11 @@
|
|||
<artifactId>dubbo-spring-boot-tracing-otel-zipkin-starter</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-spring-boot-tracing-otel-otlp-starter</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-spring-boot-tracing-brave-zipkin-starter</artifactId>
|
||||
|
|
|
|||
|
|
@ -101,6 +101,11 @@
|
|||
<artifactId>opentelemetry-exporter-zipkin</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.opentelemetry</groupId>
|
||||
<artifactId>opentelemetry-exporter-otlp</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.zipkin.reporter2</groupId>
|
||||
<artifactId>zipkin-reporter-brave</artifactId>
|
||||
|
|
@ -115,17 +120,17 @@
|
|||
</dependency>
|
||||
|
||||
<!-- dubbo -->
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-spring-boot-starter</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-spring-boot-starter</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-qos</artifactId>
|
||||
|
|
|
|||
|
|
@ -38,4 +38,5 @@ public class ObservabilityUtils {
|
|||
|
||||
public static final String DUBBO_TRACING_ZIPKIN_CONFIG_PREFIX = DUBBO_TRACING_PREFIX + PROPERTY_NAME_SEPARATOR + "tracing-exporter.zipkin-config";
|
||||
|
||||
public static final String DUBBO_TRACING_OTLP_CONFIG_PREFIX = DUBBO_TRACING_PREFIX + PROPERTY_NAME_SEPARATOR + "tracing-exporter.otlp-config";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* 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.spring.boot.observability.autoconfigure.exporter.otlp;
|
||||
|
||||
import org.apache.dubbo.config.nested.ExporterConfig.OtlpConfig;
|
||||
import org.apache.dubbo.spring.boot.autoconfigure.DubboConfigurationProperties;
|
||||
import org.apache.dubbo.spring.boot.observability.autoconfigure.annotation.ConditionalOnDubboTracingEnable;
|
||||
|
||||
import io.micrometer.tracing.otel.bridge.OtelTracer;
|
||||
import io.opentelemetry.api.OpenTelemetry;
|
||||
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
|
||||
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder;
|
||||
import io.opentelemetry.sdk.trace.SdkTracerProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.dubbo.spring.boot.observability.autoconfigure.ObservabilityUtils.DUBBO_TRACING_OTLP_CONFIG_PREFIX;
|
||||
|
||||
/**
|
||||
* @since 3.2.2
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@ConditionalOnClass({OtelTracer.class, SdkTracerProvider.class, OpenTelemetry.class, OtlpGrpcSpanExporter.class})
|
||||
@ConditionalOnDubboTracingEnable
|
||||
@EnableConfigurationProperties(DubboConfigurationProperties.class)
|
||||
public class OtlpAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = DUBBO_TRACING_OTLP_CONFIG_PREFIX, name = "endpoint")
|
||||
@ConditionalOnMissingBean(value = OtlpGrpcSpanExporter.class,
|
||||
type = "io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter")
|
||||
OtlpGrpcSpanExporter otlpGrpcSpanExporter(DubboConfigurationProperties properties) {
|
||||
OtlpConfig cfg = properties.getTracing().getTracingExporter().getOtlpConfig();
|
||||
OtlpGrpcSpanExporterBuilder builder = OtlpGrpcSpanExporter.builder()
|
||||
.setEndpoint(cfg.getEndpoint())
|
||||
.setTimeout(cfg.getTimeout())
|
||||
.setCompression(cfg.getCompressionMethod());
|
||||
for (Map.Entry<String, String> entry : cfg.getHeaders().entrySet()) {
|
||||
builder.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
|
|
@ -3,5 +3,6 @@ org.apache.dubbo.spring.boot.observability.autoconfigure.otel.OpenTelemetryAutoC
|
|||
org.apache.dubbo.spring.boot.observability.autoconfigure.DubboMicrometerTracingAutoConfiguration,\
|
||||
org.apache.dubbo.spring.boot.observability.autoconfigure.DubboObservationAutoConfiguration,\
|
||||
org.apache.dubbo.spring.boot.observability.autoconfigure.brave.BraveAutoConfiguration,\
|
||||
org.apache.dubbo.spring.boot.observability.autoconfigure.exporter.zipkin.ZipkinAutoConfiguration
|
||||
org.apache.dubbo.spring.boot.observability.autoconfigure.exporter.zipkin.ZipkinAutoConfiguration,\
|
||||
org.apache.dubbo.spring.boot.observability.autoconfigure.exporter.otlp.OtlpAutoConfiguration
|
||||
|
||||
|
|
|
|||
|
|
@ -2,4 +2,5 @@ org.apache.dubbo.spring.boot.observability.autoconfigure.otel.OpenTelemetryAutoC
|
|||
org.apache.dubbo.spring.boot.observability.autoconfigure.DubboMicrometerTracingAutoConfiguration
|
||||
org.apache.dubbo.spring.boot.observability.autoconfigure.DubboObservationAutoConfiguration
|
||||
org.apache.dubbo.spring.boot.observability.autoconfigure.brave.BraveAutoConfiguration
|
||||
org.apache.dubbo.spring.boot.observability.autoconfigure.exporter.zipkin.ZipkinAutoConfiguration
|
||||
org.apache.dubbo.spring.boot.observability.autoconfigure.exporter.zipkin.ZipkinAutoConfiguration
|
||||
org.apache.dubbo.spring.boot.observability.autoconfigure.exporter.otlp.OtlpAutoConfiguration
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>dubbo-spring-boot-observability-starters</artifactId>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>dubbo-spring-boot-tracing-otel-otlp-starter</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<description>Apache Dubbo Spring Boot Tracing Otel OTLP Starter</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-spring-boot-observability-autoconfigure</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.micrometer</groupId>
|
||||
<artifactId>micrometer-tracing-bridge-otel</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.opentelemetry</groupId>
|
||||
<artifactId>opentelemetry-exporter-otlp</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -34,6 +34,7 @@
|
|||
<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>
|
||||
<module>dubbo-spring-boot-tracing-otel-otlp-starter</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
|
|
|||
|
|
@ -404,6 +404,11 @@
|
|||
<artifactId>dubbo-spring-boot-tracing-otel-zipkin-starter</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-spring-boot-tracing-otel-otlp-starter</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-spring-boot-tracing-brave-zipkin-starter</artifactId>
|
||||
|
|
|
|||
Loading…
Reference in New Issue