From fd1f40f934d671454cbc0771c153e1bffde45bf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Gonz=C3=A1lez=20Garc=C3=ADa?= Date: Thu, 12 Dec 2024 17:45:47 +0100 Subject: [PATCH] Add configurable Dependency service resolution period (#8079) --- .../java/datadog/trace/api/config/GeneralConfig.java | 2 ++ .../src/main/java/datadog/trace/api/Config.java | 11 +++++++++++ .../telemetry/dependency/DependencyService.java | 7 ++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/dd-trace-api/src/main/java/datadog/trace/api/config/GeneralConfig.java b/dd-trace-api/src/main/java/datadog/trace/api/config/GeneralConfig.java index ee4886e7ad0..524dde00dcb 100644 --- a/dd-trace-api/src/main/java/datadog/trace/api/config/GeneralConfig.java +++ b/dd-trace-api/src/main/java/datadog/trace/api/config/GeneralConfig.java @@ -89,6 +89,8 @@ public final class GeneralConfig { public static final String AGENTLESS_LOG_SUBMISSION_ENABLED = "agentless.log.submission.enabled"; public static final String AGENTLESS_LOG_SUBMISSION_QUEUE_SIZE = "agentless.log.submission.queue.size"; + public static final String TELEMETRY_DEPENDENCY_RESOLUTION_PERIOD_MILLIS = + "telemetry.dependency.resolution.period.millis"; public static final String AGENTLESS_LOG_SUBMISSION_LEVEL = "agentless.log.submission.level"; public static final String AGENTLESS_LOG_SUBMISSION_URL = "agentless.log.submission.url"; diff --git a/internal-api/src/main/java/datadog/trace/api/Config.java b/internal-api/src/main/java/datadog/trace/api/Config.java index ad14e1fd98a..e24fe3a2710 100644 --- a/internal-api/src/main/java/datadog/trace/api/Config.java +++ b/internal-api/src/main/java/datadog/trace/api/Config.java @@ -538,6 +538,8 @@ public static String getHostName() { private final int cloudPayloadTaggingMaxDepth; private final int cloudPayloadTaggingMaxTags; + private final long dependecyResolutionPeriodMillis; + // Read order: System Properties -> Env Variables, [-> properties file], [-> default value] private Config() { this(ConfigProvider.createDefault()); @@ -1802,6 +1804,11 @@ PROFILING_DATADOG_PROFILER_ENABLED, isDatadogProfilerSafeInCurrentEnvironment()) this.cloudPayloadTaggingMaxTags = configProvider.getInteger(TracerConfig.TRACE_CLOUD_PAYLOAD_TAGGING_MAX_TAGS, 758); + this.dependecyResolutionPeriodMillis = + configProvider.getLong( + GeneralConfig.TELEMETRY_DEPENDENCY_RESOLUTION_PERIOD_MILLIS, + 1000); // 1 second by default + timelineEventsEnabled = configProvider.getBoolean( ProfilingConfig.PROFILING_TIMELINE_EVENTS_ENABLED, @@ -3700,6 +3707,10 @@ public boolean isEnabled( Collections.singletonList(settingName), "", settingSuffix, defaultEnabled); } + public long getDependecyResolutionPeriodMillis() { + return dependecyResolutionPeriodMillis; + } + public boolean isDBMTracePreparedStatements() { return DBMTracePreparedStatements; } diff --git a/telemetry/src/main/java/datadog/telemetry/dependency/DependencyService.java b/telemetry/src/main/java/datadog/telemetry/dependency/DependencyService.java index ba0531d062d..f561e9bb163 100644 --- a/telemetry/src/main/java/datadog/telemetry/dependency/DependencyService.java +++ b/telemetry/src/main/java/datadog/telemetry/dependency/DependencyService.java @@ -1,5 +1,6 @@ package datadog.telemetry.dependency; +import datadog.trace.api.Config; import datadog.trace.util.AgentTaskScheduler; import java.lang.instrument.Instrumentation; import java.net.URI; @@ -31,7 +32,11 @@ public class DependencyService implements Runnable { public void schedulePeriodicResolution() { scheduledTask = AgentTaskScheduler.INSTANCE.scheduleAtFixedRate( - AgentTaskScheduler.RunnableTask.INSTANCE, this, 0, 1000L, TimeUnit.MILLISECONDS); + AgentTaskScheduler.RunnableTask.INSTANCE, + this, + 0, + Config.get().getDependecyResolutionPeriodMillis(), + TimeUnit.MILLISECONDS); } public void resolveOneDependency() {