Skip to content

Commit aa39e08

Browse files
committed
pass multipart usage as constructor param
1 parent f2dc394 commit aa39e08

8 files changed

Lines changed: 24 additions & 27 deletions

File tree

‎dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/agent/ConfigurationUpdater.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ DebuggerTransformer supply(
6969
instrumentation,
7070
transformerSupplier,
7171
config,
72-
new DebuggerSink(config, config.getFinalDebuggerSnapshotUrl()),
72+
new DebuggerSink(config, config.getFinalDebuggerSnapshotUrl(), false),
7373
finder);
7474
}
7575

‎dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/agent/DebuggerAgent.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ public static synchronized void run(
5151
ddAgentFeaturesDiscovery.discoverIfOutdated();
5252
agentVersion = ddAgentFeaturesDiscovery.getVersion();
5353
String diagnosticEndpoint = getDiagnosticEndpoint(config, ddAgentFeaturesDiscovery);
54-
DebuggerSink debuggerSink = new DebuggerSink(config, diagnosticEndpoint);
54+
DebuggerSink debuggerSink =
55+
new DebuggerSink(
56+
config, diagnosticEndpoint, ddAgentFeaturesDiscovery.supportsDebuggerDiagnostics());
5557
debuggerSink.start();
5658
ConfigurationUpdater configurationUpdater =
5759
new ConfigurationUpdater(

‎dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/agent/DebuggerTransformer.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public DebuggerTransformer(
107107
config,
108108
configuration,
109109
null,
110-
new DebuggerSink(config, config.getFinalDebuggerSnapshotUrl()));
110+
new DebuggerSink(config, config.getFinalDebuggerSnapshotUrl(), false));
111111
}
112112

