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

DaanHoogland pushed a commit to branch 4.22
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.22 by this push:
     new aef91ae3240 Add OpenTelemetry tracing instrumentation to API layer 
(#13132)
aef91ae3240 is described below

commit aef91ae3240634a8cdb699d560176cc9811ad45e
Author: Suresh Kumar Anaparti <[email protected]>
AuthorDate: Thu Jun 18 12:17:35 2026 +0530

    Add OpenTelemetry tracing instrumentation to API layer (#13132)
    
    Co-authored-by: tmckeon <[email protected]>
    Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
---
 pom.xml                                           | 12 ++++++++++++
 server/pom.xml                                    |  8 ++++++++
 server/src/main/java/com/cloud/api/ApiServer.java |  8 ++++++++
 tools/docker/supervisord.conf                     |  1 +
 4 files changed, 29 insertions(+)

diff --git a/pom.xml b/pom.xml
index bd31d107c91..8392a099b57 100644
--- a/pom.xml
+++ b/pom.xml
@@ -189,6 +189,8 @@
         <cs.ini.version>0.5.4</cs.ini.version>
         <cs.caffeine.version>3.1.7</cs.caffeine.version>
         <cs.protobuf.version>3.25.5</cs.protobuf.version>
+        <cs.opentelemetry.version>1.51.0</cs.opentelemetry.version>
+        
<cs.opentelemetry-instrumentation.version>2.16.0</cs.opentelemetry-instrumentation.version>
     </properties>
 
     <distributionManagement>
@@ -427,6 +429,16 @@
                 <artifactId>commons-validator</artifactId>
                 <version>${cs.commons-validator.version}</version>
             </dependency>
+            <dependency>
+                <groupId>io.opentelemetry</groupId>
+                <artifactId>opentelemetry-api</artifactId>
+                <version>${cs.opentelemetry.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>io.opentelemetry.instrumentation</groupId>
+                
<artifactId>opentelemetry-instrumentation-annotations</artifactId>
+                <version>${cs.opentelemetry-instrumentation.version}</version>
+            </dependency>
             <dependency>
                 <groupId>javax.annotation</groupId>
                 <artifactId>javax.annotation-api</artifactId>
diff --git a/server/pom.xml b/server/pom.xml
index c7f4d24d68b..19cc0ca4583 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -197,6 +197,14 @@
             <version>4.22.2.0-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>io.opentelemetry.instrumentation</groupId>
+            <artifactId>opentelemetry-instrumentation-annotations</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.opentelemetry</groupId>
+            <artifactId>opentelemetry-api</artifactId>
+        </dependency>
     </dependencies>
     <build>
         <plugins>
diff --git a/server/src/main/java/com/cloud/api/ApiServer.java 
b/server/src/main/java/com/cloud/api/ApiServer.java
index 05ea166e13b..e3a64649078 100644
--- a/server/src/main/java/com/cloud/api/ApiServer.java
+++ b/server/src/main/java/com/cloud/api/ApiServer.java
@@ -58,6 +58,9 @@ import javax.naming.ConfigurationException;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.instrumentation.annotations.WithSpan;
+
 import com.cloud.cluster.ManagementServerHostVO;
 import com.cloud.cluster.dao.ManagementServerHostDao;
 import com.cloud.user.Account;
@@ -619,6 +622,7 @@ public class ApiServer extends ManagerBase implements 
HttpRequestHandler, ApiSer
     }
 
     @Override
+    @WithSpan("ApiServer.handleRequest")
     @SuppressWarnings("rawtypes")
     public String handleRequest(final Map params, final String responseType, 
final StringBuilder auditTrailSb) throws ServerApiException {
         checkCharacterInkParams(params);
@@ -628,6 +632,10 @@ public class ApiServer extends ManagerBase implements 
HttpRequestHandler, ApiSer
 
         try {
             command = (String[])params.get("command");
+            if (command != null && command.length > 0) {
+                Span.current().updateName("ApiServer.handleRequest " + 
command[0]);
+                Span.current().setAttribute("api.command", command[0]);
+            }
             if (command == null) {
                 logger.error("invalid request, no command sent");
                 if (logger.isTraceEnabled()) {
diff --git a/tools/docker/supervisord.conf b/tools/docker/supervisord.conf
index 93f01387575..1c14578c4cf 100644
--- a/tools/docker/supervisord.conf
+++ b/tools/docker/supervisord.conf
@@ -12,6 +12,7 @@ command=/bin/bash -c "mvn -pl client jetty:run -Dsimulator 
-Dorg.eclipse.jetty.a
 directory=/root
 stdout_logfile=/dev/stdout
 stdout_logfile_maxbytes=0
+redirect_stderr=true
 user=root
 
 [program:cloudstack-ui]

Reply via email to