Skip to content
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
Expand Up @@ -43,6 +43,7 @@ scenarios:
CORECLR_ENABLE_PROFILING: 1
DD_CLR_ENABLE_INLINING: 1
DD_CLR_ENABLE_NGEN: 1
DD_TRACE_SINGLE_WEB_SPAN_ENABLED: "1"
load:
job: bombardier
variables:
Expand Down
8 changes: 6 additions & 2 deletions tracer/src/Datadog.Trace/ClrProfiler/Instrumentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,16 @@ private static void StartDiagnosticManager()
{
var observers = new List<DiagnosticObserver>();

if (Tracer.Instance.Settings.AzureAppServiceMetadata?.IsFunctionsApp is not true)
var settings = Tracer.Instance.Settings;
if (settings.AzureAppServiceMetadata?.IsFunctionsApp is not true)
{
// Not adding the `AspNetCoreDiagnosticObserver` is particularly important for Azure Functions.
// The AspNetCoreDiagnosticObserver will be loaded in a separate Assembly Load Context, breaking the connection of AsyncLocal
// This is because user code is loaded within the functions host in a separate context
observers.Add(new AspNetCoreDiagnosticObserver());
DiagnosticObserver observer = settings.SingleWebSpanEnabled
? new SingleSpanAspNetCoreDiagnosticObserver()
: new AspNetCoreDiagnosticObserver();
observers.Add(observer);
}

var diagnosticManager = new DiagnosticManager(observers);
Expand Down
8 changes: 8 additions & 0 deletions tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,14 @@ internal static class FeatureFlags
/// <seealso cref="TracerSettings.RouteTemplateResourceNamesEnabled"/>
public const string RouteTemplateResourceNamesEnabled = "DD_TRACE_ROUTE_TEMPLATE_RESOURCE_NAMES_ENABLED";

/// <summary>
/// When enabled, <c>aspnet_core_mvc.request</c>, <c>aspnet-webapi.request</c>, and <c>aspnet-mvc.request</c>
/// spans will not be created. Instead, tags typically associated with these spans will be associated with
/// the <c>aspnet.request</c> and <c>aspnet_core.request</c> span instead.
/// </summary>
/// <seealso cref="TracerSettings.SingleWebSpanEnabled"/>
public const string SingleWebSpanEnabled = "DD_TRACE_SINGLE_WEB_SPAN_ENABLED";

/// <summary>
/// Configuration key to enable or disable the updated WCF instrumentation that delays execution
/// until later in the WCF pipeline when the WCF server exception handling is established.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ internal ImmutableTracerSettings(TracerSettings settings, bool unusedParamNotToU
TraceBufferSize = settings.TraceBufferSize;
TraceBatchInterval = settings.TraceBatchInterval;
RouteTemplateResourceNamesEnabled = settings.RouteTemplateResourceNamesEnabled;
SingleWebSpanEnabled = settings.SingleWebSpanEnabled;
DelayWcfInstrumentationEnabled = settings.DelayWcfInstrumentationEnabled;
WcfWebHttpResourceNamesEnabled = settings.WcfWebHttpResourceNamesEnabled;
WcfObfuscationEnabled = settings.WcfObfuscationEnabled;
Expand Down Expand Up @@ -426,6 +427,12 @@ internal ImmutableTracerSettings(TracerSettings settings, bool unusedParamNotToU
/// <seealso cref="ConfigurationKeys.FeatureFlags.RouteTemplateResourceNamesEnabled"/>
internal bool RouteTemplateResourceNamesEnabled { get; }

/// <summary>
/// Gets a value indicating whether the feature flag to enable single-web spans is enabled
/// </summary>
/// <seealso cref="ConfigurationKeys.FeatureFlags.SingleWebSpanEnabled"/>
internal bool SingleWebSpanEnabled { get; }

/// <summary>
/// Gets a value indicating whether route parameters in ASP.NET and ASP.NET Core resource names
/// should be expanded with their values. Only applies when <see cref="RouteTemplateResourceNamesEnabled"/>
Expand Down
11 changes: 11 additions & 0 deletions tracer/src/Datadog.Trace/Configuration/TracerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ internal TracerSettings(IConfigurationSource? source, IConfigurationTelemetry te
.WithKeys(ConfigurationKeys.FeatureFlags.RouteTemplateResourceNamesEnabled)
.AsBool(defaultValue: true);

SingleWebSpanEnabled = RouteTemplateResourceNamesEnabled // always disabled if route template resources names disabled
&& config
.WithKeys(ConfigurationKeys.FeatureFlags.SingleWebSpanEnabled)
.AsBool(defaultValue: false);

ExpandRouteTemplatesEnabled = config
.WithKeys(ConfigurationKeys.ExpandRouteTemplatesEnabled)
.AsBool(defaultValue: !RouteTemplateResourceNamesEnabled); // disabled by default if route template resource names enabled
Expand Down Expand Up @@ -792,6 +797,12 @@ public bool DiagnosticSourceEnabled
/// <seealso cref="ConfigurationKeys.FeatureFlags.RouteTemplateResourceNamesEnabled"/>
internal bool RouteTemplateResourceNamesEnabled { get; }

/// <summary>
/// Gets a value indicating whether the feature flag to enable single-web spans is enabled
/// </summary>
/// <seealso cref="ConfigurationKeys.FeatureFlags.SingleWebSpanEnabled"/>
internal bool SingleWebSpanEnabled { get; }

/// <summary>
/// Gets a value indicating whether resource names for ASP.NET and ASP.NET Core spans should be expanded. Only applies
/// when <see cref="RouteTemplateResourceNamesEnabled"/> is <code>true</code>.
Expand Down
Loading