Skip to content

Commit fd19e41

Browse files
author
Liudmila Molkova
committed
Only add ExecuteRequestStep in integrated piepline mode and swallow any exceptions
1 parent de3e627 commit fd19e41

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/Microsoft.AspNet.TelemetryCorrelation/AspNetTelemetryCorrelationEventSource.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ public void ActivityRestored(string id)
6464
{
6565
WriteEvent(8, id);
6666
}
67+
68+
[Event(9, Message = "Failed to invoke OnExecuteRequestStep, Error='{0}'", Level = EventLevel.Error)]
69+
public void OnExecuteRequestStepInvokationError(string error)
70+
{
71+
WriteEvent(9, error);
72+
}
6773
}
6874
}
6975
#pragma warning restore SA1600 // Elements must be documented

src/Microsoft.AspNet.TelemetryCorrelation/TelemetryCorrelationHttpModule.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,16 @@ public void Init(HttpApplication context)
3535
// OnExecuteRequestStep is availabile starting with 4.7.1
3636
// If this is executed in 4.7.1 runtime (regardless of targeted .NET version),
3737
// we will use it to restore lost activity, otherwise keep PreRequestHandlerExecute
38-
if (onStepMethodInfo != null)
38+
if (onStepMethodInfo != null && HttpRuntime.UsingIntegratedPipeline)
3939
{
40-
onStepMethodInfo.Invoke(context, new object[] { (Action<HttpContextBase, Action>)OnExecuteRequestStep });
40+
try
41+
{
42+
onStepMethodInfo.Invoke(context, new object[] { (Action<HttpContextBase, Action>)OnExecuteRequestStep });
43+
}
44+
catch (Exception e)
45+
{
46+
AspNetTelemetryCorrelationEventSource.Log.OnExecuteRequestStepInvokationError(e.Message);
47+
}
4148
}
4249
else
4350
{

tools/Microsoft.AspNet.TelemetryCorrelation.settings.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<VersionStartYear>2018</VersionStartYear>
77
<VersionMajor>1</VersionMajor>
88
<VersionMinor>0</VersionMinor>
9-
<VersionRelease>2</VersionRelease>
9+
<VersionRelease>3</VersionRelease>
1010
<VersionRelease Condition="'$(BuildQuality)' != 'rtm'">$(VersionRelease)-$(BuildQuality)</VersionRelease>
1111
</PropertyGroup>
1212

0 commit comments

Comments
 (0)