Skip to content
Open
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
Expand Up @@ -17,6 +17,9 @@

namespace Datadog.Trace.Agent.DiscoveryService
{
/// <summary>
/// Queries the Datadog Agent and discovers which version we are running against and which endpoints it supports.
/// </summary>
internal class DiscoveryService : IDiscoveryService
{
private const string SupportedDebuggerEndpoint = "debugger/v1/input";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Datadog.Trace.Agent.DiscoveryService
{
/// <summary>
/// Queries datadog-agent and discovers which version we are running against and what endpoints it supports.
/// Queries the Datadog Agent and discovers which version we are running against and which endpoints it supports.
/// </summary>
internal interface IDiscoveryService
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected override IAgentWriter GetAgentWriter(TracerSettings settings, IDogStat
return new ApmAgentWriter(settings, updateSampleRates, discoveryService, traceBufferSize);
}

protected override IDiscoveryService GetDiscoveryService(TracerSettings settings)
internal override IDiscoveryService GetDiscoveryService(TracerSettings settings)
=> _testOptimizationTracerManagement.DiscoveryService;
}
}
7 changes: 7 additions & 0 deletions tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,13 @@ internal static partial class ConfigurationKeys
/// </summary>
public const string ApplicationMonitoringConfigFileEnabled = "DD_APPLICATION_MONITORING_CONFIG_FILE_ENABLED";

/// <summary>
/// Configuration key to disable polling the /info endpoint in the trace agent for feature discovery.
/// Default value is true (polling enabled).
/// </summary>
/// <seealso cref="TracerSettings.AgentFeaturePollingEnabled"/>
public const string AgentFeaturePollingEnabled = "DD_AGENT_FEATURE_POLLING_ENABLED";

/// <summary>
/// String constants for CI Visibility configuration keys.
/// </summary>
Expand Down
13 changes: 13 additions & 0 deletions tracer/src/Datadog.Trace/Configuration/TracerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@ not null when string.Equals(value, "otlp", StringComparison.OrdinalIgnoreCase) =
.WithKeys(ConfigurationKeys.AzureServiceBusBatchLinksEnabled)
.AsBool(defaultValue: true);

AgentFeaturePollingEnabled = config
.WithKeys(ConfigurationKeys.AgentFeaturePollingEnabled)
.AsBool(defaultValue: true);

DelayWcfInstrumentationEnabled = config
.WithKeys(ConfigurationKeys.FeatureFlags.DelayWcfInstrumentationEnabled)
.AsBool(defaultValue: true);
Expand Down Expand Up @@ -990,6 +994,15 @@ not null when string.Equals(value, "otlp", StringComparison.OrdinalIgnoreCase) =
/// <seealso cref="ConfigurationKeys.AzureServiceBusBatchLinksEnabled"/>
public bool AzureServiceBusBatchLinksEnabled { get; }

/// <summary>
/// Gets a value indicating whether the agent discovery service is enabled.
/// When disabled, the tracer will not query the agent for available endpoints.
/// This is useful in environments where the discovery endpoint is not available (e.g., Azure Functions with Rust agent).
/// Default value is true (discovery service enabled).
/// </summary>
/// <seealso cref="ConfigurationKeys.AgentFeaturePollingEnabled"/>
public bool AgentFeaturePollingEnabled { get; }

/// <summary>
/// Gets a value indicating whether to enable the updated WCF instrumentation that delays execution
/// until later in the WCF pipeline when the WCF server exception handling is established.
Expand Down
8 changes: 5 additions & 3 deletions tracer/src/Datadog.Trace/TracerManagerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,6 @@ private static string GetUrl(TracerSettings settings)
}
}

protected virtual IDiscoveryService GetDiscoveryService(TracerSettings settings)
=> DiscoveryService.Create(settings.Exporter);

internal static IDogStatsd CreateDogStatsdClient(TracerSettings settings, string serviceName, List<string> constantTags, string prefix = null, TimeSpan? telemtryFlushInterval = null)
{
try
Expand Down Expand Up @@ -507,6 +504,11 @@ internal static IDogStatsd CreateDogStatsdClient(TracerSettings settings, string
}
}

internal virtual IDiscoveryService GetDiscoveryService(TracerSettings settings)
=> settings.AgentFeaturePollingEnabled ?
DiscoveryService.Create(settings.Exporter) :
NullDiscoveryService.Instance;

private static IDogStatsd CreateDogStatsdClient(TracerSettings settings, string serviceName)
{
var customTagCount = settings.GlobalTags.Count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@
"dbm_propagation_mode": "dbm_propagation_mode",
"trace.remove_root_span_laravel_queue": "trace_remove_root_span_laravel_queue_enabled",
"trace.remove_autoinstrumentation_orphans": "trace_remove_auto_instrumentation_orphans_enabled",
"DD_AGENT_FEATURE_POLLING_ENABLED": "agent_feature_polling_enabled",
"DD_TRACE_AWS_ADD_SPAN_POINTERS": "trace_aws_add_span_pointers",
"DD_TRACE_CONFIG_FILE": "trace_config_file",
"DD_DOTNET_TRACER_CONFIG_FILE": "trace_config_file",
Expand Down
23 changes: 23 additions & 0 deletions tracer/test/Datadog.Trace.Tests/TracerManagerFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,29 @@ public void RemoteConfigIsDisabledInAzureAppServices()
_manager.TracerFlareManager.Should().BeOfType<NullTracerFlareManager>();
}

[Theory]
[InlineData(true)]
[InlineData(false)]
public void DiscoveryServiceCanBeDisabled(bool enabled)
{
var source = CreateConfigurationSource((ConfigurationKeys.AgentFeaturePollingEnabled, enabled.ToString()));
var settings = new TracerSettings(source);

settings.AgentFeaturePollingEnabled.Should().Be(enabled);

var factory = new TracerManagerFactory();
var discoveryService = factory.GetDiscoveryService(settings);

if (enabled)
{
discoveryService.Should().BeOfType<DiscoveryService>();
}
else
{
discoveryService.Should().BeSameAs(NullDiscoveryService.Instance);
}
}

private static TracerManager CreateTracerManager(TracerSettings settings)
{
return new TracerManagerFactory().CreateTracerManager(
Expand Down
Loading