Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/candidate-9.6.x' into candidate-…
Browse files Browse the repository at this point in the history
…9.8.x

Signed-off-by: Jake Smith <[email protected]>
  • Loading branch information
jakesmith committed Sep 13, 2024
2 parents 46453d6 + 431f906 commit c3ab1f8
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class DFSReadWriteTest extends BaseRemoteTest
{
// private static final String[] datasets = { "~benchmark::integer::20kb", "~unit_test::all_types::thor", "~unit_test::all_types::xml", "~unit_test::all_types::json", "~unit_test::all_types::csv" };
private static final String[] datasets = { "~unit_test::all_types::xml", "~unit_test::all_types::json", "~unit_test::all_types::csv" };
private static final int[] expectedCounts = { 1250, 100000, 100000, 100000, 100000, 100000};
// Note: These datasets are generated by dfsclient/src/target/resources/generate-datasets.ecl
private static final String[] datasets = { "~benchmark::integer::20kb", "~unit_test::all_types::thor", "~unit_test::all_types::json", "~unit_test::all_types::csv" };
private static final int[] expectedCounts = { 1250, 100000, 100000, 100000};

private static final Version newProtocolVersion = new Version(8,12,10);

Expand Down
75 changes: 75 additions & 0 deletions wsclient/src/main/java/org/hpccsystems/ws/client/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.StringWriter;
import java.lang.management.ManagementFactory;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
Expand Down Expand Up @@ -1261,4 +1262,78 @@ static public String getTraceParentHeader(Span span)

return traceparent;
}

/**
* Checks if a specified VM argument is present.
*
* This method retrieves the list of VM arguments and searches for the specified argument name.
* If the argument is found, it returns true. If the argument is not found, it returns false.
*
* @param vmArgName the name of the VM argument to search for
* @return {@code true} if the specified VM argument is present, {@code false} otherwise
*/
static public boolean containsVMArgument(String vmArgName)
{
List<String> argslist = ManagementFactory.getRuntimeMXBean().getInputArguments();
for (String string : argslist)
{
if(string.matches("(?i)(" + vmArgName + "):.*"))
{
return true;
}
}
return false;
}

/**
* Fetches the value of a specified VM argument.
*
* This method retrieves the list of VM arguments and searches for the specified argument name.
* If the argument is found, it returns the value associated with it. If the argument is not found,
* it returns an empty string.
*
* @param vmArgName the name of the VM argument to search for
* @return the value of the specified VM argument, or an empty string if the argument is not found
*/
static public String fetchVMArgument(String vmArgName)
{
List<String> argslist = ManagementFactory.getRuntimeMXBean().getInputArguments();
for (String string : argslist)
{
if(string.matches("(?i)(" + vmArgName + "):.*"))
{
String[] keyval = string.split(vmArgName+":");

return keyval[1];
}
}
return "";
}

/**
* Checks if the OpenTelemetry Java agent is used by inspecting the VM arguments.
*
* This method fetches the VM argument specified by "-javaagent" and checks if it contains
* the term "opentelemetry". If the argument is found and contains "opentelemetry", it returns true.
* Otherwise, it returns false.
*
* @return {@code true} if the OpenTelemetry Java agent is detected, {@code false} otherwise.
*/
static public boolean isOtelJavaagentUsed()
{
String javaAgentPath = fetchVMArgument("-javaagent");
if (!javaAgentPath.isEmpty())
{
System.out.println("javaagent VM argument detected: " + javaAgentPath);

File jaFile = new File(javaAgentPath);

if (jaFile.getName().contains("opentelemetry") || jaFile.getName().contains("otel"))
{
System.out.println("Otel javaagent argument detected: " + javaAgentPath);
return true;
}
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ HPCC SYSTEMS software Copyright (C) 2019 HPCC Systems®.
import org.hpccsystems.ws.client.HPCCWsTopologyClient.TopologyGroupQueryKind;
import org.hpccsystems.ws.client.platform.Platform;
import org.hpccsystems.ws.client.utils.Connection;
import org.hpccsystems.ws.client.utils.Utils;
import org.hpccsystems.ws.client.wrappers.gen.wstopology.TpGroupWrapper;
import org.hpccsystems.ws.client.wrappers.wsworkunits.WorkunitWrapper;
import org.junit.Assert;
Expand Down Expand Up @@ -135,9 +136,13 @@ public static void initialize() throws Exception
System.out.println(" otel.metrics.exporter: "+ System.getProperty("otel.metrics.exporter"));
System.out.println(" OTEL_METRICS_EXPORTER Env var: " + System.getenv("OTEL_METRICS_EXPORTER"));

globalOTel = AutoConfiguredOpenTelemetrySdk.initialize().getOpenTelemetrySdk();
if (!Utils.isOtelJavaagentUsed())
{
globalOTel = AutoConfiguredOpenTelemetrySdk.initialize().getOpenTelemetrySdk();
}
}
else

if (globalOTel == null)
{
globalOTel = GlobalOpenTelemetry.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,21 +190,23 @@ else if (currentParam.matches(WSSQLPORTPATTERN))
System.out.println("If missing dependancies arise, test will halt!");
System.out.println(" otel.traces.exporter sys property: "+System.getProperty("otel.traces.exporter"));
System.out.println(" OTEL_TRACES_EXPORTER Env var: " + System.getenv("OTEL_TRACES_EXPORTER"));
System.out.println(" OTEL_TRACES_SAMPLER Env var: " + System.getenv("OTEL_TRACES_SAMPLER"));
System.out.println(" otel.traces.sampler sys property: "+System.getProperty("otel.traces.sampler"));
System.out.println(" OTEL_TRACES_SAMPLER Env var: " + System.getenv("OTEL_TRACES_SAMPLER"));
System.out.println(" otel.traces.sampler sys property: "+System.getProperty("otel.traces.sampler"));
System.out.println(" otel.logs.exporter: "+ System.getProperty("otel.logs.exporter"));
System.out.println(" OTEL_LOGS_EXPORTER Env var: " + System.getenv("OTEL_LOGS_EXPORTER"));
System.out.println(" otel.metrics.exporter: "+ System.getProperty("otel.metrics.exporter"));
System.out.println(" OTEL_METRICS_EXPORTER Env var: " + System.getenv("OTEL_METRICS_EXPORTER"));

globalOTel = AutoConfiguredOpenTelemetrySdk.initialize().getOpenTelemetrySdk();
if (!Utils.isOtelJavaagentUsed())
{
globalOTel = AutoConfiguredOpenTelemetrySdk.initialize().getOpenTelemetrySdk();
}
}
else
{

if (globalOTel == null)
globalOTel = GlobalOpenTelemetry.get();
}

Span rootSpan = globalOTel.getTracer("PlatformTester").spanBuilder("rootspan").startSpan();
Span rootSpan = globalOTel.getTracer("PlatformTester").spanBuilder("PlatformTest").startSpan();
try (Scope scope = rootSpan.makeCurrent())
{
Platform platform = Platform.get(prot, hpccServer, port, user, pass);
Expand Down

0 comments on commit c3ab1f8

Please sign in to comment.