GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Avoid performing blocking I/O operation on application thread by mcculls · Pull Request #8120 · DataDog/dd-trace-java

Avoid performing blocking I/O operation on application thread #8120

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.

Sign up for GitHub

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

Merged
mcculls merged 4 commits into master from mcculls/move-discovery-off-app-thread
Dec 20, 2024

Uh oh!

There was an error while loading. Please reload this page.

Merged

Avoid performing blocking I/O operation on application thread #8120

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
4 commits
Select commit Hold shift + click to select a range
3cb466b
Avoid performing blocking I/O operation on application thread
mcculls Dec 20, 2024
e6224b2
Make test more tolerant of parallel discover requests
mcculls Dec 20, 2024
5fc9c69
Cleanup test side-effects
mcculls Dec 20, 2024
a6cbc55
Call checkDynamicConfig() at DSM start to load tracer config, then ag…
mcculls Dec 20, 2024
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

9 changes: 7 additions & 2 deletions 9 communication/src/main/java/datadog/communication/ddagent/SharedCommunicationObjects.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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 @@ -9,6 +10,7 @@
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 @@ -98,8 +100,11 @@ public DDAgentFeaturesDiscovery featuresDiscovery(Config config) {
agentUrl,
config.isTraceAgentV05Enabled(),
config.isTracerMetricsEnabled());
if (!"true".equalsIgnoreCase(System.getProperty("dd.test.no.early.discovery"))) {
featuresDiscovery.discover();
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);
}
}
return featuresDiscovery;
Expand Down
10 changes: 5 additions & 5 deletions 10 dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/agent/DebuggerAgentTest.java
Show comments
View file
Open in desktop
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 = datadogAgentServer.takeRequest(5, TimeUnit.SECONDS);
assertNotNull(request);
assertEquals("/info", request.getPath());
request = datadogAgentServer.takeRequest(5, TimeUnit.SECONDS);
assertNotNull(request);
RecordedRequest request;
do {
request = datadogAgentServer.takeRequest(5, TimeUnit.SECONDS);
assertNotNull(request);
} while ("/info".equals(request.getPath()));
assertEquals("/v0.7/config", request.getPath());
DebuggerAgent.stop();
datadogAgentServer.shutdown();
Expand Down
30 changes: 16 additions & 14 deletions 30 dd-trace-core/src/main/java/datadog/trace/core/datastreams/DefaultDataStreamsMonitoring.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,7 @@ 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 @@ -341,6 +327,22 @@ 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
19 changes: 16 additions & 3 deletions 19 dd-trace-core/src/test/groovy/datadog/trace/core/propagation/XRayHttpInjectorTest.groovy
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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 @@ -25,7 +26,11 @@ class XRayHttpInjectorTest extends DDCoreSpecification {
setup:
def writer = new ListWriter()
def timeSource = Mock(TimeSource)
def tracer = tracerBuilder().writer(writer).timeSource(timeSource).build()
def tracer = tracerBuilder()
.dataStreamsMonitoring(Mock(DataStreamsMonitoring))
.writer(writer)
.timeSource(timeSource)
.build()
final DDSpanContext mockedContext =
new DDSpanContext(
DDTraceId.from("$traceId"),
Expand Down Expand Up @@ -76,7 +81,11 @@ class XRayHttpInjectorTest extends DDCoreSpecification {
setup:
def writer = new ListWriter()
def timeSource = Mock(TimeSource)
def tracer = tracerBuilder().writer(writer).timeSource(timeSource).build()
def tracer = tracerBuilder()
.dataStreamsMonitoring(Mock(DataStreamsMonitoring))
.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 @@ -136,7 +145,11 @@ class XRayHttpInjectorTest extends DDCoreSpecification {
setup:
def writer = new ListWriter()
def timeSource = Mock(TimeSource)
def tracer = tracerBuilder().writer(writer).timeSource(timeSource).build()
def tracer = tracerBuilder()
.dataStreamsMonitoring(Mock(DataStreamsMonitoring))
.writer(writer)
.timeSource(timeSource)
.build()
final DDSpanContext mockedContext =
new DDSpanContext(
DDTraceId.from("1"),
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.