diff --git a/pom.xml b/pom.xml
index 4762a4faf..de795adf0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -63,6 +63,8 @@
org.hpccsystems.commons.annotations.BaseTests
1.0.0
false
+ 1.38.0
+ 1.25.0-alpha
@@ -98,8 +100,48 @@
-
+
+
+
+ io.opentelemetry
+ opentelemetry-bom
+ ${opentelemetry.bom.version}
+ pom
+ import
+
+
+
+
+ io.opentelemetry
+ opentelemetry-api
+
+
+ io.opentelemetry
+ opentelemetry-sdk
+
+
+ io.opentelemetry
+ opentelemetry-exporter-logging
+
+
+ io.opentelemetry
+ opentelemetry-sdk-extension-autoconfigure
+
+
+ io.opentelemetry
+ opentelemetry-sdk-extension-autoconfigure-spi
+
+
+ io.opentelemetry
+ opentelemetry-exporter-otlp
+
+
+
+ io.opentelemetry.semconv
+ opentelemetry-semconv
+ 1.25.0-alpha
+
junit
junit
diff --git a/wsclient/src/main/java/org/hpccsystems/ws/client/BaseHPCCWsClient.java b/wsclient/src/main/java/org/hpccsystems/ws/client/BaseHPCCWsClient.java
index 2a856a5a2..be69ba1d3 100644
--- a/wsclient/src/main/java/org/hpccsystems/ws/client/BaseHPCCWsClient.java
+++ b/wsclient/src/main/java/org/hpccsystems/ws/client/BaseHPCCWsClient.java
@@ -4,6 +4,8 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
@@ -40,13 +42,29 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import io.opentelemetry.api.GlobalOpenTelemetry;
+import io.opentelemetry.api.OpenTelemetry;
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.SpanBuilder;
+import io.opentelemetry.api.trace.SpanKind;
+import io.opentelemetry.api.trace.StatusCode;
+import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator;
+import io.opentelemetry.context.Context;
+import io.opentelemetry.context.Scope;
+import io.opentelemetry.context.propagation.TextMapSetter;
+import io.opentelemetry.semconv.HttpAttributes;
+import io.opentelemetry.semconv.ServerAttributes;
+
/**
- * Defines functionality common to all HPCC Systmes web service clients.
+ * Defines functionality common to all HPCC Systems web service clients.
*
* Typically implemented by specialized HPCC Web service clients.
*/
public abstract class BaseHPCCWsClient extends DataSingleton
{
+ public static final String INSTRUMENTED_LIBRARY_NAME = "WsClient";
+ private static OpenTelemetry globalOTel = null;
/** Constant log
*/
protected static final Logger log = LogManager.getLogger(BaseHPCCWsClient.class);
/** Constant DEAFULTECLWATCHPORT="8010"
*/
@@ -164,6 +182,79 @@ private String getTargetHPCCBuildVersionString() throws Exception
}
+ public SpanBuilder getWsClientSpanBuilder(String spanName)
+ {
+ SpanBuilder spanBuilder = getWsClientTracer().spanBuilder(spanName)
+ .setAttribute(ServerAttributes.SERVER_ADDRESS, wsconn.getHost())
+ .setAttribute(ServerAttributes.SERVER_PORT, Long.getLong(wsconn.getPort()))
+ .setAttribute(HttpAttributes.HTTP_REQUEST_METHOD, HttpAttributes.HttpRequestMethodValues.GET)
+ .setSpanKind(SpanKind.CLIENT);
+
+ return spanBuilder;
+ }
+
+ static public void injectCurrentSpanTraceParentHeader(Stub clientStub)
+ {
+ if (clientStub != null)
+ {
+ injectCurrentSpanTraceParentHeader(clientStub._getServiceClient().getOptions());
+ }
+ }
+
+ static public void injectCurrentSpanTraceParentHeader(Options options)
+ {
+ if (options != null)
+ {
+ W3CTraceContextPropagator.getInstance().inject(Context.current(), options, Options::setProperty);
+ }
+ }
+
+ static public String getCurrentSpanTraceParentHeader()
+ {
+ String traceparent = null;
+ Span currentSpan = Span.current();
+ if (currentSpan != null && currentSpan.getSpanContext().isValid())
+ {
+ Map carrier = new HashMap<>();
+ TextMapSetter