Skip to content

Commit

Permalink
HPCC4J-612 Shift to zero-code instrumentaton
Browse files Browse the repository at this point in the history
- Removes manually declared spans
- Adds WithSpan annotations on several clients

Signed-off-by: Pastrana <[email protected]>
  • Loading branch information
Pastrana authored and Pastrana committed Sep 11, 2024
1 parent 7050cb3 commit 7ac51c3
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 115 deletions.
52 changes: 29 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-exporter-otlp</artifactId>
</dependency>
<dependency>
<!-- Not managed by opentelemetry-bom -->
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-instrumentation-annotations</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<!-- Not managed by opentelemetry-bom -->
<groupId>io.opentelemetry.semconv</groupId>
Expand Down Expand Up @@ -190,29 +196,29 @@
<type>pom</type>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
<version>${axis2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>${axis2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>${axis2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-adb</artifactId>
<version>${axis2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-jaxws</artifactId>
<version>${axis2.version}</version>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
<version>${axis2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>${axis2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>${axis2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-adb</artifactId>
<version>${axis2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-jaxws</artifactId>
<version>${axis2.version}</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.hpccsystems.ws.client;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -43,14 +42,12 @@

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.instrumentation.annotations.WithSpan;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.ServerAttributes;

Expand Down Expand Up @@ -91,6 +88,7 @@ public boolean isTargetHPCCContainerized() throws Exception
return targetsContainerizedHPCC;
}

@WithSpan
private boolean getTargetHPCCIsContainerized(Connection conn) throws Exception
{
if (wsconn == null)
Expand Down Expand Up @@ -155,6 +153,7 @@ public Version getTargetHPCCBuildVersion()
return targetHPCCBuildVersion;
}

@WithSpan
private String getTargetHPCCBuildVersionString() throws Exception
{
if (wsconn == null)
Expand Down Expand Up @@ -266,47 +265,29 @@ protected boolean initBaseWsClient(Connection connection, boolean fetchVersionAn

if (fetchVersionAndContainerMode)
{
Span fetchHPCCVerSpan = getWsClientSpanBuilder("FetchHPCCVersion").setSpanKind(SpanKind.INTERNAL).startSpan();
try (Scope scope = fetchHPCCVerSpan.makeCurrent())
try
{
try
{
targetHPCCBuildVersion = new Version(getTargetHPCCBuildVersionString());
}
catch (Exception e)
{
initErrMessage = "BaseHPCCWsClient: Could not stablish target HPCC bulid version, review all HPCC connection values";
if (!e.getLocalizedMessage().isEmpty())
initErrMessage = initErrMessage + "\n" + e.getLocalizedMessage();
success = false;
}
targetHPCCBuildVersion = new Version(getTargetHPCCBuildVersionString());
}
finally
catch (Exception e)
{
fetchHPCCVerSpan.setStatus(success ? StatusCode.OK : StatusCode.ERROR, initErrMessage);
fetchHPCCVerSpan.end();
initErrMessage = "BaseHPCCWsClient: Could not stablish target HPCC bulid version, review all HPCC connection values";
if (!e.getLocalizedMessage().isEmpty())
initErrMessage = initErrMessage + "\n" + e.getLocalizedMessage();
success = false;
}

Span fetchHPCCContainerMode = getWsClientSpanBuilder("FetchHPCCContainerMode").startSpan();
try (Scope scope = fetchHPCCContainerMode.makeCurrent())
try
{
try
{
targetsContainerizedHPCC = getTargetHPCCIsContainerized(wsconn);
}
catch (Exception e)
{
initErrMessage = initErrMessage + "\nBaseHPCCWsClient: Could not determine target HPCC Containerization mode, review all HPCC connection values";
if (!e.getLocalizedMessage().isEmpty())
initErrMessage = initErrMessage + "\n" + e.getLocalizedMessage();

success = false;
}
targetsContainerizedHPCC = getTargetHPCCIsContainerized(wsconn);
}
finally
catch (Exception e)
{
fetchHPCCContainerMode.setStatus(success ? StatusCode.OK : StatusCode.ERROR, initErrMessage);
fetchHPCCContainerMode.end();
initErrMessage = initErrMessage + "\nBaseHPCCWsClient: Could not determine target HPCC Containerization mode, review all HPCC connection values";
if (!e.getLocalizedMessage().isEmpty())
initErrMessage = initErrMessage + "\n" + e.getLocalizedMessage();

success = false;
}
}
if (!initErrMessage.isEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ HPCC SYSTEMS software Copyright (C) 2021 HPCC Systems®.
import org.hpccsystems.ws.client.wrappers.ArrayOfEspExceptionWrapper;
import org.hpccsystems.ws.client.wrappers.gen.wssmc.GetBuildInfoResponseWrapper;

import io.opentelemetry.instrumentation.annotations.WithSpan;

/**
* Use as soap client for HPCC WsSMC web service, also known as eclwatch
*/
Expand Down Expand Up @@ -209,6 +211,7 @@ private void initWsSMCSoapProxy(Connection conn)
* @throws java.lang.Exception
* the exception
*/
@WithSpan
public String getHPCCBuild() throws Exception
{
String build = null;
Expand Down Expand Up @@ -252,6 +255,7 @@ public String getHPCCBuild() throws Exception
* @throws java.lang.Exception
* the exception
*/
@WithSpan
public boolean isContainerized() throws Exception
{
verifyStub();
Expand Down Expand Up @@ -297,6 +301,7 @@ public boolean isContainerized() throws Exception
* @throws java.lang.Exception
* the exception
*/
@WithSpan
public GetBuildInfoResponseWrapper getBuildInfo() throws Exception
{
verifyStub();
Expand Down
Loading

0 comments on commit 7ac51c3

Please sign in to comment.