Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Avoid performing blocking I/O operation on application thread (#8120)" #8124

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package datadog.communication.ddagent;

import static datadog.communication.ddagent.TracerVersion.TRACER_VERSION;
import static datadog.trace.util.AgentThreadFactory.AGENT_THREAD_GROUP;

import datadog.common.container.ContainerInfo;
import datadog.common.socket.SocketUtils;
Expand All @@ -10,7 +9,6 @@
import datadog.remoteconfig.ConfigurationPoller;
import datadog.remoteconfig.DefaultConfigurationPoller;
import datadog.trace.api.Config;
import datadog.trace.util.AgentTaskScheduler;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import okhttp3.HttpUrl;
Expand Down Expand Up @@ -100,11 +98,8 @@ public DDAgentFeaturesDiscovery featuresDiscovery(Config config) {
agentUrl,
config.isTraceAgentV05Enabled(),
config.isTracerMetricsEnabled());
if (AGENT_THREAD_GROUP.equals(Thread.currentThread().getThreadGroup())) {
featuresDiscovery.discover(); // safe to run on same thread
} else {
// avoid performing blocking I/O operation on application thread
AgentTaskScheduler.INSTANCE.execute(featuresDiscovery::discover);
if (!"true".equalsIgnoreCase(System.getProperty("dd.test.no.early.discovery"))) {
featuresDiscovery.discover();
}
}
return featuresDiscovery;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ public void runEnabledWithDatadogAgent() throws InterruptedException, IOExceptio
ConfigurationPoller configurationPoller =
(ConfigurationPoller) sharedCommunicationObjects.configurationPoller(Config.get());
configurationPoller.start();
RecordedRequest request;
do {
request = datadogAgentServer.takeRequest(5, TimeUnit.SECONDS);
assertNotNull(request);
} while ("/info".equals(request.getPath()));
RecordedRequest request = datadogAgentServer.takeRequest(5, TimeUnit.SECONDS);
assertNotNull(request);
assertEquals("/info", request.getPath());
request = datadogAgentServer.takeRequest(5, TimeUnit.SECONDS);
assertNotNull(request);
assertEquals("/v0.7/config", request.getPath());
DebuggerAgent.stop();
datadogAgentServer.shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,21 @@ public DefaultDataStreamsMonitoring(

@Override
public void start() {
if (features.getDataStreamsEndpoint() == null) {
features.discoverIfOutdated();
}

agentSupportsDataStreams = features.supportsDataStreams();
checkDynamicConfig();

if (!configSupportsDataStreams) {
log.debug("Data streams is disabled");
} else if (!agentSupportsDataStreams) {
log.debug("Data streams is disabled or not supported by agent");
}

nextFeatureCheck = timeSource.getCurrentTimeNanos() + FEATURE_CHECK_INTERVAL_NANOS;

cancellation =
AgentTaskScheduler.INSTANCE.scheduleAtFixedRate(
new ReportTask(), this, bucketDurationNanos, bucketDurationNanos, TimeUnit.NANOSECONDS);
Expand Down Expand Up @@ -327,22 +341,6 @@ private StatsBucket getStatsBucket(final long timestamp, final String serviceNam

@Override
public void run() {

if (features.getDataStreamsEndpoint() == null) {
features.discoverIfOutdated();
}

agentSupportsDataStreams = features.supportsDataStreams();
checkDynamicConfig();

if (!configSupportsDataStreams) {
log.debug("Data streams is disabled");
} else if (!agentSupportsDataStreams) {
log.debug("Data streams is disabled or not supported by agent");
}

nextFeatureCheck = timeSource.getCurrentTimeNanos() + FEATURE_CHECK_INTERVAL_NANOS;

Thread currentThread = Thread.currentThread();
while (!currentThread.isInterrupted()) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import datadog.trace.api.DDTraceId
import datadog.trace.api.DynamicConfig
import datadog.trace.api.time.TimeSource
import datadog.trace.bootstrap.instrumentation.api.AgentTracer.NoopPathwayContext
import datadog.trace.core.datastreams.DataStreamsMonitoring

import static datadog.trace.api.sampling.PrioritySampling.*
import static datadog.trace.api.sampling.SamplingMechanism.*
Expand All @@ -26,11 +25,7 @@ class XRayHttpInjectorTest extends DDCoreSpecification {
setup:
def writer = new ListWriter()
def timeSource = Mock(TimeSource)
def tracer = tracerBuilder()
.dataStreamsMonitoring(Mock(DataStreamsMonitoring))
.writer(writer)
.timeSource(timeSource)
.build()
def tracer = tracerBuilder().writer(writer).timeSource(timeSource).build()
final DDSpanContext mockedContext =
new DDSpanContext(
DDTraceId.from("$traceId"),
Expand Down Expand Up @@ -81,11 +76,7 @@ class XRayHttpInjectorTest extends DDCoreSpecification {
setup:
def writer = new ListWriter()
def timeSource = Mock(TimeSource)
def tracer = tracerBuilder()
.dataStreamsMonitoring(Mock(DataStreamsMonitoring))
.writer(writer)
.timeSource(timeSource)
.build()
def tracer = tracerBuilder().writer(writer).timeSource(timeSource).build()
def headers = [
'X-Amzn-Trace-Id' : "Root=1-00000000-00000000${traceId.padLeft(16, '0')};Parent=${spanId.padLeft(16, '0')}"
]
Expand Down Expand Up @@ -145,11 +136,7 @@ class XRayHttpInjectorTest extends DDCoreSpecification {
setup:
def writer = new ListWriter()
def timeSource = Mock(TimeSource)
def tracer = tracerBuilder()
.dataStreamsMonitoring(Mock(DataStreamsMonitoring))
.writer(writer)
.timeSource(timeSource)
.build()
def tracer = tracerBuilder().writer(writer).timeSource(timeSource).build()
final DDSpanContext mockedContext =
new DDSpanContext(
DDTraceId.from("1"),
Expand Down
Loading