Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dd-java-agent/agent-debugger/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ dependencies {
implementation libs.dogstatsd
implementation libs.moshi

// Antithesis SDK for assertions and property testing - bundled in tracer JAR
implementation group: 'com.antithesis', name: 'sdk', version: '1.4.5'

testImplementation libs.asm.util
testImplementation libs.bundles.junit5
testImplementation libs.junit.jupiter.params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.antithesis.sdk.Assert;

/**
* Handles configuration updates if required by installing a new ClassFileTransformer and triggering
Expand Down Expand Up @@ -95,6 +96,8 @@ public void accept(Source source, Collection<? extends ProbeDefinition> definiti
applyNewConfiguration(newConfiguration);
} catch (RuntimeException e) {
ExceptionHelper.logException(LOGGER, e, "Error during accepting new debugger configuration:");
LOGGER.debug("ANTITHESIS_ASSERT: ConfigurationUpdater.accept should sometimes throw a runtime exception (sometimes)");
Assert.sometimes(true, "ConfigurationUpdater.accept should sometimes throw a runtime exception", null);
throw e;
}
}
Expand Down Expand Up @@ -143,9 +146,15 @@ private void applyNewConfiguration(Configuration newConfiguration) {
currentConfiguration = newConfiguration;
if (changes.hasProbeRelatedChanges()) {
LOGGER.debug("Applying new probe configuration, changes: {}", changes);
LOGGER.debug("ANTITHESIS_ASSERT: ConfigurationUpdater.handleProbesChanges should sometimes be called (sometimes)");
Assert.sometimes(true, "ConfigurationUpdater.handleProbesChanges should sometimes be called", null);
handleProbesChanges(changes, newConfiguration);
}
LOGGER.debug("ANTITHESIS_ASSERT: ConfigurationUpdater.applyNewConfiguration should always be successful (always)");
Assert.always(true, "ConfigurationUpdater.applyNewConfiguration should always be successful", null);
} finally {
LOGGER.debug("ANTITHESIS_ASSERT: ConfigurationUpdater.applyNewConfiguration should always be reachable (reachable)");
Assert.reachable("ConfigurationUpdater.applyNewConfiguration should always be reachable", null);
configurationLock.unlock();
}
}
Expand Down
3 changes: 3 additions & 0 deletions dd-java-agent/agent-profiling/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ dependencies {
api libs.slf4j
api project(':internal-api')

// Antithesis SDK for assertions and property testing - bundled in tracer JAR
implementation group: 'com.antithesis', name: 'sdk', version: '1.4.5'

api project(':dd-java-agent:agent-profiling:profiling-ddprof')
api project(':dd-java-agent:agent-profiling:profiling-uploader')
api project(':dd-java-agent:agent-profiling:profiling-controller')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ dependencies {
api project(':dd-java-agent:agent-profiling:profiling-controller')
api project(':dd-java-agent:agent-profiling:profiling-controller-jfr')

// Antithesis SDK for assertions and property testing - bundled in tracer JAR
implementation group: 'com.antithesis', name: 'sdk', version: '1.4.5'

testImplementation libs.bundles.junit5
testImplementation libs.bundles.mockito
testImplementation files(project(':dd-java-agent:agent-profiling:profiling-controller-jfr').sourceSets.test.output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.antithesis.sdk.Assert;

/**
* This is the implementation of the controller for OpenJDK. It should work for JDK 11+ today, and
Expand Down Expand Up @@ -289,6 +290,8 @@ private static String getJfrRepositoryBase(ConfigProvider configProvider) {
Files.createDirectories(repositoryPath);
} catch (IOException e) {
log.error("Failed to create JFR repository directory: {}", repositoryPath, e);
log.debug("ANTITHESIS_ASSERT: Failed to create JFR repository directory (unreachable)");
Assert.unreachable("Failed to create JFR repository directory", null);
throw new IllegalStateException(
"Failed to create JFR repository directory: " + repositoryPath, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ dependencies {
api project(':components:environment')
api project(':dd-java-agent:agent-profiling:profiling-utils')

// Antithesis SDK for assertions and property testing - bundled in tracer JAR
implementation group: 'com.antithesis', name: 'sdk', version: '1.4.5'

testImplementation libs.bundles.junit5
testImplementation libs.guava
testImplementation libs.bundles.mockito
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.antithesis.sdk.Assert;

/** Sets up the profiling strategy and schedules the profiling recordings. */
public final class ProfilingSystem {
Expand Down Expand Up @@ -196,9 +197,12 @@ private void startProfilingRecording() {
if (t != null) {
if (t instanceof IllegalStateException && "Shutdown in progress".equals(t.getMessage())) {
ProfilerFlareLogger.getInstance().log("Shutdown in progress, cannot start profiling");
log.debug("ANTITHESIS_ASSERT: Shutdown in progress, cannot start profiling (sometimes)");
Assert.sometimes(true, "Shutdown in progress, cannot start profiling", null);
} else {
ProfilerFlareLogger.getInstance().log("Failed to start profiling", t);

log.debug("ANTITHESIS_ASSERT: Failed to start profiling (unreachable)", t);
Assert.unreachable("Failed to start profiling", null);
throw t instanceof RuntimeException ? (RuntimeException) t : new RuntimeException(t);
}
}
Expand Down Expand Up @@ -275,13 +279,17 @@ public void snapshot(boolean onShutdown) {
// the last recording end time plus one nano second. The reason for this is that when
// JFR is filtering the stream it will only discard earlier chunks that have an end
// time that is before (not before or equal to) the requested start time of the filter.
log.debug("ANTITHESIS_ASSERT: Snapshot created (always) - lastSnapshot != null: {}", (lastSnapshot != null));
Assert.always(lastSnapshot != null, "Snapshot created", null);
lastSnapshot = recordingData.getEnd().plus(ONE_NANO);
dataListener.onNewData(recordingType, recordingData, onShutdown);
} else {
lastSnapshot = Instant.now();
}
} catch (final Exception e) {
log.error(SEND_TELEMETRY, "Exception in profiling thread, continuing", e);
log.debug("ANTITHESIS_ASSERT: Exception in profiling thread, continuing (unreachable)", e);
Assert.unreachable("Exception in profiling thread, continuing", null);
} catch (final Throwable t) {
/*
Try to continue even after fatal exception. It seems to be useful to attempt to store profile when this happens.
Expand All @@ -294,6 +302,8 @@ public void snapshot(boolean onShutdown) {
} catch (final Throwable t2) {
// This should almost never happen and there is not much we can do here in cases like
// OutOfMemoryError, so we will just ignore this.
log.debug("ANTITHESIS_ASSERT: Fatal exception in profiling thread, trying to continue (unreachable)");
Assert.unreachable("Fatal exception in profiling thread, trying to continue", null);
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions dd-java-agent/agent-profiling/profiling-ddprof/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ dependencies {

implementation libs.slf4j

// Antithesis SDK for assertions and property testing - bundled in tracer JAR
implementation group: 'com.antithesis', name: 'sdk', version: '1.4.5'

testImplementation libs.bundles.jmc
testImplementation libs.bundles.junit5
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.antithesis.sdk.Assert;
/**
* It is currently assumed that this class can be initialised early so that Datadog profiler's
* thread filter captures all tracing activity, which means it must not be modified to depend on
Expand Down Expand Up @@ -189,6 +189,8 @@ public OngoingRecording start() {
return new DatadogProfilerRecording(this);
} catch (IOException | IllegalStateException e) {
log.debug("Failed to start Datadog profiler recording", e);
log.debug("ANTITHESIS_ASSERT: Failed to start Datadog profiler recording (unreachable)");
Assert.unreachable("Failed to start Datadog profiler recording", null);
return null;
}
}
Expand All @@ -203,12 +205,16 @@ public RecordingData stop(OngoingRecording recording) {
void stopProfiler() {
if (recordingFlag.compareAndSet(true, false)) {
profiler.stop();
log.debug("ANTITHESIS_ASSERT: Checking if profiling is still active after stop (sometimes) - active: {}", isActive());
Assert.sometimes(isActive(),"Profiling is still active. Waiting to stop.", null);
if (isActive()) {
log.debug("Profiling is still active. Waiting to stop.");
while (isActive()) {
LockSupport.parkNanos(10_000_000L);
}
}
log.debug("ANTITHESIS_ASSERT: Profiling should be stopped (always) - active: {}", isActive());
Assert.always(!isActive(),"Profiling is stopped", null);
}
}

Expand All @@ -222,6 +228,8 @@ public boolean isActive() {
log.debug("Datadog Profiler Status = {}", status);
return !status.contains("not active");
} catch (IOException ignored) {
log.debug("ANTITHESIS_ASSERT: Failed to get Datadog profiler status (unreachable)");
Assert.unreachable("Failed to get Datadog profiler status", null);
}
return false;
}
Expand All @@ -244,10 +252,14 @@ Path newRecording() throws IOException, IllegalStateException {
log.warn("Unable to start Datadog profiler recording: {}", e.getMessage());
}
recordingFlag.set(false);
log.debug("ANTITHESIS_ASSERT: Unable to start Datadog profiler recording (unreachable)");
Assert.unreachable("Unable to start Datadog profiler recording", null);
throw e;
}
return recFile;
}
log.debug("ANTITHESIS_ASSERT: Datadog profiler session has already been started (unreachable)");
Assert.unreachable("Datadog profiler session has already been started", null);
throw new IllegalStateException("Datadog profiler session has already been started");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ dependencies {
implementation libs.lz4
implementation libs.aircompressor

// Antithesis SDK for assertions and property testing - bundled in tracer JAR
implementation group: 'com.antithesis', name: 'sdk', version: '1.4.5'

testImplementation project(':dd-java-agent:agent-profiling:profiling-testing')
testImplementation project(':utils:test-utils')
testImplementation libs.bundles.junit5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import okhttp3.ResponseBody;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.antithesis.sdk.Assert;

/** The class for uploading profiles to the backend. */
public final class ProfileUploader {
Expand Down Expand Up @@ -301,6 +302,8 @@ public void onFailure(final Call call, final IOException e) {
// But, in any case, we have this safety-break in place to prevent blocking finishing the
// sync request to a misbehaving server.
if (handled.compareAndSet(false, true)) {
log.debug("ANTITHESIS_ASSERT: Upload timeout (unreachable)");
Assert.unreachable("Upload timeout", null);
handleFailure(call, null, data, onCompletion);
}
}
Expand Down Expand Up @@ -351,6 +354,8 @@ private void handleResponse(
"Failed to upload profile, it's too big. Dumping information about the profile");
JfrCliHelper.invokeOn(data, ioLogger);
} else {
log.debug("ANTITHESIS_ASSERT: Failed to upload profile (unreachable) - response code: {}", response.code());
Assert.unreachable("Failed to upload profile", null);
ioLogger.error("Failed to upload profile", getLoggerResponse(response));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.antithesis.sdk.Assert;

/** Profiling agent implementation */
public class ProfilingAgent {
Expand Down Expand Up @@ -81,6 +82,8 @@ public void onNewData(RecordingType type, RecordingData data, boolean handleSync
log.debug("Debug profile stored as {}", tmp);
} catch (IOException e) {
log.debug("Unable to write debug profile dump", e);
log.debug("ANTITHESIS_ASSERT: Unable to write debug profile dump (unreachable)");
Assert.unreachable("Unable to write debug profile dump", null);
}
}
}
Expand Down Expand Up @@ -169,11 +172,15 @@ public static synchronized boolean run(final boolean earlyStart, Instrumentation
This means that if/when we implement functionality to manually shutdown profiler we would
need to not forget to add code that removes this shutdown hook from JVM.
*/
log.debug("ANTITHESIS_ASSERT: Shutdown hook added (always) - uploader != null: {}", (uploader != null));
Assert.always(uploader!= null, "Shutdown hook added", null);
Runtime.getRuntime().addShutdownHook(new ShutdownHook(profiler, uploader));
} catch (final IllegalStateException ex) {
// The JVM is already shutting down.
}
} catch (final UnsupportedEnvironmentException | ConfigurationException e) {
log.debug("ANTITHESIS_ASSERT: Failed to initialize profiling agent (unreachable)", e);
Assert.unreachable("Failed to initialize profiling agent!", null);
ProfilerFlareLogger.getInstance().log("Failed to initialize profiling agent!", e);
ProfilerFlareReporter.reportInitializationException(e);
}
Expand Down
3 changes: 3 additions & 0 deletions dd-trace-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ dependencies {

implementation group: 'com.google.re2j', name: 're2j', version: '1.7'

// Antithesis SDK for assertions and property testing - bundled in tracer JAR
implementation group: 'com.antithesis', name: 'sdk', version: '1.4.5'

compileOnly group: 'com.github.spotbugs', name: 'spotbugs-annotations', version: '4.2.0'

// We have autoservices defined in test subtree, looks like we need this to be able to properly rebuild this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public void accept(int messageCount, ByteBuffer buffer) {
healthMetrics.onSerialize(sizeInBytes);
RemoteApi.Response response = api.sendSerializedTraces(payload);
mapper.reset();

if (response.success()) {
if (log.isDebugEnabled()) {
log.debug("Successfully sent {} traces to the API", messageCount);
Expand Down
3 changes: 3 additions & 0 deletions remote-config/remote-config-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ dependencies {
implementation(libs.moshi)
implementation(libs.bundles.cafe.crypto)

// Antithesis SDK for assertions and property testing - bundled in tracer JAR
implementation(group = "com.antithesis", name = "sdk", version = "1.4.5")

implementation(project(":internal-api"))

testImplementation(project(":utils:test-utils"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import okio.ByteString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.antithesis.sdk.Assert;

/** Handles polling debugger configuration from datadog agent/Remote Configuration */
public class DefaultConfigurationPoller
Expand Down Expand Up @@ -281,8 +282,10 @@ private boolean initialize() {
new PollerRequestFactory(config, tracerVersion, containerId, entityId, url, moshi);
} catch (Exception e) {
// We can't recover from this, so we'll not try to initialize again.
fatalOnInitialization = true;
log.error("Remote configuration poller initialization failed", e);
log.debug("ANTITHESIS_ASSERT: Remote configuration poller initialization failed (unreachable)", e);
Assert.unreachable("Remote configuration poller initialization failed", null);
fatalOnInitialization = true;
}
return true;
}
Expand Down Expand Up @@ -379,6 +382,8 @@ private void handleAgentResponse(ResponseBody body) {
} catch (Exception e) {
// no error can be reported, as we don't have the data client.state.targets_version avail
ratelimitedLogger.warn("Error parsing remote config response", e);
log.debug("ANTITHESIS_ASSERT: Error parsing remote config response (unreachable)", e);
Assert.unreachable("Error parsing remote config response", null);
return;
}

Expand Down Expand Up @@ -446,6 +451,8 @@ private void runConfigurationEndListener(
ConfigurationEndListener listener, List<ReportableException> errors) {
try {
listener.onConfigurationEnd();
log.debug("ANTITHESIS_ASSERT: Configuration end listener should always be reachable (reachable)");
Assert.reachable("Configuration end listener should always be reachable", null);
} catch (ReportableException re) {
errors.add(re);
} catch (RuntimeException rte) {
Expand All @@ -454,6 +461,8 @@ private void runConfigurationEndListener(
// is about combining configuration from different products
ratelimitedLogger.warn(
"Error running configuration listener {}: {}", listener, rte.getMessage(), rte);
log.debug("ANTITHESIS_ASSERT: Error running configuration listener (unreachable)", rte);
Assert.unreachable("Error running configuration listener", null);
}
}

Expand Down
3 changes: 3 additions & 0 deletions telemetry/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ dependencies {
implementation(libs.slf4j)

implementation(project(":internal-api"))

// Antithesis SDK for assertions and property testing - bundled in tracer JAR
implementation(group = "com.antithesis", name = "sdk", version = "1.4.5")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: Another concern, is how much more weight it adds to the jar.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now this PR adds ~20mb to the final jar... but a lot of that is because it embeds antithesis, its native FFI wrapper, and various jackson dependencies multiple times in each of the product directories in the agent jar.

If we move it to the shared section in dd-java-agent/build.gradle and add the necessary excludes to gradle/dependencies.gradle like we do for other shared dependencies then the overhead is 3mb compressed and 8mb uncompressed.

That still feels too big to have in the general deliverable for something only used for testing purposes.

One option might be to only include the direct dependency in the release (i.e. without jackson or the ffi wrapper.) - in other words just enough to allow the classes to load. We'd then have to look at how to combine the other parts for testing, whether that's via -Xbootclasspath/a: or something similar.


compileOnly(project(":dd-java-agent:agent-tooling"))
testImplementation(project(":dd-java-agent:agent-tooling"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ public Result sendHttpRequest(Request.Builder httpRequestBuilder) {
try (okhttp3.Response response =
OkHttpUtils.sendWithRetries(okHttpClient, httpRetryPolicy, httpRequest)) {
if (response.code() == 404) {

log.debug("Telemetry endpoint is disabled, dropping {} message.", requestType);
return Result.NOT_FOUND;
}

if (!response.isSuccessful()) {
log.debug(
"Telemetry message {} failed with: {} {}.",
Expand All @@ -109,6 +111,7 @@ public Result sendHttpRequest(Request.Builder httpRequestBuilder) {
response.message());
return Result.FAILURE;
}

} catch (InterruptedIOException e) {
log.debug("Telemetry message {} sending interrupted: {}.", requestType, e.toString());
return Result.INTERRUPTED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public TelemetryClient.Result sendRequest(TelemetryRequest request) {
// interrupted request is most likely due to telemetry system shutdown,
// we do not want to log errors and reattempt in this case
&& result != TelemetryClient.Result.INTERRUPTED;

if (currentClient == agentClient) {
if (requestFailed) {
reportErrorOnce(currentClient.getUrl(), result);
Expand Down
Loading
Loading