Share tracing context in all threads 73/137173/2
authorsaul.gill <saul.gill@est.tech>
Thu, 1 Feb 2024 16:51:26 +0000 (16:51 +0000)
committersaul.gill <saul.gill@est.tech>
Wed, 7 Feb 2024 13:19:28 +0000 (13:19 +0000)
Issue-ID: POLICY-4922
Change-Id: I8f5e99b597c989a26777233ef58ef5c4f9db4215
Signed-off-by: saul.gill <saul.gill@est.tech>
participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/handler/AutomationCompositionElementHandler.java
participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ThreadHandler.java
pom.xml
runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java
runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java

index 23d4696..417b609 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2023 Nordix Foundation.
+ *  Copyright (C) 2023-2024 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
 package org.onap.policy.clamp.acm.participant.kserve.handler;
 
 import io.kubernetes.client.openapi.ApiException;
+import io.opentelemetry.context.Context;
 import jakarta.validation.Validation;
 import jakarta.validation.ValidationException;
 import java.io.IOException;
@@ -70,7 +71,8 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
 
     private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
-    private ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
+    private ExecutorService executor = Context.taskWrapping(
+            Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()));
 
     private final ParticipantIntermediaryApi intermediaryApi;
 
index e29562a..0aed919 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2023 Nordix Foundation.
+ *  Copyright (C) 2023-2024 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
 
 package org.onap.policy.clamp.acm.participant.intermediary.handler;
 
+import io.opentelemetry.context.Context;
 import java.io.Closeable;
 import java.io.IOException;
 import java.util.HashMap;
@@ -57,7 +58,8 @@ public class ThreadHandler implements Closeable {
 
     private final Map<UUID, Future> executionMap = new ConcurrentHashMap<>();
 
-    private final ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
+    private final ExecutorService executor =
+            Context.taskWrapping(Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()));
 
     /**
      * Handle an update on a automation composition element.
diff --git a/pom.xml b/pom.xml
index 846a03e..a0a902c 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         <dependency>
             <groupId>io.micrometer</groupId>
             <artifactId>micrometer-tracing-bridge-otel</artifactId>
-            <version>1.1.3</version>
+            <version>1.1.8</version>
         </dependency>
         <dependency>
             <groupId>io.opentelemetry</groupId>
index dd0ddaa..3e4c96b 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2021-2023 Nordix Foundation.
+ * Copyright (C) 2021-2024 Nordix Foundation.
  * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,6 +21,7 @@
 
 package org.onap.policy.clamp.acm.runtime.commissioning;
 
+import io.opentelemetry.context.Context;
 import jakarta.ws.rs.core.Response.Status;
 import java.util.HashSet;
 import java.util.UUID;
@@ -60,7 +61,7 @@ public class CommissioningProvider {
     private final ParticipantPrimePublisher participantPrimePublisher;
     private final AcRuntimeParameterGroup acRuntimeParameterGroup;
 
-    private final ExecutorService executor = Executors.newFixedThreadPool(1);
+    private final ExecutorService executor = Context.taskWrapping(Executors.newFixedThreadPool(1));
 
     private CommissioningResponse createCommissioningResponse(UUID compositionId,
             ToscaServiceTemplate serviceTemplate) {
index 69d48fb..a5dc0e7 100644 (file)
@@ -21,6 +21,7 @@
 package org.onap.policy.clamp.acm.runtime.supervision;
 
 import io.micrometer.core.annotation.Timed;
+import io.opentelemetry.context.Context;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
@@ -64,7 +65,7 @@ public class SupervisionAcHandler {
     private final AcElementPropertiesPublisher acElementPropertiesPublisher;
     private final AutomationCompositionMigrationPublisher acCompositionMigrationPublisher;
 
-    private final ExecutorService executor = Executors.newFixedThreadPool(1);
+    private final ExecutorService executor = Context.taskWrapping(Executors.newFixedThreadPool(1));
 
     /**
      * Handle Deploy an AutomationComposition instance.