Skip to content

Commit e75fdd2

Browse files
Make tracer changes to accept the new DD_TRACE_WCF_ENABLE_NEW_INSTRUMENTATION setting, disable original WCF instrumentation when DD_TRACE_WCF_ENABLE_NEW_INSTRUMENTATION=true, and update tests/snapshots
1 parent d6b9d16 commit e75fdd2

8 files changed

+32
-0
lines changed

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Wcf/ChannelHandlerIntegration.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public class ChannelHandlerIntegration
4242
/// <returns>Calltarget state value</returns>
4343
public static CallTargetState OnMethodBegin<TTarget, TRequestContext, TOperationContext>(TTarget instance, TRequestContext request, TOperationContext currentOperationContext)
4444
{
45+
if (Tracer.Instance.Settings.WcfEnableNewInstrumentation)
46+
{
47+
return CallTargetState.GetDefault();
48+
}
49+
4550
return new CallTargetState(WcfIntegration.CreateScope(request));
4651
}
4752

tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,12 @@ public static class ConfigurationKeys
363363
/// <seealso cref="TracerSettings.KafkaCreateConsumerScopeEnabled"/>
364364
public const string KafkaCreateConsumerScopeEnabled = "DD_TRACE_KAFKA_CREATE_CONSUMER_SCOPE_ENABLED";
365365

366+
/// <summary>
367+
/// Configuration key to enable or disable the updated WCF instrumentation
368+
/// </summary>
369+
/// <seealso cref="TracerSettings.WcfEnableNewInstrumentation"/>
370+
public const string WcfEnableNewInstrumentation = "DD_TRACE_WCF_ENABLE_NEW_INSTRUMENTATION";
371+
366372
/// <summary>
367373
/// Configuration key for enabling or disabling CI Visibility.
368374
/// Default is value is false (disabled).

tracer/src/Datadog.Trace/Configuration/TracerSettings.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ public TracerSettings(IConfigurationSource source)
214214

215215
KafkaCreateConsumerScopeEnabled = source?.GetBool(ConfigurationKeys.KafkaCreateConsumerScopeEnabled)
216216
?? true; // default
217+
218+
WcfEnableNewInstrumentation = source?.GetBool(ConfigurationKeys.WcfEnableNewInstrumentation)
219+
?? false;
217220
}
218221

219222
/// <summary>
@@ -413,6 +416,11 @@ public int PartialFlushMinSpans
413416
/// <seealso cref="ConfigurationKeys.KafkaCreateConsumerScopeEnabled"/>
414417
public bool KafkaCreateConsumerScopeEnabled { get; set; }
415418

419+
/// <summary>
420+
/// Gets or sets a value indicating whether to use the updated WCF instrumentation
421+
/// </summary>
422+
public bool WcfEnableNewInstrumentation { get; set; }
423+
416424
/// <summary>
417425
/// Gets or sets a value indicating whether the diagnostic log at startup is enabled
418426
/// </summary>

tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/WcfTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,17 @@ public static IEnumerable<object[]> GetData()
3939
{
4040
foreach (var binding in Bindings)
4141
{
42+
// When using the binding example, it is expected that CallSite or CallTarget w/ Old WCF fails,
43+
// so only include CallTarget w/ New WCF
44+
if (binding == "Custom")
45+
{
46+
yield return new object[] { binding, true, true };
47+
continue;
48+
}
49+
4250
yield return new object[] { binding, false, false };
4351
yield return new object[] { binding, true, false };
52+
yield return new object[] { binding, true, true };
4453
}
4554
}
4655

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

0 commit comments

Comments
 (0)