Skip to content
Merged
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: 2 additions & 1 deletion tracer/src/Datadog.Trace/ClrProfiler/Instrumentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,8 @@ private static void InitializeDebugger(TracerSettings tracerSettings)

if (!debuggerSettings.DynamicInstrumentationEnabled
&& !debuggerSettings.CodeOriginForSpansEnabled
&& !manager.ExceptionReplaySettings.Enabled)
&& !manager.ExceptionReplaySettings.Enabled
&& !debuggerSettings.SymbolDatabaseUploadEnabled)
{
Log.Debug("Debugger products are not enabled");
}
Expand Down
15 changes: 4 additions & 11 deletions tracer/src/Datadog.Trace/Debugger/DebuggerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,9 @@ private void InitializeSymbolUploaderIfNeeded(TracerSettings tracerSettings, Deb
return;
}

if (!DebuggerSettings.SymbolDatabaseUploadEnabled
|| !newDebuggerSettings.DynamicInstrumentationCanBeEnabled)
if (!newDebuggerSettings.SymbolDatabaseUploadEnabled)
{
// explicitly disabled via local env var or DI can not be enabled
// explicitly disabled via local env var
return;
}

Expand All @@ -297,15 +296,9 @@ private void InitializeSymbolUploaderIfNeeded(TracerSettings tracerSettings, Deb
return;
}

if (!newDebuggerSettings.DynamicInstrumentationEnabled
&& newDebuggerSettings.DynamicSettings.DynamicInstrumentationEnabled != true)
{
return;
}

