Skip to content

Commit

Permalink
feat(api): Remove Strings.join API in favor of JDK String.join
Browse files Browse the repository at this point in the history
  • Loading branch information
PerfectSlayer committed Nov 19, 2024
1 parent ff8ee85 commit 67bc957
Show file tree
Hide file tree
Showing 20 changed files with 26 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ public Path createPackFiles(List<String> objectHashes)
return executeCommand(
Command.PACK_OBJECTS,
() -> {
byte[] input = Strings.join("\n", objectHashes).getBytes(Charset.defaultCharset());
byte[] input = String.join("\n", objectHashes).getBytes(Charset.defaultCharset());

Path tempDirectory = createTempDirectory();
String basename = Strings.random(8);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import datadog.trace.context.TraceScope;
import datadog.trace.util.AgentThreadFactory;
import datadog.trace.util.AgentThreadFactory.AgentThread;
import datadog.trace.util.Strings;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
Expand Down Expand Up @@ -124,7 +123,7 @@ private <T> T executeCommand(
throw new ShellCommandFailedException(
exitValue,
"Command '"
+ Strings.join(" ", command)
+ String.join(" ", command)
+ "' failed with exit code "
+ exitValue
+ ": "
Expand All @@ -147,7 +146,7 @@ private <T> T executeCommand(
terminate(p);
throw new TimeoutException(
"Timeout while waiting for '"
+ Strings.join(" ", command)
+ String.join(" ", command)
+ "'; "
+ IOUtils.readFully(errorStreamConsumer.read(), Charset.defaultCharset()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static datadog.trace.bootstrap.AgentClassLoading.INJECTING_HELPERS;

import datadog.trace.util.Strings;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.security.CodeSource;
Expand Down Expand Up @@ -101,7 +100,7 @@ public DynamicType.Builder<?> transform(
if (classLoader == null) {
throw new UnsupportedOperationException(
"Cannot inject helper classes onto boot-class-path; move "
+ Strings.join(",", helperClassNames)
+ String.join(",", helperClassNames)
+ " to agent-bootstrap");
}

Expand All @@ -112,7 +111,7 @@ public DynamicType.Builder<?> transform(
"Injecting helper classes - instrumentation.class={} instrumentation.target.classloader={} instrumentation.helper_classes=[{}]",
requestingName,
classLoader,
Strings.join(",", helperClassNames));
String.join(",", helperClassNames));
}

final Map<String, byte[]> classnameToBytes = getHelperMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import datadog.trace.api.cache.DDCache;
import datadog.trace.api.cache.DDCaches;
import datadog.trace.util.Strings;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicLongArray;
import org.slf4j.Logger;
Expand Down Expand Up @@ -130,7 +129,7 @@ public static void blockInstrumentation(int instrumentationId) {
public static String describe(int instrumentationId) {
if (instrumentationId >= 0 && instrumentationId < instrumentationNames.length) {
return "instrumentation.names=["
+ Strings.join(",", instrumentationNames[instrumentationId])
+ String.join(",", instrumentationNames[instrumentationId])
+ "] instrumentation.class="
+ instrumentationClasses[instrumentationId];
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import datadog.trace.api.telemetry.ProductChange;
import datadog.trace.api.telemetry.ProductChangeCollector;
import datadog.trace.bootstrap.ActiveSubsystems;
import datadog.trace.util.Strings;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -104,7 +103,7 @@ private static void doStart(SubscriptionService gw, SharedCommunicationObjects s

STARTED.set(true);

String startedAppSecModules = Strings.join(", ", STARTED_MODULES_INFO.values());
String startedAppSecModules = String.join(", ", STARTED_MODULES_INFO.values());
if (appSecEnabledConfig == ProductActivation.FULLY_ENABLED) {
log.info("AppSec is {} with {}", appSecEnabledConfig, startedAppSecModules);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.bootstrap.instrumentation.api.Tags;
import datadog.trace.util.Strings;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse;
Expand Down Expand Up @@ -32,12 +31,12 @@ private void onRequest(final ActionRequest request) {
if (request instanceof IndicesRequest) {
final IndicesRequest req = (IndicesRequest) request;
if (req.indices() != null) {
span.setTag("elasticsearch.request.indices", Strings.join(",", req.indices()));
span.setTag("elasticsearch.request.indices", String.join(",", req.indices()));
}
}
if (request instanceof SearchRequest) {
final SearchRequest req = (SearchRequest) request;
span.setTag("elasticsearch.request.search.types", Strings.join(",", req.types()));
span.setTag("elasticsearch.request.search.types", String.join(",", req.types()));
}
if (request instanceof DocumentRequest) {
final DocumentRequest req = (DocumentRequest) request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.bootstrap.instrumentation.api.Tags;
import datadog.trace.util.Strings;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse;
Expand Down Expand Up @@ -34,12 +33,12 @@ private void onRequest(final ActionRequest request) {
if (request instanceof IndicesRequest) {
final IndicesRequest req = (IndicesRequest) request;
if (req.indices() != null) {
span.setTag("elasticsearch.request.indices", Strings.join(",", req.indices()));
span.setTag("elasticsearch.request.indices", String.join(",", req.indices()));
}
}
if (request instanceof SearchRequest) {
final SearchRequest req = (SearchRequest) request;
span.setTag("elasticsearch.request.search.types", Strings.join(",", req.types()));
span.setTag("elasticsearch.request.search.types", String.join(",", req.types()));
}
if (request instanceof DocWriteRequest) {
final DocWriteRequest req = (DocWriteRequest) request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.bootstrap.instrumentation.api.Tags;
import datadog.trace.util.Strings;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse;
Expand Down Expand Up @@ -37,12 +36,12 @@ private void onRequest(final ActionRequest request) {
if (request instanceof IndicesRequest) {
final IndicesRequest req = (IndicesRequest) request;
if (req.indices() != null) {
span.setTag("elasticsearch.request.indices", Strings.join(",", req.indices()));
span.setTag("elasticsearch.request.indices", String.join(",", req.indices()));
}
}
if (request instanceof SearchRequest) {
final SearchRequest req = (SearchRequest) request;
span.setTag("elasticsearch.request.search.types", Strings.join(",", req.types()));
span.setTag("elasticsearch.request.search.types", String.join(",", req.types()));
}
if (request instanceof DocumentRequest) {
final DocumentRequest req = (DocumentRequest) request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static datadog.trace.instrumentation.elasticsearch.ElasticsearchTransportClientDecorator.DECORATE;

import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.util.Strings;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse;
Expand Down Expand Up @@ -37,12 +36,12 @@ private void onRequest(final ActionRequest request) {
if (request instanceof IndicesRequest) {
final IndicesRequest req = (IndicesRequest) request;
if (req.indices() != null) {
span.setTag("elasticsearch.request.indices", Strings.join(",", req.indices()));
span.setTag("elasticsearch.request.indices", String.join(",", req.indices()));
}
}
if (request instanceof SearchRequest) {
final SearchRequest req = (SearchRequest) request;
span.setTag("elasticsearch.request.search.types", Strings.join(",", req.types()));
span.setTag("elasticsearch.request.search.types", String.join(",", req.types()));
}
if (request instanceof DocWriteRequest) {
final DocWriteRequest req = (DocWriteRequest) request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static datadog.trace.instrumentation.elasticsearch.ElasticsearchTransportClientDecorator.DECORATE;

import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.util.Strings;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse;
Expand Down Expand Up @@ -34,12 +33,12 @@ private void onRequest(final ActionRequest request) {
if (request instanceof IndicesRequest) {
final IndicesRequest req = (IndicesRequest) request;
if (req.indices() != null) {
span.setTag("elasticsearch.request.indices", Strings.join(",", req.indices()));
span.setTag("elasticsearch.request.indices", String.join(",", req.indices()));
}
}
if (request instanceof SearchRequest) {
final SearchRequest req = (SearchRequest) request;
span.setTag("elasticsearch.request.search.types", Strings.join(",", req.types()));
span.setTag("elasticsearch.request.search.types", String.join(",", req.types()));
}
if (request instanceof DocWriteRequest) {
final DocWriteRequest req = (DocWriteRequest) request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import datadog.trace.bootstrap.instrumentation.api.InternalSpanTypes;
import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString;
import datadog.trace.bootstrap.instrumentation.decorator.ClientDecorator;
import datadog.trace.util.Strings;
import java.util.function.Function;

/** Decorate Hazelcast distributed object span's with relevant contextual information. */
Expand Down Expand Up @@ -84,7 +83,7 @@ public AgentSpan onServiceExecution(
QUALIFIED_NAME_CACHE.computeIfAbsent(
Pair.of(object.getServiceName(), object.getName()), COMPUTE_QUALIFIED_NAME);

span.setResourceName(UTF8BytesString.create(Strings.join(".", objectName, methodName)));
span.setResourceName(UTF8BytesString.create(String.join(".", objectName, methodName)));

span.setTag(HAZELCAST_SERVICE, object.getServiceName());
span.setTag(HAZELCAST_OPERATION, methodName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import datadog.trace.bootstrap.instrumentation.api.InternalSpanTypes;
import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString;
import datadog.trace.bootstrap.instrumentation.decorator.ClientDecorator;
import datadog.trace.util.Strings;

/** Decorate Hazelcast client invocations with relevant contextual information. */
public class ClientInvocationDecorator extends ClientDecorator {
Expand Down Expand Up @@ -51,7 +50,7 @@ public AgentSpan onServiceExecution(
long correlationId) {

if (objectName != null) {
span.setResourceName(UTF8BytesString.create(Strings.join(" ", operationName, objectName)));
span.setResourceName(UTF8BytesString.create(String.join(" ", operationName, objectName)));
span.setTag(HAZELCAST_NAME, objectName);
} else {
span.setResourceName(UTF8BytesString.create(operationName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import datadog.trace.bootstrap.instrumentation.api.InternalSpanTypes;
import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString;
import datadog.trace.bootstrap.instrumentation.decorator.ClientDecorator;
import datadog.trace.util.Strings;

/** Decorate Hazelcast distributed object span's with relevant contextual information. */
public class HazelcastDecorator extends ClientDecorator {
Expand Down Expand Up @@ -51,7 +50,7 @@ public AgentSpan onServiceExecution(

if (objectName != null) {
span.setResourceName(
UTF8BytesString.create(Strings.join(" ", operationName, objectName.toString())));
UTF8BytesString.create(String.join(" ", operationName, objectName.toString())));
span.setTag(HAZELCAST_NAME, objectName.toString());
} else {
span.setResourceName(UTF8BytesString.create(operationName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static datadog.trace.instrumentation.opensearch.OpensearchTransportClientDecorator.DECORATE;

import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.util.Strings;
import org.opensearch.action.ActionListener;
import org.opensearch.action.ActionRequest;
import org.opensearch.action.ActionResponse;
Expand Down Expand Up @@ -32,7 +31,7 @@ private void onRequest(final ActionRequest request) {
if (request instanceof IndicesRequest) {
final IndicesRequest req = (IndicesRequest) request;
if (req.indices() != null) {
span.setTag("opensearch.request.indices", Strings.join(",", req.indices()));
span.setTag("opensearch.request.indices", String.join(",", req.indices()));
}
}
if (request instanceof DocWriteRequest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
import datadog.trace.util.Strings;
import java.util.ArrayList;
import java.util.List;
import net.bytebuddy.asm.Advice;
Expand Down Expand Up @@ -100,7 +99,7 @@ public static AgentScope onEnter(
for (CommandData<?, ?> commandData : command.getCommands()) {
commandResourceNames.add(commandData.getCommand().getName());
}
DECORATE.onStatement(span, Strings.join(";", commandResourceNames));
DECORATE.onStatement(span, String.join(";", commandResourceNames));
command.getPromise().addListener(new SpanFinishListener(AgentTracer.captureSpan(span)));
return activateSpan(span);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
import datadog.trace.util.Strings;
import java.util.ArrayList;
import java.util.List;
import net.bytebuddy.asm.Advice;
Expand Down Expand Up @@ -101,7 +100,7 @@ public static AgentScope onEnter(
for (CommandData<?, ?> commandData : command.getCommands()) {
commandResourceNames.add(commandData.getCommand().getName());
}
RedissonClientDecorator.DECORATE.onStatement(span, Strings.join(";", commandResourceNames));
RedissonClientDecorator.DECORATE.onStatement(span, String.join(";", commandResourceNames));
((RFuture<?>) command.getPromise())
.addListener(new SpanFinishListener(AgentTracer.captureSpan(span)));
return activateSpan(span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
import datadog.trace.util.Strings;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletionStage;
Expand Down Expand Up @@ -111,7 +110,7 @@ public static AgentScope onEnter(
for (CommandData<?, ?> commandData : command.getCommands()) {
commandResourceNames.add(commandData.getCommand().getName());
}
RedissonClientDecorator.DECORATE.onStatement(span, Strings.join(";", commandResourceNames));
RedissonClientDecorator.DECORATE.onStatement(span, String.join(";", commandResourceNames));
promise.whenComplete(new SpanFinishListener(AgentTracer.captureSpan(span)));
return activateSpan(span);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import datadog.trace.logging.LogLevel;
import datadog.trace.util.AgentTaskScheduler;
import datadog.trace.util.AgentTaskScheduler.Scheduled;
import datadog.trace.util.Strings;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.management.ManagementFactory;
Expand Down Expand Up @@ -239,8 +238,7 @@ private void addConfig(ZipOutputStream zip) throws IOException {
private void addRuntime(ZipOutputStream zip) throws IOException {
try {
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
TracerFlare.addText(
zip, "jvm_args.txt", Strings.join(" ", runtimeMXBean.getInputArguments()));
TracerFlare.addText(zip, "jvm_args.txt", String.join(" ", runtimeMXBean.getInputArguments()));
TracerFlare.addText(zip, "classpath.txt", runtimeMXBean.getClassPath());
TracerFlare.addText(zip, "library_path.txt", runtimeMXBean.getLibraryPath());
if (runtimeMXBean.isBootClassPathSupported()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import datadog.trace.api.naming.NamingSchema;
import datadog.trace.api.naming.SpanNaming;
import datadog.trace.util.Strings;
import java.util.Locale;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -34,7 +33,7 @@ public String operationForRequest(
return SpanNaming.instance().namingSchema().messaging().outboundOperation("sns");
default:
final String lowercaseService = cloudService.toLowerCase(Locale.ROOT);
return Strings.join(".", provider, lowercaseService, "request"); // aws.s3.request
return String.join(".", provider, lowercaseService, "request"); // aws.s3.request
}
}

Expand Down
Loading

0 comments on commit 67bc957

Please sign in to comment.