diff --git a/src/OpenTelemetry.Contrib.Instrumentation.Wcf/CHANGELOG.md b/src/OpenTelemetry.Contrib.Instrumentation.Wcf/CHANGELOG.md
index baf57e4996..5b4f7fe271 100644
--- a/src/OpenTelemetry.Contrib.Instrumentation.Wcf/CHANGELOG.md
+++ b/src/OpenTelemetry.Contrib.Instrumentation.Wcf/CHANGELOG.md
@@ -1,5 +1,10 @@
# Changelog
+## 1.0.0-rc4
+
+* Removed `Propagator` property on `WcfInstrumentationOptions`
+ ([#163](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/163))
+
## 1.0.0-rc3
* Added `TelemetryServiceBehavior`. **Breaking change** (config update
diff --git a/src/OpenTelemetry.Contrib.Instrumentation.Wcf/Implementation/ActionMetadata.cs b/src/OpenTelemetry.Contrib.Instrumentation.Wcf/Implementation/ActionMetadata.cs
index 463e26008f..c5ddc9e46a 100644
--- a/src/OpenTelemetry.Contrib.Instrumentation.Wcf/Implementation/ActionMetadata.cs
+++ b/src/OpenTelemetry.Contrib.Instrumentation.Wcf/Implementation/ActionMetadata.cs
@@ -16,7 +16,7 @@
namespace OpenTelemetry.Contrib.Instrumentation.Wcf
{
- internal class ActionMetadata
+ internal sealed class ActionMetadata
{
public string ContractName { get; set; }
diff --git a/src/OpenTelemetry.Contrib.Instrumentation.Wcf/Implementation/WcfInstrumentationEventSource.cs b/src/OpenTelemetry.Contrib.Instrumentation.Wcf/Implementation/WcfInstrumentationEventSource.cs
index 894eda0a35..f3642a45e5 100644
--- a/src/OpenTelemetry.Contrib.Instrumentation.Wcf/Implementation/WcfInstrumentationEventSource.cs
+++ b/src/OpenTelemetry.Contrib.Instrumentation.Wcf/Implementation/WcfInstrumentationEventSource.cs
@@ -22,7 +22,7 @@
namespace OpenTelemetry.Contrib.Instrumentation.Wcf.Implementation
{
[EventSource(Name = "OpenTelemetry-Instrumentation-Wcf")]
- internal class WcfInstrumentationEventSource : EventSource
+ internal sealed class WcfInstrumentationEventSource : EventSource
{
public static readonly WcfInstrumentationEventSource Log = new WcfInstrumentationEventSource();
@@ -36,9 +36,9 @@ public void RequestFilterException(Exception ex)
}
[Event(EventIds.RequestIsFilteredOut, Message = "Request is filtered out.", Level = EventLevel.Verbose)]
- public void RequestIsFilteredOut(string eventName)
+ public void RequestIsFilteredOut()
{
- this.WriteEvent(EventIds.RequestIsFilteredOut, eventName);
+ this.WriteEvent(EventIds.RequestIsFilteredOut);
}
[Event(EventIds.RequestFilterException, Message = "InstrumentationFilter threw exception. Request will not be collected. Exception {0}.", Level = EventLevel.Error)]
diff --git a/src/OpenTelemetry.Contrib.Instrumentation.Wcf/TelemetryClientMessageInspector.cs b/src/OpenTelemetry.Contrib.Instrumentation.Wcf/TelemetryClientMessageInspector.cs
index da98d95bd1..5542d629c0 100644
--- a/src/OpenTelemetry.Contrib.Instrumentation.Wcf/TelemetryClientMessageInspector.cs
+++ b/src/OpenTelemetry.Contrib.Instrumentation.Wcf/TelemetryClientMessageInspector.cs
@@ -45,7 +45,7 @@ public object BeforeSendRequest(ref Message request, IClientChannel channel)
{
if (WcfInstrumentationActivitySource.Options == null || WcfInstrumentationActivitySource.Options.OutgoingRequestFilter?.Invoke(request) == false)
{
- WcfInstrumentationEventSource.Log.RequestIsFilteredOut(request.Headers.Action);
+ WcfInstrumentationEventSource.Log.RequestIsFilteredOut();
return new State
{
SuppressionScope = this.SuppressDownstreamInstrumentation(),
@@ -71,7 +71,7 @@ public object BeforeSendRequest(ref Message request, IClientChannel channel)
string action = request.Headers.Action;
activity.DisplayName = action;
- WcfInstrumentationActivitySource.Options.Propagator.Inject(
+ Propagators.DefaultTextMapPropagator.Inject(
new PropagationContext(activity.Context, Baggage.Current),
request,
WcfInstrumentationActivitySource.MessageHeaderValueSetter);
@@ -136,8 +136,7 @@ public void AfterReceiveReply(ref Message reply, object correlationState)
state.SuppressionScope?.Dispose();
- Activity activity = state.Activity;
- if (activity != null)
+ if (state.Activity is Activity activity)
{
if (activity.IsAllDataRequested)
{
diff --git a/src/OpenTelemetry.Contrib.Instrumentation.Wcf/TelemetryContractBehaviorAttribute.cs b/src/OpenTelemetry.Contrib.Instrumentation.Wcf/TelemetryContractBehaviorAttribute.cs
index 29ea4a4b38..1867f80a6f 100644
--- a/src/OpenTelemetry.Contrib.Instrumentation.Wcf/TelemetryContractBehaviorAttribute.cs
+++ b/src/OpenTelemetry.Contrib.Instrumentation.Wcf/TelemetryContractBehaviorAttribute.cs
@@ -36,7 +36,7 @@ namespace OpenTelemetry.Contrib.Instrumentation.Wcf
///
#endif
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
- public class TelemetryContractBehaviorAttribute : Attribute, IContractBehavior
+ public sealed class TelemetryContractBehaviorAttribute : Attribute, IContractBehavior
{
///
public void AddBindingParameters(ContractDescription contractDescription, ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
diff --git a/src/OpenTelemetry.Contrib.Instrumentation.Wcf/TelemetryDispatchMessageInspector.cs b/src/OpenTelemetry.Contrib.Instrumentation.Wcf/TelemetryDispatchMessageInspector.cs
index 2db138872f..b1064030bb 100644
--- a/src/OpenTelemetry.Contrib.Instrumentation.Wcf/TelemetryDispatchMessageInspector.cs
+++ b/src/OpenTelemetry.Contrib.Instrumentation.Wcf/TelemetryDispatchMessageInspector.cs
@@ -21,6 +21,7 @@
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Dispatcher;
+using OpenTelemetry.Context.Propagation;
using OpenTelemetry.Contrib.Instrumentation.Wcf.Implementation;
using OpenTelemetry.Trace;
@@ -45,7 +46,7 @@ public object AfterReceiveRequest(ref Message request, IClientChannel channel, I
{
if (WcfInstrumentationActivitySource.Options == null || WcfInstrumentationActivitySource.Options.IncomingRequestFilter?.Invoke(request) == false)
{
- WcfInstrumentationEventSource.Log.RequestIsFilteredOut(request.Headers.Action);
+ WcfInstrumentationEventSource.Log.RequestIsFilteredOut();
return null;
}
}
@@ -55,7 +56,8 @@ public object AfterReceiveRequest(ref Message request, IClientChannel channel, I
return null;
}
- var ctx = WcfInstrumentationActivitySource.Options.Propagator.Extract(default, request, WcfInstrumentationActivitySource.MessageHeaderValuesGetter);
+ var textMapPropagator = Propagators.DefaultTextMapPropagator;
+ var ctx = textMapPropagator.Extract(default, request, WcfInstrumentationActivitySource.MessageHeaderValuesGetter);
Activity activity = WcfInstrumentationActivitySource.ActivitySource.StartActivity(
WcfInstrumentationActivitySource.IncomingRequestActivityName,
@@ -106,11 +108,11 @@ public object AfterReceiveRequest(ref Message request, IClientChannel channel, I
WcfInstrumentationEventSource.Log.EnrichmentException(ex);
}
}
- }
- if (ctx.Baggage != default)
- {
- Baggage.Current = ctx.Baggage;
+ if (!(textMapPropagator is TraceContextPropagator))
+ {
+ Baggage.Current = ctx.Baggage;
+ }
}
return activity;
@@ -119,8 +121,7 @@ public object AfterReceiveRequest(ref Message request, IClientChannel channel, I
///
public void BeforeSendReply(ref Message reply, object correlationState)
{
- Activity activity = (Activity)correlationState;
- if (activity != null)
+ if (correlationState is Activity activity)
{
if (activity.IsAllDataRequested)
{
@@ -141,6 +142,11 @@ public void BeforeSendReply(ref Message reply, object correlationState)
}
activity.Stop();
+
+ if (!(Propagators.DefaultTextMapPropagator is TraceContextPropagator))
+ {
+ Baggage.Current = default;
+ }
}
}
}
diff --git a/src/OpenTelemetry.Contrib.Instrumentation.Wcf/WcfEnrichEventNames.cs b/src/OpenTelemetry.Contrib.Instrumentation.Wcf/WcfEnrichEventNames.cs
index e96a67d03d..a4a175ce8f 100644
--- a/src/OpenTelemetry.Contrib.Instrumentation.Wcf/WcfEnrichEventNames.cs
+++ b/src/OpenTelemetry.Contrib.Instrumentation.Wcf/WcfEnrichEventNames.cs
@@ -19,7 +19,7 @@ namespace OpenTelemetry.Contrib.Instrumentation.Wcf
///
/// Constants used for event names when enriching an activity.
///
- public class WcfEnrichEventNames
+ public static class WcfEnrichEventNames
{
#if NETFRAMEWORK
///
diff --git a/src/OpenTelemetry.Contrib.Instrumentation.Wcf/WcfInstrumentationOptions.cs b/src/OpenTelemetry.Contrib.Instrumentation.Wcf/WcfInstrumentationOptions.cs
index 33bd21ae48..3e8a5510fb 100644
--- a/src/OpenTelemetry.Contrib.Instrumentation.Wcf/WcfInstrumentationOptions.cs
+++ b/src/OpenTelemetry.Contrib.Instrumentation.Wcf/WcfInstrumentationOptions.cs
@@ -17,7 +17,6 @@
using System;
using System.Diagnostics;
using System.ServiceModel.Channels;
-using OpenTelemetry.Context.Propagation;
namespace OpenTelemetry.Contrib.Instrumentation.Wcf
{
@@ -26,15 +25,6 @@ namespace OpenTelemetry.Contrib.Instrumentation.Wcf
///
public class WcfInstrumentationOptions
{
- ///
- /// Gets or sets for context propagation. Default value: with & .
- ///
- public TextMapPropagator Propagator { get; set; } = new CompositeTextMapPropagator(new TextMapPropagator[]
- {
- new TraceContextPropagator(),
- new BaggagePropagator(),
- });
-
///
/// Gets or sets an action to enrich an Activity.
///