// Initialize symbol database uploader only if DI is enabled locally or remotely.
// Initialize the symbol uploader as soon as local settings allow it.
var tracerManager = TracerManager.Instance;
this.SymbolsUploader = DebuggerFactory.CreateSymbolsUploader(tracerManager.DiscoveryService, RcmSubscriptionManager.Instance, () => ServiceName, tracerSettings, DebuggerSettings, tracerManager.GitMetadataTagsProvider);
this.SymbolsUploader = DebuggerFactory.CreateSymbolsUploader(tracerManager.DiscoveryService, RcmSubscriptionManager.Instance, () => ServiceName, tracerSettings, newDebuggerSettings, tracerManager.GitMetadataTagsProvider);
_ = this.SymbolsUploader.StartFlushingAsync()
.ContinueWith(
t => Log.Error(t?.Exception, "Failed to initialize symbol uploader"),
Expand Down
2 changes: 1 addition & 1 deletion tracer/src/Datadog.Trace/Debugger/DebuggerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public DebuggerSettings(IConfigurationSource? source, IConfigurationTelemetry te
DynamicInstrumentationEnabled = diEnabledResult.WithDefault(false);
DynamicInstrumentationCanBeEnabled = diEnabledResult.ConfigurationResult is not { IsValid: true, Result: false };

SymbolDatabaseUploadEnabled = config.WithKeys(ConfigurationKeys.Debugger.SymbolDatabaseUploadEnabled).AsBool(DynamicInstrumentationCanBeEnabled);
SymbolDatabaseUploadEnabled = config.WithKeys(ConfigurationKeys.Debugger.SymbolDatabaseUploadEnabled).AsBool(true);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

SymDB only makes sense where we have remote config, right? So maybe we should only be enabling this in scenarios where we have remote config? 🤔 e.g. there are a lot of serverless scenarios which don't, and those are particularly sensitive to doing extra work on startup, so it could be quite beneficial?


MaximumDepthOfMembersToCopy = config
.WithKeys(ConfigurationKeys.Debugger.MaxDepthToSerialize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ await RunDynamicConfigurationTest(
// Initially, no DI objects should exist
memoryAssertions.NoObjectsExist<DynamicInstrumentation>();
memoryAssertions.NoObjectsExist<LineProbeResolver>();
memoryAssertions.NoObjectsExist<Symbols.SymbolsUploader>();
// The uploader starts early so it can subscribe to SymDB remote config
// even while Dynamic Instrumentation is still disabled.
memoryAssertions.ObjectsExist<Symbols.SymbolsUploader>();
},
remoteConfig: new { dynamic_instrumentation_enabled = true },
DynamicInstrumentationEnabledLogEntry,
Expand Down Expand Up @@ -121,6 +123,7 @@ await RunDynamicConfigurationTest(
public async Task DebuggerManager_MultipleProducts_StartDisabled_EnabledViaRemoteConfig()
{
SetEnvironmentVariable(ConfigurationKeys.Rcm.RemoteConfigurationEnabled, "true");
SetEnvironmentVariable(ConfigurationKeys.Debugger.CodeOriginForSpansEnabled, string.Empty);

await RunDynamicConfigurationTest(
false,
Expand All @@ -129,10 +132,11 @@ await RunDynamicConfigurationTest(
// Initially, no debugger objects should exist
memoryAssertions.NoObjectsExist<DynamicInstrumentation>();
memoryAssertions.NoObjectsExist<ExceptionAutoInstrumentation.ExceptionReplay>();
memoryAssertions.NoObjectsExist<SpanCodeOrigin.SpanCodeOrigin>();
memoryAssertions.NoObjectsExist<SnapshotSink>();
memoryAssertions.NoObjectsExist<LineProbeResolver>();
memoryAssertions.NoObjectsExist<Symbols.SymbolsUploader>();
// The uploader starts early so it can subscribe to SymDB remote config
// even while the other debugger products remain disabled.
memoryAssertions.ObjectsExist<Symbols.SymbolsUploader>();
},
remoteConfig: new
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ public DebuggerManagerTests(ITestOutputHelper output)
[Trait("Category", "ArmUnsupported")]
[Trait("RunOnWindows", "True")]
[Trait("Category", "LinuxUnsupported")]
public async Task DebuggerManager_AllFeaturesByDefault_NoDebuggerObjectsCreated()
public async Task DebuggerManager_AllFeaturesByDefault_CreatesOnlyNonDiDebuggerObjects()
{
await RunDebuggerManagerTestWithMemoryAssertions(memoryAssertions =>
{
memoryAssertions.NoObjectsExist<SnapshotSink>();
memoryAssertions.NoObjectsExist<LineProbeResolver>();
memoryAssertions.NoObjectsExist<DynamicInstrumentation>();
memoryAssertions.NoObjectsExist<ExceptionAutoInstrumentation.ExceptionReplay>();
memoryAssertions.NoObjectsExist<Symbols.SymbolsUploader>();
memoryAssertions.ObjectsExist<Symbols.SymbolsUploader>();
memoryAssertions.ObjectsExist<SpanCodeOrigin.SpanCodeOrigin>();
});
}
Expand All @@ -63,7 +63,7 @@ await RunDebuggerManagerTestWithMemoryAssertions(memoryAssertions =>
[Trait("Category", "ArmUnsupported")]
[Trait("RunOnWindows", "True")]
[Trait("Category", "LinuxUnsupported")]
public async Task DebuggerManager_DynamicInstrumentationExplicitlyDisabled_NoDebuggerObjectsCreated()
public async Task DebuggerManager_DynamicInstrumentationExplicitlyDisabled_DoesNotCreateDynamicInstrumentationObjects()
{
// at least one product should be enabled to initialize the debugger manager
SetEnvironmentVariable(ConfigurationKeys.Debugger.CodeOriginForSpansEnabled, "true");
Expand All @@ -76,6 +76,24 @@ await RunDebuggerManagerTestWithMemoryAssertions(memoryAssertions =>
});
}

[SkippableFact]
[Trait("Category", "EndToEnd")]
[Trait("Category", "ArmUnsupported")]
[Trait("RunOnWindows", "True")]
[Trait("Category", "LinuxUnsupported")]
public async Task DebuggerManager_DynamicInstrumentationExplicitlyDisabled_SymbolDatabaseEnabledByDefault_CreatesSymbolUploader()
{
SetEnvironmentVariable(ConfigurationKeys.Debugger.DynamicInstrumentationEnabled, "false");

await RunDebuggerManagerTestWithMemoryAssertions(memoryAssertions =>
{
memoryAssertions.NoObjectsExist<SnapshotSink>();
memoryAssertions.NoObjectsExist<LineProbeResolver>();
memoryAssertions.NoObjectsExist<DynamicInstrumentation>();
memoryAssertions.ObjectsExist<Symbols.SymbolsUploader>();
});
}

[SkippableFact]
[Trait("Category", "EndToEnd")]
[Trait("Category", "ArmUnsupported")]
Expand Down Expand Up @@ -126,6 +144,23 @@ await RunDebuggerManagerTestWithMemoryAssertions(memoryAssertions =>
});
}

[SkippableFact]
[Trait("Category", "EndToEnd")]
[Trait("Category", "ArmUnsupported")]
[Trait("RunOnWindows", "True")]
[Trait("Category", "LinuxUnsupported")]
public async Task DebuggerManager_SymbolDatabaseUploadEnabled_WithoutDynamicInstrumentation_CreatesSymbolUploader()
{
SetEnvironmentVariable(ConfigurationKeys.Debugger.CodeOriginForSpansEnabled, "true");
SetEnvironmentVariable(ConfigurationKeys.Debugger.SymbolDatabaseUploadEnabled, "true");

await RunDebuggerManagerTestWithMemoryAssertions(memoryAssertions =>
{
memoryAssertions.NoObjectsExist<DynamicInstrumentation>();
memoryAssertions.ObjectsExist<Symbols.SymbolsUploader>();
});
}

[SkippableFact]
[Trait("Category", "EndToEnd")]
[Trait("Category", "ArmUnsupported")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,23 @@ public void SymbolsEnabled(string enabled)
settings.SymbolDatabaseUploadEnabled.Should().BeTrue();
}

[Theory]
[InlineData("false")]
[InlineData("0")]
public void SymbolsEnabled_WhenDynamicInstrumentationExplicitlyDisabled(string enabled)
{
var settings = new DebuggerSettings(
new NameValueConfigurationSource(new()
{
{ ConfigurationKeys.Debugger.DynamicInstrumentationEnabled, enabled },
}),
NullConfigurationTelemetry.Instance);

settings.DynamicInstrumentationEnabled.Should().BeFalse();
settings.DynamicInstrumentationCanBeEnabled.Should().BeFalse();
settings.SymbolDatabaseUploadEnabled.Should().BeTrue();
}

[Fact]
public void DebuggerSettings_UseSettings()
{
Expand Down
Loading