Skip to content

Commit 874dba1

Browse files
rpastranaPastrana
and
Pastrana
authored
HPCC4J-612 Shift to zero-code instrumentaton (#747)
Signed-off-by: Pastrana <[email protected]> Co-authored-by: Pastrana <[email protected]>
1 parent 51661a6 commit 874dba1

37 files changed

+443
-219
lines changed

dfsclient/src/main/java/org/hpccsystems/dfs/client/HPCCRemoteFileWriter.java

-4
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@
1515
import org.hpccsystems.commons.ecl.FieldDef;
1616
import org.hpccsystems.commons.ecl.RecordDefinitionTranslator;
1717

18-
import org.hpccsystems.dfs.client.RowServiceOutputStream;
19-
import org.hpccsystems.dfs.client.Utils;
20-
2118
import io.opentelemetry.api.common.AttributeKey;
2219
import io.opentelemetry.api.common.Attributes;
2320
import io.opentelemetry.api.trace.Span;
2421
import io.opentelemetry.api.trace.StatusCode;
25-
import io.opentelemetry.semconv.ServerAttributes;
2622

2723
import org.apache.logging.log4j.Logger;
2824
import org.apache.logging.log4j.LogManager;

dfsclient/src/main/java/org/hpccsystems/dfs/client/HpccRemoteFileReader.java

-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
*******************************************************************************/
1313
package org.hpccsystems.dfs.client;
1414

15-
import org.hpccsystems.dfs.client.Utils;
16-
1715
import org.hpccsystems.commons.ecl.FieldDef;
1816
import org.hpccsystems.commons.ecl.RecordDefinitionTranslator;
1917
import org.hpccsystems.commons.errors.HpccFileException;
@@ -22,7 +20,6 @@
2220
import io.opentelemetry.api.common.Attributes;
2321
import io.opentelemetry.api.trace.Span;
2422
import io.opentelemetry.api.trace.StatusCode;
25-
import io.opentelemetry.semconv.ServerAttributes;
2623

2724
import org.apache.logging.log4j.Logger;
2825
import org.apache.logging.log4j.LogManager;

dfsclient/src/main/java/org/hpccsystems/dfs/client/RowServiceInputStream.java

-2
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@
4747
import io.opentelemetry.api.common.Attributes;
4848
import io.opentelemetry.api.trace.Span;
4949
import io.opentelemetry.api.trace.StatusCode;
50-
import io.opentelemetry.context.Context;
5150
import io.opentelemetry.semconv.ExceptionAttributes;
52-
import io.opentelemetry.semconv.ServerAttributes;
5351
import io.opentelemetry.semconv.ServiceAttributes;
5452

5553
/**

pom.xml

+30-23
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
<project.benchmarking>false</project.benchmarking>
6565
<opentelemetry.bom.version>1.38.0</opentelemetry.bom.version>
6666
<opentelemetry.semconv.version>1.25.0-alpha</opentelemetry.semconv.version>
67+
<opentelemetry.instrumentation.annotations.version>2.6.0</opentelemetry.instrumentation.annotations.version>
6768
</properties>
6869

6970
<scm>
@@ -135,6 +136,12 @@
135136
<groupId>io.opentelemetry</groupId>
136137
<artifactId>opentelemetry-exporter-otlp</artifactId>
137138
</dependency>
139+
<dependency>
140+
<!-- Not managed by opentelemetry-bom -->
141+
<groupId>io.opentelemetry.instrumentation</groupId>
142+
<artifactId>opentelemetry-instrumentation-annotations</artifactId>
143+
<version>${opentelemetry.instrumentation.annotations.version}</version>
144+
</dependency>
138145
<dependency>
139146
<!-- Not managed by opentelemetry-bom -->
140147
<groupId>io.opentelemetry.semconv</groupId>
@@ -190,29 +197,29 @@
190197
<type>pom</type>
191198
</dependency>
192199
<dependency>
193-
<groupId>org.apache.axis2</groupId>
194-
<artifactId>axis2-kernel</artifactId>
195-
<version>${axis2.version}</version>
196-
</dependency>
197-
<dependency>
198-
<groupId>org.apache.axis2</groupId>
199-
<artifactId>axis2-transport-http</artifactId>
200-
<version>${axis2.version}</version>
201-
</dependency>
202-
<dependency>
203-
<groupId>org.apache.axis2</groupId>
204-
<artifactId>axis2-transport-local</artifactId>
205-
<version>${axis2.version}</version>
206-
</dependency>
207-
<dependency>
208-
<groupId>org.apache.axis2</groupId>
209-
<artifactId>axis2-adb</artifactId>
210-
<version>${axis2.version}</version>
211-
</dependency>
212-
<dependency>
213-
<groupId>org.apache.axis2</groupId>
214-
<artifactId>axis2-jaxws</artifactId>
215-
<version>${axis2.version}</version>
200+
<groupId>org.apache.axis2</groupId>
201+
<artifactId>axis2-kernel</artifactId>
202+
<version>${axis2.version}</version>
203+
</dependency>
204+
<dependency>
205+
<groupId>org.apache.axis2</groupId>
206+
<artifactId>axis2-transport-http</artifactId>
207+
<version>${axis2.version}</version>
208+
</dependency>
209+
<dependency>
210+
<groupId>org.apache.axis2</groupId>
211+
<artifactId>axis2-transport-local</artifactId>
212+
<version>${axis2.version}</version>
213+
</dependency>
214+
<dependency>
215+
<groupId>org.apache.axis2</groupId>
216+
<artifactId>axis2-adb</artifactId>
217+
<version>${axis2.version}</version>
218+
</dependency>
219+
<dependency>
220+
<groupId>org.apache.axis2</groupId>
221+
<artifactId>axis2-jaxws</artifactId>
222+
<version>${axis2.version}</version>
216223
</dependency>
217224
</dependencies>
218225

wsclient/src/main/java/org/hpccsystems/ws/client/BaseHPCCWsClient.java

+18-37
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.hpccsystems.ws.client;
22

33
import java.io.ByteArrayInputStream;
4-
import java.io.IOException;
54
import java.net.MalformedURLException;
65
import java.net.URL;
76
import java.nio.charset.StandardCharsets;
@@ -43,14 +42,12 @@
4342

4443
import io.opentelemetry.api.GlobalOpenTelemetry;
4544
import io.opentelemetry.api.OpenTelemetry;
46-
import io.opentelemetry.api.trace.Span;
4745
import io.opentelemetry.api.trace.SpanBuilder;
4846
import io.opentelemetry.api.trace.SpanKind;
49-
import io.opentelemetry.api.trace.StatusCode;
5047
import io.opentelemetry.api.trace.Tracer;
5148
import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator;
5249
import io.opentelemetry.context.Context;
53-
import io.opentelemetry.context.Scope;
50+
import io.opentelemetry.instrumentation.annotations.WithSpan;
5451
import io.opentelemetry.semconv.HttpAttributes;
5552
import io.opentelemetry.semconv.ServerAttributes;
5653

@@ -91,6 +88,7 @@ public boolean isTargetHPCCContainerized() throws Exception
9188
return targetsContainerizedHPCC;
9289
}
9390

91+
@WithSpan
9492
private boolean getTargetHPCCIsContainerized(Connection conn) throws Exception
9593
{
9694
if (wsconn == null)
@@ -155,6 +153,7 @@ public Version getTargetHPCCBuildVersion()
155153
return targetHPCCBuildVersion;
156154
}
157155

156+
@WithSpan
158157
private String getTargetHPCCBuildVersionString() throws Exception
159158
{
160159
if (wsconn == null)
@@ -266,47 +265,29 @@ protected boolean initBaseWsClient(Connection connection, boolean fetchVersionAn
266265

267266
if (fetchVersionAndContainerMode)
268267
{
269-
Span fetchHPCCVerSpan = getWsClientSpanBuilder("FetchHPCCVersion").setSpanKind(SpanKind.INTERNAL).startSpan();
270-
try (Scope scope = fetchHPCCVerSpan.makeCurrent())
268+
try
271269
{
272-
try
273-
{
274-
targetHPCCBuildVersion = new Version(getTargetHPCCBuildVersionString());
275-
}
276-
catch (Exception e)
277-
{
278-
initErrMessage = "BaseHPCCWsClient: Could not stablish target HPCC bulid version, review all HPCC connection values";
279-
if (!e.getLocalizedMessage().isEmpty())
280-
initErrMessage = initErrMessage + "\n" + e.getLocalizedMessage();
281-
success = false;
282-
}
270+
targetHPCCBuildVersion = new Version(getTargetHPCCBuildVersionString());
283271
}
284-
finally
272+
catch (Exception e)
285273
{
286-
fetchHPCCVerSpan.setStatus(success ? StatusCode.OK : StatusCode.ERROR, initErrMessage);
287-
fetchHPCCVerSpan.end();
274+
initErrMessage = "BaseHPCCWsClient: Could not stablish target HPCC bulid version, review all HPCC connection values";
275+
if (!e.getLocalizedMessage().isEmpty())
276+
initErrMessage = initErrMessage + "\n" + e.getLocalizedMessage();
277+
success = false;
288278
}
289279

290-
Span fetchHPCCContainerMode = getWsClientSpanBuilder("FetchHPCCContainerMode").startSpan();
291-
try (Scope scope = fetchHPCCContainerMode.makeCurrent())
280+
try
292281
{
293-
try
294-
{
295-
targetsContainerizedHPCC = getTargetHPCCIsContainerized(wsconn);
296-
}
297-
catch (Exception e)
298-
{
299-
initErrMessage = initErrMessage + "\nBaseHPCCWsClient: Could not determine target HPCC Containerization mode, review all HPCC connection values";
300-
if (!e.getLocalizedMessage().isEmpty())
301-
initErrMessage = initErrMessage + "\n" + e.getLocalizedMessage();
302-
303-
success = false;
304-
}
282+
targetsContainerizedHPCC = getTargetHPCCIsContainerized(wsconn);
305283
}
306-
finally
284+
catch (Exception e)
307285
{
308-
fetchHPCCContainerMode.setStatus(success ? StatusCode.OK : StatusCode.ERROR, initErrMessage);
309-
fetchHPCCContainerMode.end();
286+
initErrMessage = initErrMessage + "\nBaseHPCCWsClient: Could not determine target HPCC Containerization mode, review all HPCC connection values";
287+
if (!e.getLocalizedMessage().isEmpty())
288+
initErrMessage = initErrMessage + "\n" + e.getLocalizedMessage();
289+
290+
success = false;
310291
}
311292
}
312293
if (!initErrMessage.isEmpty())

wsclient/src/main/java/org/hpccsystems/ws/client/HPCCFileSprayClient.java

+31-15
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@
8989
import org.hpccsystems.ws.client.wrappers.gen.filespray.ProgressResponseWrapper;
9090
import org.w3c.dom.Document;
9191

92+
import io.opentelemetry.instrumentation.annotations.SpanAttribute;
93+
import io.opentelemetry.instrumentation.annotations.WithSpan;
94+
9295
/**
9396
* Facilitates File Spray related activities.
9497
* This includes listing available dropzones, uploading files to dropzone, listing files in a dropzone,
@@ -356,7 +359,6 @@ private void initWsFileSprayStub(Connection connection)
356359
{
357360
initErrMessage += "\nCould not initialize FileSprayStub - Review all HPCC connection values";
358361
}
359-
360362
}
361363

362364
/**
@@ -421,6 +423,7 @@ public void setFileUploadReadBufferLength(int length)
421423
* @throws org.hpccsystems.ws.client.wrappers.ArrayOfEspExceptionWrapper
422424
* the array of esp exception wrapper
423425
*/
426+
@WithSpan
424427
public boolean handleSprayResponse(ProgressResponseWrapper progressResponseWrapper, int maxRetries, int milliesBetweenRetry)
425428
throws Exception, org.hpccsystems.ws.client.wrappers.ArrayOfEspExceptionWrapper
426429
{
@@ -560,7 +563,8 @@ public List<DropZoneWrapper> fetchLocalDropZones() throws Exception, ArrayOfEspE
560563
* @throws org.hpccsystems.ws.client.wrappers.ArrayOfEspExceptionWrapper
561564
* the array of esp exception wrapper
562565
*/
563-
public List<DropZoneWrapper> fetchDropZones(String dropzoneNetAddress) throws Exception, ArrayOfEspExceptionWrapper
566+
@WithSpan
567+
public List<DropZoneWrapper> fetchDropZones(@SpanAttribute String dropzoneNetAddress) throws Exception, ArrayOfEspExceptionWrapper
564568
{
565569
verifyStub();
566570

@@ -621,7 +625,8 @@ public List<DropZoneWrapper> fetchDropZones(String dropzoneNetAddress) throws Ex
621625
* @throws org.hpccsystems.ws.client.wrappers.ArrayOfEspExceptionWrapper
622626
* the array of esp exception wrapper
623627
*/
624-
public String copyFile(String from, String to, boolean overwrite) throws Exception, ArrayOfEspExceptionWrapper
628+
@WithSpan
629+
public String copyFile(@SpanAttribute String from, @SpanAttribute String to, @SpanAttribute boolean overwrite) throws Exception, ArrayOfEspExceptionWrapper
625630
{
626631
verifyStub();
627632
Copy cp = new Copy();
@@ -671,7 +676,8 @@ public String copyFile(String from, String to, boolean overwrite) throws Excepti
671676
* @throws org.hpccsystems.ws.client.wrappers.ArrayOfEspExceptionWrapper
672677
* the array of esp exception wrapper
673678
*/
674-
public DropZoneFilesResponseWrapper fetchDropZones(String dzname, String netaddress, String os, String path, String subfolder, boolean dironly,
679+
@WithSpan
680+
public DropZoneFilesResponseWrapper fetchDropZones(@SpanAttribute String dzname, @SpanAttribute String netaddress, @SpanAttribute String os, @SpanAttribute String path, String subfolder, boolean dironly,
675681
boolean watchvisibleonely) throws Exception, ArrayOfEspExceptionWrapper
676682
{
677683
verifyStub();
@@ -699,6 +705,7 @@ public DropZoneFilesResponseWrapper fetchDropZones(String dzname, String netaddr
699705
* @throws org.hpccsystems.ws.client.wrappers.ArrayOfEspExceptionWrapper
700706
* the array of esp exception wrapper
701707
*/
708+
@WithSpan
702709
public DropZoneFilesResponseWrapper fetchDropZones(DropZoneFilesRequestWrapper szrequest) throws Exception, ArrayOfEspExceptionWrapper
703710
{
704711
if (szrequest == null) throw new Exception("DropZoneFilesRequestWrapper null detected");
@@ -740,7 +747,8 @@ public DropZoneFilesResponseWrapper fetchDropZones(DropZoneFilesRequestWrapper s
740747
* @throws org.hpccsystems.ws.client.wrappers.ArrayOfEspExceptionWrapper
741748
* the array of esp exception wrapper
742749
*/
743-
public PhysicalFileStruct[] dzFileSearch(String dzname, String netaddr, String namefilter) throws Exception, ArrayOfEspExceptionWrapper
750+
@WithSpan
751+
public PhysicalFileStruct[] dzFileSearch(@SpanAttribute String dzname, @SpanAttribute String netaddr, @SpanAttribute String namefilter) throws Exception, ArrayOfEspExceptionWrapper
744752
{
745753
verifyStub();
746754

@@ -788,7 +796,8 @@ public PhysicalFileStruct[] dzFileSearch(String dzname, String netaddr, String n
788796
* @throws org.hpccsystems.ws.client.wrappers.ArrayOfEspExceptionWrapper
789797
* the array of esp exception wrapper
790798
*/
791-
public List<PhysicalFileStructWrapper> listFiles(String netAddress, String path, String OS) throws Exception, ArrayOfEspExceptionWrapper
799+
@WithSpan
800+
public List<PhysicalFileStructWrapper> listFiles(@SpanAttribute String netAddress, @SpanAttribute String path, @SpanAttribute String OS) throws Exception, ArrayOfEspExceptionWrapper
792801
{
793802
verifyStub();
794803

@@ -994,8 +1003,9 @@ public ProgressResponseWrapper sprayVariable(DelimitedDataOptions options, DropZ
9941003
* @throws org.hpccsystems.ws.client.wrappers.ArrayOfEspExceptionWrapper
9951004
* the array of esp exception wrapper
9961005
*/
997-
public ProgressResponseWrapper sprayVariable(DelimitedDataOptions options, DropZoneWrapper targetDropZone, String sourceFileName,
998-
String targetFileName, String prefix, String destGroup, boolean overwrite, SprayVariableFormat format, Integer sourceMaxRecordSize,
1006+
@WithSpan
1007+
public ProgressResponseWrapper sprayVariable(@SpanAttribute DelimitedDataOptions options, @SpanAttribute DropZoneWrapper targetDropZone, @SpanAttribute String sourceFileName,
1008+
@SpanAttribute String targetFileName, String prefix, String destGroup, boolean overwrite, SprayVariableFormat format, Integer sourceMaxRecordSize,
9991009
Integer maxConnections, Boolean compress, Boolean replicate, Boolean failIfNoSourceFile, Boolean recordStructurePresent,
10001010
Integer expireDays) throws Exception, ArrayOfEspExceptionWrapper
10011011
{
@@ -1149,8 +1159,9 @@ public ProgressResponseWrapper sprayLocalXML(String sourceFileName, String targe
11491159
* @throws org.hpccsystems.ws.client.wrappers.ArrayOfEspExceptionWrapper
11501160
* the array of esp exception wrapper
11511161
*/
1152-
public ProgressResponseWrapper sprayXML(DropZoneWrapper targetDropZone, String sourceFileName, String targetFileName, String prefix,
1153-
String destGroup, String rowtag, boolean overwrite, SprayVariableFormat format, Integer maxrecsize, Integer maxConnections,
1162+
@WithSpan
1163+
public ProgressResponseWrapper sprayXML(@SpanAttribute DropZoneWrapper targetDropZone,@SpanAttribute String sourceFileName,@SpanAttribute String targetFileName, String prefix,
1164+
@SpanAttribute String destGroup, String rowtag, boolean overwrite, SprayVariableFormat format, Integer maxrecsize, Integer maxConnections,
11541165
Boolean replicate, Boolean compress, Boolean failIfNoSourceFile, Integer expireDays) throws Exception, ArrayOfEspExceptionWrapper
11551166
{
11561167
verifyStub();
@@ -1303,7 +1314,8 @@ public ProgressResponseWrapper sprayFixedLocalDropZone(String sourceFileName, in
13031314
* @throws org.hpccsystems.ws.client.wrappers.ArrayOfEspExceptionWrapper
13041315
* the array of esp exception wrapper
13051316
*/
1306-
public ProgressResponseWrapper sprayFixed(DropZoneWrapper targetDropZone, String sourceFileName, int recordSize, String targetFileLabel,
1317+
@WithSpan
1318+
public ProgressResponseWrapper sprayFixed(@SpanAttribute DropZoneWrapper targetDropZone, @SpanAttribute String sourceFileName, int recordSize, String targetFileLabel,
13071319
String prefix, String destGroup, boolean overwrite, Integer maxConnections, Boolean compress, Boolean replicate,
13081320
Boolean failIfNoSourceFile, Integer expireDays, String decryptKey, String encryptKey, Boolean nosplit, Boolean recordStructurePresent,
13091321
Integer transferBufferSize, Boolean wrap) throws Exception, ArrayOfEspExceptionWrapper
@@ -1364,7 +1376,8 @@ public ProgressResponseWrapper sprayFixed(DropZoneWrapper targetDropZone, String
13641376
* @throws org.hpccsystems.ws.client.wrappers.ArrayOfEspExceptionWrapper
13651377
* the array of esp exception wrapper
13661378
*/
1367-
public ProgressResponseWrapper getDfuProgress(String dfuwuid) throws Exception, ArrayOfEspExceptionWrapper
1379+
@WithSpan
1380+
public ProgressResponseWrapper getDfuProgress(@SpanAttribute String dfuwuid) throws Exception, ArrayOfEspExceptionWrapper
13681381
{
13691382
verifyStub();
13701383

@@ -1411,7 +1424,8 @@ public ProgressResponseWrapper getDfuProgress(String dfuwuid) throws Exception,
14111424
* @throws org.hpccsystems.ws.client.wrappers.ArrayOfEspExceptionWrapper
14121425
* the array of esp exception wrapper
14131426
*/
1414-
public boolean uploadFile(File file, String targetDropzoneAddress) throws Exception, ArrayOfEspExceptionWrapper
1427+
@WithSpan
1428+
public boolean uploadFile(@SpanAttribute File file, @SpanAttribute String targetDropzoneAddress) throws Exception, ArrayOfEspExceptionWrapper
14151429
{
14161430
List<DropZoneWrapper> dropZones = fetchDropZones(targetDropzoneAddress);
14171431
if (dropZones == null || dropZones.size() <= 0) throw new Exception("Could not fetch target dropzone information");
@@ -1469,7 +1483,8 @@ static protected void setupUploadResultParser() throws XPathExpressionException,
14691483
* - The target dropzone
14701484
* @return - Boolean, success
14711485
*/
1472-
public boolean uploadLargeFile(File uploadFile, DropZoneWrapper dropZone)
1486+
@WithSpan
1487+
public boolean uploadLargeFile(@SpanAttribute File uploadFile, @SpanAttribute DropZoneWrapper dropZone)
14731488
{
14741489
if (uploadFile == null || dropZone == null)
14751490
{
@@ -1619,7 +1634,8 @@ public boolean uploadLargeFile(File uploadFile, DropZoneWrapper dropZone)
16191634
* @throws Exception
16201635
* the exception
16211636
*/
1622-
private boolean uploadFile(File file, DropZoneWrapper dropZone) throws Exception
1637+
@WithSpan
1638+
private boolean uploadFile(@SpanAttribute File file, @SpanAttribute DropZoneWrapper dropZone) throws Exception
16231639
{
16241640
if (file == null) return false;
16251641
String filename = file.getName();

0 commit comments

Comments
 (0)