@@ -126,11 +126,15 @@ public void Dispose()
126126 [ InlineData ( true , false , false ) ]
127127 [ InlineData ( false ) ]
128128 [ InlineData ( true , false , true , true ) ]
129+ [ InlineData ( true , false , true , true , true ) ]
130+ [ InlineData ( true , false , true , true , true , true ) ]
129131 public async Task OutgoingRequestInstrumentationTest (
130132 bool instrument ,
131133 bool filter = false ,
132134 bool suppressDownstreamInstrumentation = true ,
133- bool includeVersion = false )
135+ bool includeVersion = false ,
136+ bool enrich = false ,
137+ bool enrichmentException = false )
134138 {
135139#if NETFRAMEWORK
136140 const string OutgoingHttpOperationName = "OpenTelemetry.HttpWebRequest.HttpRequestOut" ;
@@ -147,10 +151,30 @@ public async Task OutgoingRequestInstrumentationTest(
147151 builder
148152 . AddWcfInstrumentation ( options =>
149153 {
150- options . OutgoingRequestFilter = ( Message m ) =>
154+ if ( enrich )
151155 {
152- return ! filter ;
153- } ;
156+ if ( ! enrichmentException )
157+ {
158+ options . Enrich = ( activity , eventName , message ) =>
159+ {
160+ switch ( eventName )
161+ {
162+ case WcfEnrichEventNames . BeforeSendRequest :
163+ activity . SetTag ( "client.beforesendrequest" , WcfEnrichEventNames . BeforeSendRequest ) ;
164+ break ;
165+ case WcfEnrichEventNames . AfterReceiveReply :
166+ activity . SetTag ( "client.afterreceivereply" , WcfEnrichEventNames . AfterReceiveReply ) ;
167+ break ;
168+ }
169+ } ;
170+ }
171+ else
172+ {
173+ options . Enrich = ( activity , eventName , message ) => throw new Exception ( "Error while enriching activity" ) ;
174+ }
175+ }
176+
177+ options . OutgoingRequestFilter = ( Message m ) => ! filter ;
154178 options . SuppressDownstreamInstrumentation = suppressDownstreamInstrumentation ;
155179 options . SetSoapMessageVersion = includeVersion ;
156180 } )
@@ -226,6 +250,12 @@ public async Task OutgoingRequestInstrumentationTest(
226250 {
227251 Assert . Equal ( "Soap11 (http://schemas.xmlsoap.org/soap/envelope/) AddressingNone (http://schemas.microsoft.com/ws/2005/05/addressing/none)" , activity . TagObjects . FirstOrDefault ( t => t . Key == WcfInstrumentationConstants . SoapMessageVersionTag ) . Value ) ;
228252 }
253+
254+ if ( enrich && ! enrichmentException )
255+ {
256+ Assert . Equal ( WcfEnrichEventNames . BeforeSendRequest , activity . TagObjects . Single ( t => t . Key == "client.beforesendrequest" ) . Value ) ;
257+ Assert . Equal ( WcfEnrichEventNames . AfterReceiveReply , activity . TagObjects . Single ( t => t . Key == "client.afterreceivereply" ) . Value ) ;
258+ }
229259 }
230260 else
231261 {
0 commit comments