This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ratis.git


The following commit(s) were added to refs/heads/master by this push:
     new a09fb1d3b RATIS-2558. Move Opentelemetry to a new module (#1484)
a09fb1d3b is described below

commit a09fb1d3b8b0fa6b124be1a9617689100ccb8ead
Author: Tsz-Wo Nicholas Sze <[email protected]>
AuthorDate: Tue Jun 16 22:48:01 2026 -0700

    RATIS-2558. Move Opentelemetry to a new module (#1484)
---
 pom.xml                                            | 40 ++++++++++------------
 ratis-assembly/pom.xml                             |  4 +++
 ratis-assembly/src/main/assembly/bin.xml           |  1 +
 ratis-assembly/src/main/assembly/src.xml           |  1 +
 ratis-bom/pom.xml                                  |  5 +++
 ratis-common/pom.xml                               | 14 --------
 .../java/org/apache/ratis/trace/TraceUtils.java    | 10 +++---
 .../java/org/apache/ratis/util/ServiceUtils.java   |  4 +++
 ratis-server/pom.xml                               |  5 ---
 ratis-test/pom.xml                                 | 13 +++++++
 .../server/impl/RaftServerImplTracingTests.java    |  0
 .../org/apache/ratis/trace/TestTraceUtils.java     |  7 ++++
 .../dev-support/findbugsExcludeFile.xml            | 18 ++++++++++
 {ratis-common => ratis-trace-otel}/pom.xml         | 30 ++++++----------
 .../ratis/trace/otel/OTelRatisAttributes.java      |  0
 .../apache/ratis/trace/otel/OTelTraceProvider.java |  0
 .../apache/ratis/trace/otel/OTelTraceUtils.java    |  0
 .../services/org.apache.ratis.trace.TraceProvider  | 18 ++++++++++
 18 files changed, 105 insertions(+), 65 deletions(-)

diff --git a/pom.xml b/pom.xml
index f95611394..ca947366a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,14 +64,16 @@
     <module>ratis-grpc</module>
     <module>ratis-netty</module>
 
-    <module>ratis-test</module>
-
-    <module>ratis-examples</module>
     <module>ratis-metrics-api</module>
     <module>ratis-metrics-default</module>
     <module>ratis-metrics-dropwizard3</module>
+    <module>ratis-trace-otel</module>
+
     <module>ratis-tools</module>
     <module>ratis-shell</module>
+    <module>ratis-examples</module>
+    <module>ratis-test</module>
+
     <module>ratis-assembly</module>
     <module>ratis-bom</module>
   </modules>
@@ -270,6 +272,20 @@
         <type>test-jar</type>
         <scope>test</scope>
       </dependency>
+
+      <dependency>
+        <artifactId>ratis-trace-otel</artifactId>
+        <groupId>org.apache.ratis</groupId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <artifactId>ratis-trace-otel</artifactId>
+        <groupId>org.apache.ratis</groupId>
+        <version>${project.version}</version>
+        <type>test-jar</type>
+        <scope>test</scope>
+      </dependency>
+
       <dependency>
         <artifactId>ratis-tools</artifactId>
         <groupId>org.apache.ratis</groupId>
@@ -386,25 +402,7 @@
         <artifactId>mockito-core</artifactId>
         <version>${mockito.version}</version>
       </dependency>
-
-      <!-- OpenTelemetry dependencies -->
-      <dependency>
-        <groupId>io.opentelemetry</groupId>
-        <artifactId>opentelemetry-api</artifactId>
-        <version>${opentelemetry.version}</version>
-      </dependency>
-      <dependency>
-        <groupId>io.opentelemetry</groupId>
-        <artifactId>opentelemetry-sdk-testing</artifactId>
-        <version>${opentelemetry.version}</version>
-      </dependency>
-      <dependency>
-        <groupId>io.opentelemetry</groupId>
-        <artifactId>opentelemetry-context</artifactId>
-        <version>${opentelemetry.version}</version>
-      </dependency>
     </dependencies>
-
   </dependencyManagement>
 
   <build>
diff --git a/ratis-assembly/pom.xml b/ratis-assembly/pom.xml
index 055869303..394adf9e9 100644
--- a/ratis-assembly/pom.xml
+++ b/ratis-assembly/pom.xml
@@ -281,6 +281,10 @@
       <groupId>org.apache.ratis</groupId>
       <artifactId>ratis-metrics-default</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.ratis</groupId>
+      <artifactId>ratis-trace-otel</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.apache.ratis</groupId>
       <artifactId>ratis-tools</artifactId>
diff --git a/ratis-assembly/src/main/assembly/bin.xml 
b/ratis-assembly/src/main/assembly/bin.xml
index 12161b00a..05286e571 100644
--- a/ratis-assembly/src/main/assembly/bin.xml
+++ b/ratis-assembly/src/main/assembly/bin.xml
@@ -50,6 +50,7 @@
         <include>org.apache.ratis:ratis-metrics-api</include>
         <include>org.apache.ratis:ratis-metrics-default</include>
         <include>org.apache.ratis:ratis-metrics-dropwizard3</include>
+        <include>org.apache.ratis:ratis-trace-otel</include>
         <include>org.apache.ratis:ratis-shell</include>
         <include>org.apache.ratis:ratis-tools</include>
         <include>org.apache.ratis:ratis-resource-bundle</include>
diff --git a/ratis-assembly/src/main/assembly/src.xml 
b/ratis-assembly/src/main/assembly/src.xml
index e20770d54..a2b094b83 100644
--- a/ratis-assembly/src/main/assembly/src.xml
+++ b/ratis-assembly/src/main/assembly/src.xml
@@ -46,6 +46,7 @@
         <include>org.apache.ratis:ratis-metrics-api</include>
         <include>org.apache.ratis:ratis-metrics-default</include>
         <include>org.apache.ratis:ratis-metrics-dropwizard3</include>
+        <include>org.apache.ratis:ratis-trace-otel</include>
         <include>org.apache.ratis:ratis-tools</include>
         <include>org.apache.ratis:ratis-resource-bundle</include>
       </includes>
diff --git a/ratis-bom/pom.xml b/ratis-bom/pom.xml
index c07161e4c..34402c4fb 100644
--- a/ratis-bom/pom.xml
+++ b/ratis-bom/pom.xml
@@ -100,6 +100,11 @@
         <artifactId>ratis-metrics-dropwizard3</artifactId>
         <version>${project.version}</version>
       </dependency>
+      <dependency>
+        <groupId>org.apache.ratis</groupId>
+        <artifactId>ratis-trace-otel</artifactId>
+        <version>${project.version}</version>
+      </dependency>
       <dependency>
         <groupId>org.apache.ratis</groupId>
         <artifactId>ratis-netty</artifactId>
diff --git a/ratis-common/pom.xml b/ratis-common/pom.xml
index 1d7a69fa5..f6bc0ee41 100644
--- a/ratis-common/pom.xml
+++ b/ratis-common/pom.xml
@@ -38,20 +38,6 @@
       <artifactId>slf4j-api</artifactId>
     </dependency>
 
-    <dependency>
-      <groupId>io.opentelemetry</groupId>
-      <artifactId>opentelemetry-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>io.opentelemetry</groupId>
-      <artifactId>opentelemetry-context</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>io.opentelemetry</groupId>
-      <artifactId>opentelemetry-sdk-testing</artifactId>
-      <scope>test</scope>
-    </dependency>
-
     <dependency>
       <groupId>org.junit.jupiter</groupId>
       <artifactId>junit-jupiter-api</artifactId>
diff --git a/ratis-common/src/main/java/org/apache/ratis/trace/TraceUtils.java 
b/ratis-common/src/main/java/org/apache/ratis/trace/TraceUtils.java
index 780a4e650..d91a8edb2 100644
--- a/ratis-common/src/main/java/org/apache/ratis/trace/TraceUtils.java
+++ b/ratis-common/src/main/java/org/apache/ratis/trace/TraceUtils.java
@@ -18,7 +18,7 @@
 package org.apache.ratis.trace;
 
 import org.apache.ratis.conf.RaftProperties;
-import org.apache.ratis.trace.otel.OTelTraceProvider;
+import org.apache.ratis.util.ServiceUtils;
 
 import java.util.concurrent.atomic.AtomicReference;
 
@@ -48,7 +48,7 @@ public final class TraceUtils {
    * @param enabled when true, enables the OpenTelemetry provider; when false, 
clears it
    */
   public static void setTracerWhenEnabled(boolean enabled) {
-    PROVIDER.set(enabled ? newOpenTelemetryTraceProvider() : 
NoOpTraceProvider.INSTANCE);
+    PROVIDER.set(enabled ? loadTraceProvider() : NoOpTraceProvider.INSTANCE);
   }
 
   public static boolean isEnabled() {
@@ -59,11 +59,11 @@ public final class TraceUtils {
     return PROVIDER.get();
   }
 
-  private static TraceProvider newOpenTelemetryTraceProvider() {
+  private static TraceProvider loadTraceProvider() {
     try {
-      return new OTelTraceProvider();
+      return ServiceUtils.load(TraceProvider.class, () -> 
NoOpTraceProvider.INSTANCE);
     } catch (Throwable e) {
-      throw new IllegalStateException("Failed to create OTelTraceProvider.", 
e);
+      throw new IllegalStateException("Failed to load " + 
TraceProvider.class.getSimpleName(), e);
     }
   }
 }
diff --git a/ratis-common/src/main/java/org/apache/ratis/util/ServiceUtils.java 
b/ratis-common/src/main/java/org/apache/ratis/util/ServiceUtils.java
index bb772b516..c031acee4 100644
--- a/ratis-common/src/main/java/org/apache/ratis/util/ServiceUtils.java
+++ b/ratis-common/src/main/java/org/apache/ratis/util/ServiceUtils.java
@@ -37,6 +37,10 @@ public final class ServiceUtils {
         throw new IllegalStateException("Failed to load " + defaultClass, e);
       }
     };
+    return load(serviceInterface, defaultInstance);
+  }
+
+  public static <T> T load(Class<T> serviceInterface, Supplier<T> 
defaultInstance) {
     final List<T> providers = loadServiceProviders(serviceInterface);
     return load(serviceInterface, defaultInstance, providers);
   }
diff --git a/ratis-server/pom.xml b/ratis-server/pom.xml
index 74cd7c546..2c0bc93a2 100644
--- a/ratis-server/pom.xml
+++ b/ratis-server/pom.xml
@@ -84,11 +84,6 @@
       <artifactId>mockito-core</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>io.opentelemetry</groupId>
-      <artifactId>opentelemetry-sdk-testing</artifactId>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>org.apache.ratis</groupId>
       <artifactId>ratis-metrics-api</artifactId>
diff --git a/ratis-test/pom.xml b/ratis-test/pom.xml
index 54f076ac1..1b1b5b4c8 100644
--- a/ratis-test/pom.xml
+++ b/ratis-test/pom.xml
@@ -64,6 +64,18 @@
       <scope>test</scope>
     </dependency>
 
+    <dependency>
+      <artifactId>ratis-trace-otel</artifactId>
+      <groupId>org.apache.ratis</groupId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <artifactId>ratis-trace-otel</artifactId>
+      <groupId>org.apache.ratis</groupId>
+      <scope>test</scope>
+      <type>test-jar</type>
+    </dependency>
+
     <dependency>
       <artifactId>ratis-netty</artifactId>
       <groupId>org.apache.ratis</groupId>
@@ -160,6 +172,7 @@
       <groupId>io.opentelemetry</groupId>
       <artifactId>opentelemetry-sdk-testing</artifactId>
       <scope>test</scope>
+      <version>${opentelemetry.version}</version>
     </dependency>
   </dependencies>
 </project>
diff --git 
a/ratis-server/src/test/java/org/apache/ratis/server/impl/RaftServerImplTracingTests.java
 
b/ratis-test/src/test/java/org/apache/ratis/server/impl/RaftServerImplTracingTests.java
similarity index 100%
rename from 
ratis-server/src/test/java/org/apache/ratis/server/impl/RaftServerImplTracingTests.java
rename to 
ratis-test/src/test/java/org/apache/ratis/server/impl/RaftServerImplTracingTests.java
diff --git 
a/ratis-common/src/test/java/org/apache/ratis/trace/TestTraceUtils.java 
b/ratis-test/src/test/java/org/apache/ratis/trace/TestTraceUtils.java
similarity index 88%
rename from 
ratis-common/src/test/java/org/apache/ratis/trace/TestTraceUtils.java
rename to ratis-test/src/test/java/org/apache/ratis/trace/TestTraceUtils.java
index 71f0f2564..20b400df9 100644
--- a/ratis-common/src/test/java/org/apache/ratis/trace/TestTraceUtils.java
+++ b/ratis-test/src/test/java/org/apache/ratis/trace/TestTraceUtils.java
@@ -18,12 +18,14 @@
 package org.apache.ratis.trace;
 
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import io.opentelemetry.api.trace.SpanKind;
 import io.opentelemetry.sdk.testing.junit5.OpenTelemetryExtension;
 import io.opentelemetry.sdk.trace.data.SpanData;
 import org.apache.ratis.protocol.RaftPeerId;
+import org.apache.ratis.trace.otel.OTelTraceProvider;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 
@@ -39,6 +41,11 @@ public class TestTraceUtils {
   private void runTraceAsyncAndAssertClientSpan(boolean tracingEnabled, 
boolean expectClientSpan)
       throws Exception {
     TraceUtils.setTracerWhenEnabled(tracingEnabled);
+    if (tracingEnabled) {
+      assertSame(OTelTraceProvider.class, TraceUtils.getProvider().getClass());
+    } else {
+      assertSame(NoOpTraceProvider.class, TraceUtils.getProvider().getClass());
+    }
     TraceClient.asyncSend(
         () -> CompletableFuture.completedFuture("ok"),
         null,
diff --git a/ratis-trace-otel/dev-support/findbugsExcludeFile.xml 
b/ratis-trace-otel/dev-support/findbugsExcludeFile.xml
new file mode 100644
index 000000000..3616f05a1
--- /dev/null
+++ b/ratis-trace-otel/dev-support/findbugsExcludeFile.xml
@@ -0,0 +1,18 @@
+<!--
+   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.
+-->
+<FindBugsFilter>
+</FindBugsFilter>
\ No newline at end of file
diff --git a/ratis-common/pom.xml b/ratis-trace-otel/pom.xml
similarity index 73%
copy from ratis-common/pom.xml
copy to ratis-trace-otel/pom.xml
index 1d7a69fa5..6e04f3286 100644
--- a/ratis-common/pom.xml
+++ b/ratis-trace-otel/pom.xml
@@ -12,7 +12,8 @@
   See the License for the specific language governing permissions and
   limitations under the License. See accompanying LICENSE file.
 -->
-<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";>
+<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>ratis</artifactId>
@@ -20,17 +21,13 @@
     <version>3.3.0-SNAPSHOT</version>
   </parent>
 
-  <artifactId>ratis-common</artifactId>
-  <name>Apache Ratis Common</name>
+  <artifactId>ratis-trace-otel</artifactId>
+  <name>Apache Ratis Tracing - OpenTelemetry</name>
 
   <dependencies>
     <dependency>
+      <artifactId>ratis-common</artifactId>
       <groupId>org.apache.ratis</groupId>
-      <artifactId>ratis-thirdparty-misc</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.ratis</groupId>
-      <artifactId>ratis-proto</artifactId>
     </dependency>
 
     <dependency>
@@ -41,35 +38,28 @@
     <dependency>
       <groupId>io.opentelemetry</groupId>
       <artifactId>opentelemetry-api</artifactId>
+      <version>${opentelemetry.version}</version>
     </dependency>
     <dependency>
       <groupId>io.opentelemetry</groupId>
       <artifactId>opentelemetry-context</artifactId>
+      <version>${opentelemetry.version}</version>
     </dependency>
     <dependency>
       <groupId>io.opentelemetry</groupId>
-      <artifactId>opentelemetry-sdk-testing</artifactId>
+      <artifactId>opentelemetry-sdk</artifactId>
+      <version>${opentelemetry.version}</version>
       <scope>test</scope>
     </dependency>
 
-    <dependency>
-      <groupId>org.junit.jupiter</groupId>
-      <artifactId>junit-jupiter-api</artifactId>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>org.junit.jupiter</groupId>
       <artifactId>junit-jupiter-engine</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.junit.platform</groupId>
-      <artifactId>junit-platform-launcher</artifactId>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>org.junit.jupiter</groupId>
-      <artifactId>junit-jupiter-params</artifactId>
+      <artifactId>junit-jupiter-api</artifactId>
       <scope>test</scope>
     </dependency>
   </dependencies>
diff --git 
a/ratis-common/src/main/java/org/apache/ratis/trace/otel/OTelRatisAttributes.java
 
b/ratis-trace-otel/src/main/java/org/apache/ratis/trace/otel/OTelRatisAttributes.java
similarity index 100%
rename from 
ratis-common/src/main/java/org/apache/ratis/trace/otel/OTelRatisAttributes.java
rename to 
ratis-trace-otel/src/main/java/org/apache/ratis/trace/otel/OTelRatisAttributes.java
diff --git 
a/ratis-common/src/main/java/org/apache/ratis/trace/otel/OTelTraceProvider.java 
b/ratis-trace-otel/src/main/java/org/apache/ratis/trace/otel/OTelTraceProvider.java
similarity index 100%
rename from 
ratis-common/src/main/java/org/apache/ratis/trace/otel/OTelTraceProvider.java
rename to 
ratis-trace-otel/src/main/java/org/apache/ratis/trace/otel/OTelTraceProvider.java
diff --git 
a/ratis-common/src/main/java/org/apache/ratis/trace/otel/OTelTraceUtils.java 
b/ratis-trace-otel/src/main/java/org/apache/ratis/trace/otel/OTelTraceUtils.java
similarity index 100%
rename from 
ratis-common/src/main/java/org/apache/ratis/trace/otel/OTelTraceUtils.java
rename to 
ratis-trace-otel/src/main/java/org/apache/ratis/trace/otel/OTelTraceUtils.java
diff --git 
a/ratis-trace-otel/src/main/resources/META-INF/services/org.apache.ratis.trace.TraceProvider
 
b/ratis-trace-otel/src/main/resources/META-INF/services/org.apache.ratis.trace.TraceProvider
new file mode 100644
index 000000000..7ffa6d664
--- /dev/null
+++ 
b/ratis-trace-otel/src/main/resources/META-INF/services/org.apache.ratis.trace.TraceProvider
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+org.apache.ratis.trace.otel.OTelTraceProvider
\ No newline at end of file

Reply via email to