113113
private void readExcludeFiles(String commaSeparatedFileNames) {

‎dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/sink/DebuggerSink.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ public class DebuggerSink {
4040
private volatile AgentTaskScheduler.Scheduled<DebuggerSink> flushIntervalScheduled;
4141
private volatile long currentFlushInterval = INITIAL_FLUSH_INTERVAL;
4242

43-
public DebuggerSink(Config config, String diagnosticsEndpoint) {
43+
public DebuggerSink(Config config, String diagnosticsEndpoint, boolean useMultiPart) {
4444
this(
4545
config,
4646
new BatchUploader(config, config.getFinalDebuggerSnapshotUrl()),
4747
DebuggerMetrics.getInstance(config),
48-
new ProbeStatusSink(config, diagnosticsEndpoint),
48+
new ProbeStatusSink(config, diagnosticsEndpoint, useMultiPart),
4949
new SnapshotSink(config),
5050
new SymbolSink(config));
5151
}
@@ -56,7 +56,7 @@ public DebuggerSink(Config config, String diagnosticsEndpoint) {
5656
config,
5757
snapshotUploader,
5858
DebuggerMetrics.getInstance(config),
59-
new ProbeStatusSink(config, config.getFinalDebuggerSnapshotUrl()),
59+
new ProbeStatusSink(config, config.getFinalDebuggerSnapshotUrl(), false),
6060
new SnapshotSink(config),
6161
new SymbolSink(config));
6262
}
@@ -76,7 +76,7 @@ public DebuggerSink(Config config, ProbeStatusSink probeStatusSink) {
7676
config,
7777
snapshotUploader,
7878
debuggerMetrics,
79-
new ProbeStatusSink(config, config.getFinalDebuggerSnapshotUrl()),
79+
new ProbeStatusSink(config, config.getFinalDebuggerSnapshotUrl(), false),
8080
new SnapshotSink(config),
8181
new SymbolSink(config));
8282
}

‎dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/sink/ProbeStatusSink.java‎

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import com.datadog.debugger.util.ExceptionHelper;
88
import com.datadog.debugger.util.MoshiHelper;
99
import com.squareup.moshi.JsonAdapter;
10-
import datadog.communication.ddagent.DDAgentFeaturesDiscovery;
1110
import datadog.trace.api.Config;
1211
import datadog.trace.bootstrap.debugger.ProbeId;
1312
import java.time.Clock;
@@ -35,30 +34,22 @@ public class ProbeStatusSink {
3534
private final Duration interval;
3635
private final int batchSize;
3736
private final boolean isInstrumentTheWorld;
38-
private final boolean useDebuggerTrack;
37+
private final boolean useMultiPart;
3938

40-
ProbeStatusSink(Config config, String diagnosticsEndpoint) {
41-
this(
42-
config,
43-
new BatchUploader(config, diagnosticsEndpoint),
44-
isUsingDebuggerTrack(diagnosticsEndpoint));
39+
ProbeStatusSink(Config config, String diagnosticsEndpoint, boolean useMultiPart) {
40+
this(config, new BatchUploader(config, diagnosticsEndpoint), useMultiPart);
4541
}
4642

47-
ProbeStatusSink(Config config, BatchUploader diagnosticUploader, boolean useDebuggerTrack) {
43+
ProbeStatusSink(Config config, BatchUploader diagnosticUploader, boolean useMultiPart) {
4844
this.diagnosticUploader = diagnosticUploader;
49-
this.useDebuggerTrack = useDebuggerTrack;
45+
this.useMultiPart = useMultiPart;
5046
this.messageBuilder = new Builder(config);
5147
this.interval = Duration.ofSeconds(config.getDebuggerDiagnosticsInterval());
5248
this.batchSize = config.getDebuggerUploadBatchSize();
5349
this.queue = new ArrayBlockingQueue<>(2 * this.batchSize);
5450
this.isInstrumentTheWorld = config.isDebuggerInstrumentTheWorld();
5551
}
5652

57-
private static boolean isUsingDebuggerTrack(String endpoint) {
58-
return endpoint != null
59-
&& endpoint.contains(DDAgentFeaturesDiscovery.DEBUGGER_DIAGNOSTICS_ENDPOINT);
60-
}
61-
6253
public void addReceived(ProbeId probeId) {
6354
addDiagnostics(messageBuilder.receivedMessage(probeId));
6455
}
@@ -83,9 +74,9 @@ public void flush(String tags) {
8374
List<String> serializedDiagnostics = getSerializedDiagnostics();
8475
List<byte[]> batches = IntakeBatchHelper.createBatches(serializedDiagnostics);
8576
for (byte[] batch : batches) {
86-
if (useDebuggerTrack) {
77+
if (useMultiPart) {
8778
diagnosticUploader.uploadAsMultipart(
88-
"", new BatchUploader.MultiPartContent(batch, "event", "event.json"));
79+
tags, new BatchUploader.MultiPartContent(batch, "event", "event.json"));
8980
} else {
9081
diagnosticUploader.upload(batch, tags);
9182
}

‎dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/agent/CapturedSnapshotTest.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.datadog.debugger.instrumentation.InstrumentationResult;
3131
import com.datadog.debugger.probe.LogProbe;
3232
import com.datadog.debugger.probe.ProbeDefinition;
33+
import com.datadog.debugger.sink.DebuggerSink;
3334
import com.datadog.debugger.sink.ProbeStatusSink;
3435
import com.datadog.debugger.sink.Snapshot;
3536
import com.datadog.debugger.util.MoshiHelper;
@@ -1979,7 +1980,10 @@ private DebuggerTransformerTest.TestSnapshotListener setupInstrumentTheWorldTran
19791980
DebuggerAgentHelper.injectSink(listener);
19801981
currentTransformer =
19811982
DebuggerAgent.setupInstrumentTheWorldTransformer(
1982-
config, instr, new DebuggerSink(config, config.getFinalDebuggerSnapshotUrl()), null);
1983+
config,
1984+
instr,
1985+
new DebuggerSink(config, config.getFinalDebuggerSnapshotUrl(), false),
1986+
null);
19831987
DebuggerContext.initClassFilter(new DenyListHelper(null));
19841988
return listener;
19851989
}

‎dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/agent/DebuggerTransformerTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public void testBlockedProbes() {
262262
config,
263263
configuration,
264264
((definition, result) -> lastResult.set(result)),
265-
new DebuggerSink(config, config.getFinalDebuggerSnapshotUrl()));
265+
new DebuggerSink(config, config.getFinalDebuggerSnapshotUrl(), false));
266266
byte[] newClassBuffer =
267267
debuggerTransformer.transform(
268268
ClassLoader.getSystemClassLoader(),
@@ -289,7 +289,7 @@ public void classBeingRedefinedNull() {
289289
config,
290290
configuration,
291291
((definition, result) -> lastResult.set(result)),
292-
new DebuggerSink(config, config.getFinalDebuggerSnapshotUrl()));
292+
new DebuggerSink(config, config.getFinalDebuggerSnapshotUrl(), false));
293293
byte[] newClassBuffer =
294294
debuggerTransformer.transform(
295295
ClassLoader.getSystemClassLoader(),

‎dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/sink/ProbeStatusSinkTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void setUp() {
5050
when(config.getDebuggerDiagnosticsInterval()).thenReturn(DIAGNOSTICS_INTERVAL);
5151
when(config.getDebuggerUploadBatchSize()).thenReturn(100);
5252
builder = new Builder(config);
53-
probeStatusSink = new ProbeStatusSink(config, "http://localhost:8126/debugger/v1/input");
53+
probeStatusSink = new ProbeStatusSink(config, "http://localhost:8126/debugger/v1/input", true);
5454
}
5555

5656
@Test

0 commit comments

Comments
 (0)