diff --git a/Datadog.Trace.sln b/Datadog.Trace.sln index b149bcede..696a87aae 100644 --- a/Datadog.Trace.sln +++ b/Datadog.Trace.sln @@ -436,7 +436,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.Telemetry", "tracer EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sandbox.AutomaticInstrumentation", "tracer\test\test-applications\regression\Sandbox.AutomaticInstrumentation\Sandbox.AutomaticInstrumentation.csproj", "{10619BA2-AED1-482A-8570-BB7C7B83DDDC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Datadog.Trace.Coverage.collector", "tracer\src\Datadog.Trace.Coverage.collector\Datadog.Trace.Coverage.collector.csproj", "{7A0D8A39-C60D-4BA1-93AB-D429080BBFA5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.Trace.Coverage.collector", "tracer\src\Datadog.Trace.Coverage.collector\Datadog.Trace.Coverage.collector.csproj", "{7A0D8A39-C60D-4BA1-93AB-D429080BBFA5}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.TraceAnnotations", "tracer\test\test-applications\integrations\Samples.TraceAnnotations\Samples.TraceAnnotations.csproj", "{230A9B80-E1AA-469F-86F2-B7E257F14E66}" EndProject @@ -468,16 +468,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.InstrumentedAssembl EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.InstrumentedAssemblyVerification.Standalone", "tracer\src\Datadog.InstrumentedAssemblyVerification.Standalone\Datadog.InstrumentedAssemblyVerification.Standalone.csproj", "{61FD6A7E-38EB-4B90-A890-DE3205C041B1}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.AspNetMvc5CustomException", "tracer\test\test-applications\aspnet\Samples.AspNetMvc5CustomException\Samples.AspNetMvc5CustomException.csproj", "{F71B1B2D-C3E0-49B6-AC29-B96F45E12D5E}" +EndProject Global - GlobalSection(SharedMSBuildProjectFiles) = preSolution - tracer\test\test-applications\Samples.Shared\Samples.Shared.projitems*{3c6dd42e-9214-4747-92ba-78de29aace59}*SharedItemsImports = 4 - tracer\test\test-applications\Samples.Shared\Samples.Shared.projitems*{6d86109f-b7c9-477d-86d7-45735a3a0818}*SharedItemsImports = 4 - tracer\test\test-applications\Samples.Shared\Samples.Shared.projitems*{7b0822f6-80de-4b49-8125-93975678d0d5}*SharedItemsImports = 4 - tracer\test\test-applications\Samples.Shared\Samples.Shared.projitems*{99a62ccf-8e7f-4d57-8383-d38c371c8087}*SharedItemsImports = 4 - tracer\test\test-applications\Samples.Shared\Samples.Shared.projitems*{b6a98887-4a47-4c19-9c6f-d833e24f4b1c}*SharedItemsImports = 4 - tracer\test\test-applications\Samples.Shared\Samples.Shared.projitems*{bbb60b0f-bf01-4499-936a-4a299a9acfd4}*SharedItemsImports = 4 - tracer\test\test-applications\Samples.Shared\Samples.Shared.projitems*{fab2b108-e5be-4647-869b-1dc5d362252e}*SharedItemsImports = 4 - EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 @@ -2251,6 +2244,30 @@ Global {47DA933E-8DBC-4B03-A1D1-2BBE5F4D0D70}.Release|x64.Build.0 = Release|x64 {47DA933E-8DBC-4B03-A1D1-2BBE5F4D0D70}.Release|x86.ActiveCfg = Release|Win32 {47DA933E-8DBC-4B03-A1D1-2BBE5F4D0D70}.Release|x86.Build.0 = Release|Win32 + {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Debug|x64.ActiveCfg = Debug|Any CPU + {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Debug|x64.Build.0 = Debug|Any CPU + {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Debug|x86.ActiveCfg = Debug|Any CPU + {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Debug|x86.Build.0 = Debug|Any CPU + {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Release|Any CPU.Build.0 = Release|Any CPU + {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Release|x64.ActiveCfg = Release|Any CPU + {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Release|x64.Build.0 = Release|Any CPU + {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Release|x86.ActiveCfg = Release|Any CPU + {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Release|x86.Build.0 = Release|Any CPU + {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Debug|Any CPU.ActiveCfg = Debug|x64 + {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Debug|Any CPU.Build.0 = Debug|x64 + {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Debug|x64.ActiveCfg = Debug|x64 + {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Debug|x64.Build.0 = Debug|x64 + {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Debug|x86.ActiveCfg = Debug|x86 + {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Debug|x86.Build.0 = Debug|x86 + {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Release|Any CPU.ActiveCfg = Release|x64 + {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Release|Any CPU.Build.0 = Release|x64 + {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Release|x64.ActiveCfg = Release|x64 + {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Release|x64.Build.0 = Release|x64 + {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Release|x86.ActiveCfg = Release|x86 + {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Release|x86.Build.0 = Release|x86 {CD816C0C-D116-49A1-93A7-8095594224EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CD816C0C-D116-49A1-93A7-8095594224EB}.Debug|Any CPU.Build.0 = Debug|Any CPU {CD816C0C-D116-49A1-93A7-8095594224EB}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -2287,42 +2304,18 @@ Global {61FD6A7E-38EB-4B90-A890-DE3205C041B1}.Release|x64.Build.0 = Release|Any CPU {61FD6A7E-38EB-4B90-A890-DE3205C041B1}.Release|x86.ActiveCfg = Release|Any CPU {61FD6A7E-38EB-4B90-A890-DE3205C041B1}.Release|x86.Build.0 = Release|Any CPU - {F6A03B6C-EBF9-4581-9904-EDC7270CF3BD}.Debug|Any CPU.ActiveCfg = Debug|x64 - {F6A03B6C-EBF9-4581-9904-EDC7270CF3BD}.Debug|Any CPU.Build.0 = Debug|x64 - {F6A03B6C-EBF9-4581-9904-EDC7270CF3BD}.Debug|x64.ActiveCfg = Debug|x64 - {F6A03B6C-EBF9-4581-9904-EDC7270CF3BD}.Debug|x64.Build.0 = Debug|x64 - {F6A03B6C-EBF9-4581-9904-EDC7270CF3BD}.Debug|x86.ActiveCfg = Debug|x86 - {F6A03B6C-EBF9-4581-9904-EDC7270CF3BD}.Debug|x86.Build.0 = Debug|x86 - {F6A03B6C-EBF9-4581-9904-EDC7270CF3BD}.Release|Any CPU.ActiveCfg = Release|x64 - {F6A03B6C-EBF9-4581-9904-EDC7270CF3BD}.Release|Any CPU.Build.0 = Release|x64 - {F6A03B6C-EBF9-4581-9904-EDC7270CF3BD}.Release|x64.ActiveCfg = Release|x64 - {F6A03B6C-EBF9-4581-9904-EDC7270CF3BD}.Release|x64.Build.0 = Release|x64 - {F6A03B6C-EBF9-4581-9904-EDC7270CF3BD}.Release|x86.ActiveCfg = Release|x86 - {F6A03B6C-EBF9-4581-9904-EDC7270CF3BD}.Release|x86.Build.0 = Release|x86 - {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Debug|x64.ActiveCfg = Debug|Any CPU - {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Debug|x64.Build.0 = Debug|Any CPU - {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Debug|x86.ActiveCfg = Debug|Any CPU - {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Debug|x86.Build.0 = Debug|Any CPU - {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Release|Any CPU.Build.0 = Release|Any CPU - {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Release|x64.ActiveCfg = Release|Any CPU - {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Release|x64.Build.0 = Release|Any CPU - {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Release|x86.ActiveCfg = Release|Any CPU - {4067EAF6-28C5-4B04-9C8A-80720C0541E6}.Release|x86.Build.0 = Release|Any CPU - {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Debug|Any CPU.ActiveCfg = Debug|x64 - {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Debug|Any CPU.Build.0 = Debug|x64 - {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Debug|x64.ActiveCfg = Debug|x64 - {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Debug|x64.Build.0 = Debug|x64 - {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Debug|x86.ActiveCfg = Debug|x86 - {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Debug|x86.Build.0 = Debug|x86 - {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Release|Any CPU.ActiveCfg = Release|x64 - {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Release|Any CPU.Build.0 = Release|x64 - {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Release|x64.ActiveCfg = Release|x64 - {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Release|x64.Build.0 = Release|x64 - {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Release|x86.ActiveCfg = Release|x86 - {C4CDF6A6-40E5-4CCD-AC4C-143F9F4398CA}.Release|x86.Build.0 = Release|x86 + {F71B1B2D-C3E0-49B6-AC29-B96F45E12D5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F71B1B2D-C3E0-49B6-AC29-B96F45E12D5E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F71B1B2D-C3E0-49B6-AC29-B96F45E12D5E}.Debug|x64.ActiveCfg = Debug|Any CPU + {F71B1B2D-C3E0-49B6-AC29-B96F45E12D5E}.Debug|x64.Build.0 = Debug|Any CPU + {F71B1B2D-C3E0-49B6-AC29-B96F45E12D5E}.Debug|x86.ActiveCfg = Debug|Any CPU + {F71B1B2D-C3E0-49B6-AC29-B96F45E12D5E}.Debug|x86.Build.0 = Debug|Any CPU + {F71B1B2D-C3E0-49B6-AC29-B96F45E12D5E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F71B1B2D-C3E0-49B6-AC29-B96F45E12D5E}.Release|Any CPU.Build.0 = Release|Any CPU + {F71B1B2D-C3E0-49B6-AC29-B96F45E12D5E}.Release|x64.ActiveCfg = Release|Any CPU + {F71B1B2D-C3E0-49B6-AC29-B96F45E12D5E}.Release|x64.Build.0 = Release|Any CPU + {F71B1B2D-C3E0-49B6-AC29-B96F45E12D5E}.Release|x86.ActiveCfg = Release|Any CPU + {F71B1B2D-C3E0-49B6-AC29-B96F45E12D5E}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2495,8 +2488,19 @@ Global {CD816C0C-D116-49A1-93A7-8095594224EB} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB} {FCE813DE-7BF2-4F63-8303-E92F90780C81} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB} {61FD6A7E-38EB-4B90-A890-DE3205C041B1} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB} + {F71B1B2D-C3E0-49B6-AC29-B96F45E12D5E} = {AFA0AB23-64F0-4AC1-9050-6CE8FE06F580} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {160A1D00-1F5B-40F8-A155-621B4459D78F} EndGlobalSection + GlobalSection(SharedMSBuildProjectFiles) = preSolution + tracer\test\test-applications\Samples.Shared\Samples.Shared.projitems*{3c6dd42e-9214-4747-92ba-78de29aace59}*SharedItemsImports = 4 + tracer\test\test-applications\Samples.Shared\Samples.Shared.projitems*{6d86109f-b7c9-477d-86d7-45735a3a0818}*SharedItemsImports = 4 + tracer\test\test-applications\Samples.Shared\Samples.Shared.projitems*{7b0822f6-80de-4b49-8125-93975678d0d5}*SharedItemsImports = 4 + tracer\test\test-applications\Samples.Shared\Samples.Shared.projitems*{99a62ccf-8e7f-4d57-8383-d38c371c8087}*SharedItemsImports = 4 + tracer\test\test-applications\Samples.Shared\Samples.Shared.projitems*{b6a98887-4a47-4c19-9c6f-d833e24f4b1c}*SharedItemsImports = 4 + tracer\test\test-applications\Samples.Shared\Samples.Shared.projitems*{bbb60b0f-bf01-4499-936a-4a299a9acfd4}*SharedItemsImports = 4 + tracer\test\test-applications\Samples.Shared\Samples.Shared.projitems*{f71b1b2d-c3e0-49b6-ac29-b96f45e12d5e}*SharedItemsImports = 4 + tracer\test\test-applications\Samples.Shared\Samples.Shared.projitems*{fab2b108-e5be-4647-869b-1dc5d362252e}*SharedItemsImports = 4 + EndGlobalSection EndGlobal diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 798a44d66..ad030df30 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -15,6 +15,9 @@ and this repository adheres to [Semantic Versioning](https://semver.org/spec/v2. ### Bugfixes +- [ASP.NET Web API 2 Instrumentation] Fix the case when the spans was + incorrectly marked as errors when servers return 404 status code. + ### Enhancements ## [Release 0.2.7](https://github.com/signalfx/signalfx-dotnet-tracing/releases/tag/v0.2.7) diff --git a/tracer/src/Datadog.Trace/AspNet/SharedItems.cs b/tracer/src/Datadog.Trace/AspNet/SharedItems.cs index 522ac1c39..ea9f487e8 100644 --- a/tracer/src/Datadog.Trace/AspNet/SharedItems.cs +++ b/tracer/src/Datadog.Trace/AspNet/SharedItems.cs @@ -16,6 +16,7 @@ namespace Datadog.Trace.AspNet internal static class SharedItems { public const string HttpContextPropagatedResourceNameKey = "__SignalFx.Tracing.ClrProfiler.Managed.AspNetMvcIntegration-aspnet.resourcename"; + public const string HttpContextPropagatedExceptionKey = "__SignalFx.Tracing.ClrProfiler.Managed.AspNetMvcIntegration-aspnet.exception"; private static readonly Func, Scope> Pop = stack => stack.Pop(); private static readonly Func, Scope> Peek = stack => stack.Peek(); diff --git a/tracer/src/Datadog.Trace/AspNet/TracingHttpModule.cs b/tracer/src/Datadog.Trace/AspNet/TracingHttpModule.cs index be980a8a9..b321cb0f2 100644 --- a/tracer/src/Datadog.Trace/AspNet/TracingHttpModule.cs +++ b/tracer/src/Datadog.Trace/AspNet/TracingHttpModule.cs @@ -210,6 +210,11 @@ private void OnEndRequest(object sender, EventArgs eventArgs) scope.Span.ResourceName = $"{app.Request.HttpMethod.ToUpperInvariant()} {path.ToLowerInvariant()}"; } + if (app.Context.Items[SharedItems.HttpContextPropagatedExceptionKey] is Exception exception && app.Context.Response.StatusCode != 404) + { + scope.Span.SetException(exception); + } + scope.Dispose(); } finally @@ -240,9 +245,8 @@ private void OnError(object sender, EventArgs eventArgs) var httpContext = (sender as HttpApplication)?.Context; var exception = httpContext?.Error; - // We want to ignore 404 exceptions here, as they are not errors - var httpException = exception as HttpException; - var is404 = httpException?.GetHttpCode() == 404; + // We want to ignore 404 code as it is not an error + var is404 = httpContext?.Response.StatusCode == 404; if (httpContext?.Items[_httpContextScopeKey] is Scope scope) { diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ApiController_ExecuteAsync_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ApiController_ExecuteAsync_Integration.cs index ceb1cd91c..28b6b5159 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ApiController_ExecuteAsync_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ApiController_ExecuteAsync_Integration.cs @@ -3,6 +3,8 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // +// Modified by Splunk Inc. + #if NETFRAMEWORK using System; using System.Collections.Generic; @@ -99,8 +101,6 @@ internal static TResponse OnAsyncMethodEnd(TTarget instance, if (exception != null) { - scope.Span.SetException(exception); - // We don't have access to the final status code at this point // Ask the HttpContext to call us back to that we can get it if (httpContext != null) @@ -111,7 +111,7 @@ internal static TResponse OnAsyncMethodEnd(TTarget instance, // us to defer finishing the span later while making sure callers of this method do not // get this scope when calling Tracer.ActiveScope var now = scope.Span.Context.TraceContext.UtcNow; - httpContext.AddOnRequestCompleted(h => OnRequestCompletedAfterException(h, scope, now)); + httpContext.AddOnRequestCompleted(h => OnRequestCompletedAfterException(h, scope, now, exception)); scope.SetFinishOnClose(false); scope.Dispose(); @@ -119,6 +119,7 @@ internal static TResponse OnAsyncMethodEnd(TTarget instance, else { // Looks like we won't be able to get the final status code + scope.Span.SetException(exception); scope.Dispose(); } } @@ -132,8 +133,13 @@ internal static TResponse OnAsyncMethodEnd(TTarget instance, return responseMessage; } - private static void OnRequestCompletedAfterException(HttpContext httpContext, Scope scope, DateTimeOffset finishTime) + private static void OnRequestCompletedAfterException(HttpContext httpContext, Scope scope, DateTimeOffset finishTime, Exception exception) { + if (httpContext.Response.StatusCode != 404) + { + scope.Span.SetException(exception); + } + HttpContextHelper.AddHeaderTagsFromHttpResponse(httpContext, scope); scope.Span.SetHttpStatusCode(httpContext.Response.StatusCode, isServer: true, Tracer.Instance.Settings); scope.Span.Finish(finishTime); diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/AsyncControllerActionInvoker_EndInvokeAction_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/AsyncControllerActionInvoker_EndInvokeAction_Integration.cs index bc63410ab..11abe8c83 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/AsyncControllerActionInvoker_EndInvokeAction_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/AsyncControllerActionInvoker_EndInvokeAction_Integration.cs @@ -68,8 +68,6 @@ internal static CallTargetReturn OnMethodEnd(TTarget { if (exception != null) { - scope.Span.SetException(exception); - // In case of exception, the status code is set further down the ASP.NET pipeline // We use the OnRequestCompleted callback to be notified when that happens. // We don't know how long it'll take for ASP.NET to invoke the callback, @@ -78,7 +76,7 @@ internal static CallTargetReturn OnMethodEnd(TTarget // us to defer finishing the span later while making sure callers of this method do not // get this scope when calling Tracer.ActiveScope var now = scope.Span.Context.TraceContext.UtcNow; - httpContext.AddOnRequestCompleted(h => OnRequestCompletedAfterException(h, scope, now)); + httpContext.AddOnRequestCompleted(h => OnRequestCompletedAfterException(h, scope, now, exception)); scope.SetFinishOnClose(false); scope.Dispose(); @@ -94,8 +92,13 @@ internal static CallTargetReturn OnMethodEnd(TTarget return new CallTargetReturn(returnValue); } - private static void OnRequestCompletedAfterException(HttpContext httpContext, Scope scope, DateTimeOffset finishTime) + private static void OnRequestCompletedAfterException(HttpContext httpContext, Scope scope, DateTimeOffset finishTime, Exception exception) { + if (httpContext.Response.StatusCode != 404) + { + scope.Span.SetException(exception); + } + HttpContextHelper.AddHeaderTagsFromHttpResponse(httpContext, scope); if (!HttpRuntime.UsingIntegratedPipeline && httpContext.Response.StatusCode == 200) diff --git a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ExceptionHandlerExtensions_HandleAsync_Integration.cs b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ExceptionHandlerExtensions_HandleAsync_Integration.cs index 940b7b64c..5e6b936a2 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ExceptionHandlerExtensions_HandleAsync_Integration.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AspNet/ExceptionHandlerExtensions_HandleAsync_Integration.cs @@ -3,10 +3,13 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // +// Modified by Splunk Inc. + #if NETFRAMEWORK using System.ComponentModel; using System.Threading; +using Datadog.Trace.AspNet; using Datadog.Trace.ClrProfiler.CallTarget; using Datadog.Trace.Configuration; @@ -51,11 +54,12 @@ internal static CallTargetState OnMethodBegin +// Modified by Splunk Inc. + #if NET461 #pragma warning disable SA1402 // File may only contain a single class #pragma warning disable SA1649 // File name must match first type name diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/AspNetWebApi2Tests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/AspNetWebApi2Tests.cs index bb035003c..8670f9333 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/AspNetWebApi2Tests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNet/AspNetWebApi2Tests.cs @@ -3,12 +3,13 @@ // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // +// Modified by Splunk Inc. + #if NET461 #pragma warning disable SA1402 // File may only contain a single class #pragma warning disable SA1649 // File name must match first type name using System.Net; -using System.Runtime.InteropServices; using System.Threading.Tasks; using Datadog.Trace.Configuration; using Datadog.Trace.TestHelpers; @@ -205,6 +206,70 @@ await Verifier.Verify(spans, settings) } } + [Collection("IisTests")] + public class AspNetWebApi2TestsCustomExceptionCallTargetClassic : AspNetWebApi2CustomExceptionTests + { + public AspNetWebApi2TestsCustomExceptionCallTargetClassic(IisFixture iisFixture, ITestOutputHelper output) + : base(iisFixture, output, classicMode: true) + { + } + } + + [Collection("IisTests")] + public class AspNetWebApi2TestsCustomExceptionCallTargetIntegrated : AspNetWebApi2CustomExceptionTests + { + public AspNetWebApi2TestsCustomExceptionCallTargetIntegrated(IisFixture iisFixture, ITestOutputHelper output) + : base(iisFixture, output, classicMode: false) + { + } + } + + [UsesVerify] + public abstract class AspNetWebApi2CustomExceptionTests : TestHelper, IClassFixture + { + private readonly IisFixture _iisFixture; + private readonly string _testName; + + public AspNetWebApi2CustomExceptionTests(IisFixture iisFixture, ITestOutputHelper output, bool classicMode) + : base("AspNetMvc5CustomException", @"test\test-applications\aspnet", output) + { + SetServiceVersion("1.0.0"); + + _iisFixture = iisFixture; + _iisFixture.ShutdownPath = "/home/shutdown"; + + _iisFixture.TryStartIis(this, classicMode ? IisAppType.AspNetClassic : IisAppType.AspNetIntegrated); + _testName = nameof(AspNetWebApi2CustomExceptionTests) + + (classicMode ? ".Classic" : ".Integrated"); + } + + public static TheoryData Data() => new() + { + { "/api2/ThrowCustomNotFoundException", 404, 2 }, + }; + + [SkippableTheory] + [Trait("Category", "EndToEnd")] + [Trait("RunOnWindows", "True")] + [Trait("LoadFromGAC", "True")] + [MemberData(nameof(Data))] + public async Task SubmitsTraces(string path, HttpStatusCode statusCode, int expectedSpanCount) + { + // Append virtual directory to the actual request + var spans = await GetWebServerSpans(_iisFixture.VirtualApplicationPath + path, _iisFixture.Agent, _iisFixture.HttpPort, statusCode, expectedSpanCount); + + var sanitisedPath = VerifyHelper.SanitisePathsForVerify(path); + + var settings = VerifyHelper.GetSpanVerifierSettings(sanitisedPath, (int)statusCode); + + // Overriding the type name here as we have multiple test classes in the file + // Overriding the method name to _ + // Overriding the parameters to remove the expectedSpanCount parameter, which is necessary for operation but unnecessary for the filename + await Verifier.Verify(spans, settings) + .UseFileName($"{_testName}.__path={sanitisedPath}_statusCode={(int)statusCode}"); + } + } + [UsesVerify] public abstract class AspNetWebApi2ModuleOnlyTests : TestHelper, IClassFixture { diff --git a/tracer/test/snapshots/AspNetWebApi2CustomExceptionTests.Classic.__path=_api2_ThrowCustomNotFoundException_statusCode=404.verified.txt b/tracer/test/snapshots/AspNetWebApi2CustomExceptionTests.Classic.__path=_api2_ThrowCustomNotFoundException_statusCode=404.verified.txt new file mode 100644 index 000000000..ac14a7bb8 --- /dev/null +++ b/tracer/test/snapshots/AspNetWebApi2CustomExceptionTests.Classic.__path=_api2_ThrowCustomNotFoundException_statusCode=404.verified.txt @@ -0,0 +1,56 @@ +[ + { + TraceId: Id_1, + SpanId: Id_2, + Name: GET /api2/throwcustomnotfoundexception/{value}, + LogicScope: aspnet.request, + Resource: GET /api2/throwcustomnotfoundexception/{value}, + Service: sample, + Type: web, + Tags: { + deployment.environment: integration_tests, + http.method: GET, + http.request.headers.host: localhost:00000, + http.status_code: 404, + http.url: http://localhost:00000/api2/ThrowCustomNotFoundException, + language: dotnet, + net.peer.ip: ::1, + runtime-id: Guid_1, + signalfx.tracing.library: dotnet-tracing, + signalfx.tracing.version: x.y.z, + span.kind: server, + version: 1.0.0 + }, + Metrics: { + process_id: 0, + _dd.agent_psr: 1.0, + _dd.top_level: 1.0, + _dd.tracer_kr: 1.0, + _sampling_priority_v1: 1.0 + } + }, + { + TraceId: Id_1, + SpanId: Id_3, + Name: GET /api2/throwcustomnotfoundexception/{value}, + LogicScope: aspnet-webapi.request, + Resource: GET /api2/throwcustomnotfoundexception/{value}, + Service: sample, + Type: web, + ParentId: Id_2, + Tags: { + aspnet.action: throwcustomnotfoundexception, + aspnet.controller: conventions, + aspnet.route: api2/{action}/{value}, + deployment.environment: integration_tests, + http.method: GET, + http.request.headers.host: localhost:00000, + http.status_code: 404, + http.url: http://localhost:00000/api2/ThrowCustomNotFoundException, + language: dotnet, + net.peer.ip: ::1, + span.kind: server, + version: 1.0.0 + } + } +] \ No newline at end of file diff --git a/tracer/test/snapshots/AspNetWebApi2CustomExceptionTests.Integrated.__path=_api2_ThrowCustomNotFoundException_statusCode=404.verified.txt b/tracer/test/snapshots/AspNetWebApi2CustomExceptionTests.Integrated.__path=_api2_ThrowCustomNotFoundException_statusCode=404.verified.txt new file mode 100644 index 000000000..ac14a7bb8 --- /dev/null +++ b/tracer/test/snapshots/AspNetWebApi2CustomExceptionTests.Integrated.__path=_api2_ThrowCustomNotFoundException_statusCode=404.verified.txt @@ -0,0 +1,56 @@ +[ + { + TraceId: Id_1, + SpanId: Id_2, + Name: GET /api2/throwcustomnotfoundexception/{value}, + LogicScope: aspnet.request, + Resource: GET /api2/throwcustomnotfoundexception/{value}, + Service: sample, + Type: web, + Tags: { + deployment.environment: integration_tests, + http.method: GET, + http.request.headers.host: localhost:00000, + http.status_code: 404, + http.url: http://localhost:00000/api2/ThrowCustomNotFoundException, + language: dotnet, + net.peer.ip: ::1, + runtime-id: Guid_1, + signalfx.tracing.library: dotnet-tracing, + signalfx.tracing.version: x.y.z, + span.kind: server, + version: 1.0.0 + }, + Metrics: { + process_id: 0, + _dd.agent_psr: 1.0, + _dd.top_level: 1.0, + _dd.tracer_kr: 1.0, + _sampling_priority_v1: 1.0 + } + }, + { + TraceId: Id_1, + SpanId: Id_3, + Name: GET /api2/throwcustomnotfoundexception/{value}, + LogicScope: aspnet-webapi.request, + Resource: GET /api2/throwcustomnotfoundexception/{value}, + Service: sample, + Type: web, + ParentId: Id_2, + Tags: { + aspnet.action: throwcustomnotfoundexception, + aspnet.controller: conventions, + aspnet.route: api2/{action}/{value}, + deployment.environment: integration_tests, + http.method: GET, + http.request.headers.host: localhost:00000, + http.status_code: 404, + http.url: http://localhost:00000/api2/ThrowCustomNotFoundException, + language: dotnet, + net.peer.ip: ::1, + span.kind: server, + version: 1.0.0 + } + } +] \ No newline at end of file diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/App_Start/RouteConfig.cs b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/App_Start/RouteConfig.cs new file mode 100644 index 000000000..15ec8c624 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/App_Start/RouteConfig.cs @@ -0,0 +1,25 @@ +// Modified by Splunk Inc. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using System.Web.Routing; + +namespace Samples.AspNetMvc5CustomException +{ + public class RouteConfig + { + public static void RegisterRoutes(RouteCollection routes) + { + routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); + + routes.MapRoute( + name: "Default", + url: "{controller}/{action}/{id}", + defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } + ); + } + } +} diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/App_Start/WebApiConfig.cs b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/App_Start/WebApiConfig.cs new file mode 100644 index 000000000..a2f930823 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/App_Start/WebApiConfig.cs @@ -0,0 +1,31 @@ +// Modified by Splunk Inc. + +using System.Web.Http; +using Samples.AspNetMvc5CustomException.Handlers; + +namespace Samples.AspNetMvc5CustomException +{ + public static class WebApiConfig + { + public static void Register(HttpConfiguration config) + { + // Web API configuration and services + + // Web API routes + config.MapHttpAttributeRoutes(); + + + // Add global message handler + config.MessageHandlers.Add(new CustomNotFoundExceptionMessageHandler()); + + config.Routes.MapHttpRoute( + name: "ApiConventions", + routeTemplate: "api2/{action}/{value}", + defaults: new + { + controller = "Conventions", + value = RouteParameter.Optional + }); + } + } +} diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Controllers/ConventionsController.cs b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Controllers/ConventionsController.cs new file mode 100644 index 000000000..f439f5796 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Controllers/ConventionsController.cs @@ -0,0 +1,16 @@ +// Modified by Splunk Inc. + +using System.Web.Http; +using Samples.AspNetMvc5CustomException.Data; + +namespace Samples.AspNetMvc5CustomException.Controllers +{ + public class ConventionsController : ApiController + { + [HttpGet] + public IHttpActionResult ThrowCustomNotFoundException() + { + throw new CustomNotFoundException(); + } + } +} diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Controllers/HomeController.cs b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Controllers/HomeController.cs new file mode 100644 index 000000000..a3e52e211 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Controllers/HomeController.cs @@ -0,0 +1,24 @@ +// Modified by Splunk Inc. + +using System.Linq; +using System.Web.Mvc; + +namespace Samples.AspNetMvc5.Controllers +{ + public class HomeController : Controller + { + public ActionResult Index() + { + var envVars = SampleHelpers.GetDatadogEnvironmentVariables(); + + return View(envVars.ToList()); + } + + public ActionResult Shutdown() + { + SampleHelpers.RunShutDownTasks(this); + + return RedirectToAction("Index"); + } + } +} diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Data/CustomNotFoundException.cs b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Data/CustomNotFoundException.cs new file mode 100644 index 000000000..7a721220e --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Data/CustomNotFoundException.cs @@ -0,0 +1,10 @@ +// Modified by Splunk Inc. + +using System; + +namespace Samples.AspNetMvc5CustomException.Data +{ + public class CustomNotFoundException : Exception + { + } +} diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Global.asax b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Global.asax new file mode 100644 index 000000000..aa5d1f113 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Global.asax @@ -0,0 +1 @@ +<%@ Application Codebehind="Global.asax.cs" Inherits="Samples.AspNetMvc5CustomException.MvcApplication" Language="C#" %> diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Global.asax.cs b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Global.asax.cs new file mode 100644 index 000000000..1b5b7e90a --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Global.asax.cs @@ -0,0 +1,20 @@ +// Modified by Splunk Inc. + +using System.Web; +using System.Web.Mvc; +using System.Web.Routing; +using System.Web.Http; +using System; + +namespace Samples.AspNetMvc5CustomException +{ + public class MvcApplication : HttpApplication + { + protected void Application_Start() + { + GlobalConfiguration.Configure(WebApiConfig.Register); + AreaRegistration.RegisterAllAreas(); + RouteConfig.RegisterRoutes(RouteTable.Routes); + } + } +} diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Handlers/CustomNotFoundExceptionMessageHandler.cs b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Handlers/CustomNotFoundExceptionMessageHandler.cs new file mode 100644 index 000000000..6a7efb25d --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Handlers/CustomNotFoundExceptionMessageHandler.cs @@ -0,0 +1,19 @@ +// Modified by Splunk Inc. + +using System.Net; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; + +namespace Samples.AspNetMvc5CustomException.Handlers +{ + public class CustomNotFoundExceptionMessageHandler : DelegatingHandler + { + protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + var response = await base.SendAsync(request, cancellationToken); + response.StatusCode = HttpStatusCode.NotFound; + return response; + } + } +} diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Properties/AssemblyInfo.cs b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..e752c8c66 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Properties/AssemblyInfo.cs @@ -0,0 +1,37 @@ +// Modified by Splunk Inc. + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Samples.AspNetMvc5CustomException")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Samples.AspNetMvc5CustomException")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("d4bcbb48-f351-4d97-8a98-1b77862b62c6")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Samples.AspNetMvc5CustomException.csproj b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Samples.AspNetMvc5CustomException.csproj new file mode 100644 index 000000000..aa0ada386 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Samples.AspNetMvc5CustomException.csproj @@ -0,0 +1,231 @@ + + + + + + Debug + x64 + + + 2.0 + {F71B1B2D-C3E0-49B6-AC29-B96F45E12D5E} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + Samples.AspNetMvc5CustomException + Samples.AspNetMvc5CustomException + v4.6.1 + true + true + + + + + + + + + + + + ..\..\..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\..\..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + ..\..\..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll + + + + ..\..\..\..\..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + + + + + ..\..\..\..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll + + + + + + + + + + ..\..\..\..\..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.Helpers.dll + + + ..\..\..\..\..\packages\Microsoft.AspNet.WebApi.Core.5.1.2\lib\net45\System.Web.Http.dll + + + ..\..\..\..\..\packages\Microsoft.AspNet.WebApi.Tracing.5.1.2\lib\net45\System.Web.Http.Tracing.dll + + + ..\..\..\..\..\packages\Microsoft.AspNet.WebApi.WebHost.5.1.2\lib\net45\System.Web.Http.WebHost.dll + + + ..\..\..\..\..\packages\Microsoft.AspNet.Mvc.5.2.7\lib\net45\System.Web.Mvc.dll + + + ..\..\..\..\..\packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll + + + ..\..\..\..\..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.dll + + + ..\..\..\..\..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Deployment.dll + + + ..\..\..\..\..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Razor.dll + + + + + + + + + + + + ..\..\..\..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll + + + + + + + + + + + + + + Global.asax + + + + + + + + + + + + + + + + + + + Web.config + + + Web.config + + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + AnyCPU + bin\ + DEBUG;TRACE + prompt + full + true + MinimumRecommendedRules.ruleset + + + AnyCPU + bin\ + true + TRACE + prompt + pdbonly + true + MinimumRecommendedRules.ruleset + + + true + bin\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + + + true + bin\ + TRACE + true + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + + + true + bin\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + + + true + bin\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + + + true + + + + + + + + + True + True + 50449 + / + http://localhost:50449/ + False + False + + + False + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Contacts/Create.cshtml b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Contacts/Create.cshtml new file mode 100644 index 000000000..8058def6a --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Contacts/Create.cshtml @@ -0,0 +1,43 @@ +@model Samples.AspNetMvc5.Data.Contact + +@{ + ViewBag.Title = "Create"; +} + +

Create

+ +@using (Html.BeginForm()) +{ + @Html.AntiForgeryToken() + +
+

Contact

+
+ @Html.ValidationSummary(true, "", new { @class = "text-danger" }) +
+ @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" }) +
+ @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } }) + @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" }) +
+
+ +
+ @Html.LabelFor(model => model.EmailAddress, htmlAttributes: new { @class = "control-label col-md-2" }) +
+ @Html.EditorFor(model => model.EmailAddress, new { htmlAttributes = new { @class = "form-control" } }) + @Html.ValidationMessageFor(model => model.EmailAddress, "", new { @class = "text-danger" }) +
+
+ +
+
+ +
+
+
+} + +
+ @Html.ActionLink("Back to List", "Index") +
diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Contacts/Delete.cshtml b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Contacts/Delete.cshtml new file mode 100644 index 000000000..d8c83dad9 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Contacts/Delete.cshtml @@ -0,0 +1,40 @@ +@model Samples.AspNetMvc5.Data.Contact + +@{ + ViewBag.Title = "Delete"; +} + +

Delete

+ +

Are you sure you want to delete this?

+
+

Contact

+
+
+
+ @Html.DisplayNameFor(model => model.Name) +
+ +
+ @Html.DisplayFor(model => model.Name) +
+ +
+ @Html.DisplayNameFor(model => model.EmailAddress) +
+ +
+ @Html.DisplayFor(model => model.EmailAddress) +
+ +
+ + @using (Html.BeginForm()) { + @Html.AntiForgeryToken() + +
+ | + @Html.ActionLink("Back to List", "Index") +
+ } +
diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Contacts/Details.cshtml b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Contacts/Details.cshtml new file mode 100644 index 000000000..eb8687bba --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Contacts/Details.cshtml @@ -0,0 +1,34 @@ +@model Samples.AspNetMvc5.Data.Contact + +@{ + ViewBag.Title = "Details"; +} + +

Details

+ +
+

Contact

+
+
+
+ @Html.DisplayNameFor(model => model.Name) +
+ +
+ @Html.DisplayFor(model => model.Name) +
+ +
+ @Html.DisplayNameFor(model => model.EmailAddress) +
+ +
+ @Html.DisplayFor(model => model.EmailAddress) +
+ +
+
+

+ @Html.ActionLink("Edit", "Edit", new { id = Model.Id }) | + @Html.ActionLink("Back to List", "Index") +

diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Contacts/Edit.cshtml b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Contacts/Edit.cshtml new file mode 100644 index 000000000..e1aefa166 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Contacts/Edit.cshtml @@ -0,0 +1,45 @@ +@model Samples.AspNetMvc5.Data.Contact + +@{ + ViewBag.Title = "Edit"; +} + +

Edit

+ +@using (Html.BeginForm()) +{ + @Html.AntiForgeryToken() + +
+

Contact

+
+ @Html.ValidationSummary(true, "", new { @class = "text-danger" }) + @Html.HiddenFor(model => model.Id) + +
+ @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" }) +
+ @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } }) + @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" }) +
+
+ +
+ @Html.LabelFor(model => model.EmailAddress, htmlAttributes: new { @class = "control-label col-md-2" }) +
+ @Html.EditorFor(model => model.EmailAddress, new { htmlAttributes = new { @class = "form-control" } }) + @Html.ValidationMessageFor(model => model.EmailAddress, "", new { @class = "text-danger" }) +
+
+ +
+
+ +
+
+
+} + +
+ @Html.ActionLink("Back to List", "Index") +
diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Contacts/Index.cshtml b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Contacts/Index.cshtml new file mode 100644 index 000000000..59937afd2 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Contacts/Index.cshtml @@ -0,0 +1,35 @@ +@model IEnumerable + +@{ + ViewBag.Title = "Contacts"; +} + +

Contacts

+ +

+ @Html.ActionLink("Create New", "Create") +

+ + + + + + + + + + + @foreach (var item in Model) + { + + + + + + } + +
@Html.DisplayNameFor(model => model.Name)@Html.DisplayNameFor(model => model.EmailAddress)
@Html.DisplayFor(modelItem => item.Name)@Html.DisplayFor(modelItem => item.EmailAddress) + @Html.ActionLink("Edit", "Edit", new { id = item.Id }) | + @Html.ActionLink("Details", "Details", new { id = item.Id }) | + @Html.ActionLink("Delete", "Delete", new { id = item.Id }) +
diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Error/Index.cshtml b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Error/Index.cshtml new file mode 100644 index 000000000..eb47fdb9d --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Error/Index.cshtml @@ -0,0 +1,35 @@ +@model List> + +@{ + Page.Title = "Error Page"; +} + +
+
Error Information:
+ + + + + + + + + @if (Model.Any()) + { + foreach (var envVar in Model) + { + + + + + } + } + else + { + + + + } + +
NameValue
@envVar.Key@envVar.Value
(empty)
+
\ No newline at end of file diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Home/Delay.cshtml b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Home/Delay.cshtml new file mode 100644 index 000000000..18839f1c5 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Home/Delay.cshtml @@ -0,0 +1,8 @@ +@model int + +@{ + ViewBag.Title = "Delay"; +} + +

Hello, world!

+

Delayed @Html.FormatValue(Model, "{0:N0}") seconds

\ No newline at end of file diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Home/Index.cshtml b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Home/Index.cshtml new file mode 100644 index 000000000..a4507a7a2 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Home/Index.cshtml @@ -0,0 +1,63 @@ +@model List> +@using System.Reflection + +@{ + ViewBag.Title = "Index"; +} + +
+ + + + + + + + + + + + + + + + + + + + + + + +
Application bitness@(Environment.Is64BitProcess ? "64-bit" : "32-bit")
Profiler attached@Samples.SampleHelpers.IsProfilerAttached()
Current directory@(Environment.CurrentDirectory)
MapPath("~")@(System.Web.Hosting.HostingEnvironment.IsHosted ? System.Web.Hosting.HostingEnvironment.MapPath("~") : null)
Datadog.Trace.dll path@Samples.SampleHelpers.GetTracerAssemblyLocation()
+
+ +
+
Environment Variables:
+ + + + + + + + + @if (Model.Any()) + { + foreach (var envVar in Model) + { + + + + + } + } + else + { + + + + } + +
NameValue
@envVar.Key@envVar.Value
(empty)
+
diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Web.config b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Web.config new file mode 100644 index 000000000..cd36e1793 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/Web.config @@ -0,0 +1,42 @@ + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/_Layout.cshtml b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/_Layout.cshtml new file mode 100644 index 000000000..74a806b55 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/_Layout.cshtml @@ -0,0 +1,15 @@ + + + + + + @ViewBag.Title - Samples.AspNetMvc5CustomException + + + + +
+ @RenderBody() +
+ + diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/_ViewStart.cshtml b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/_ViewStart.cshtml new file mode 100644 index 000000000..f2c8fb697 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Views/_ViewStart.cshtml @@ -0,0 +1,3 @@ +@{ + Layout = "~/Views/_Layout.cshtml"; +} \ No newline at end of file diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Web.Debug.config b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Web.Debug.config new file mode 100644 index 000000000..fae9cfefa --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Web.Debug.config @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Web.Release.config b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Web.Release.config new file mode 100644 index 000000000..da6e960b8 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Web.Release.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Web.config b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Web.config new file mode 100644 index 000000000..7d3e11709 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/Web.config @@ -0,0 +1,72 @@ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/packages.config b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/packages.config new file mode 100644 index 000000000..7286db5a9 --- /dev/null +++ b/tracer/test/test-applications/aspnet/Samples.AspNetMvc5CustomException/packages.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file