Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,11 @@ private void OnHostingHttpRequestInStop(object arg)
{
var span = scope.Span;

// we may need to update the resource name if none of the routing/mvc events updated it
// if we had an unhandled exception, the status code is already updated
if (string.IsNullOrEmpty(span.ResourceName) || !span.Error)
// We may need to update the resource name if none of the routing/mvc events updated it.
// If we had an unhandled exception, the status code will already be updated correctly,
// but if the span was manually marked as an error, we still need to record the status code
var isMissingHttpStatusCode = !span.HasHttpStatusCode();
if (string.IsNullOrEmpty(span.ResourceName) || isMissingHttpStatusCode)
{
var httpRequest = arg.DuckCast<HttpRequestInStopStruct>();
HttpContext httpContext = httpRequest.HttpContext;
Expand All @@ -793,7 +795,7 @@ private void OnHostingHttpRequestInStop(object arg)
span.ResourceName = AspNetCoreRequestHandler.GetDefaultResourceName(httpContext.Request);
}

if (!span.Error)
if (isMissingHttpStatusCode)
{
span.SetHttpStatusCode(httpContext.Response.StatusCode, isServer: true, tracer.Settings);
span.SetHeaderTags(new HeadersCollectionAdapter(httpContext.Response.Headers), tracer.Settings.HeaderTags, defaultTagPrefix: SpanContextPropagator.HttpResponseHeadersTagPrefix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ protected AspNetCoreIisMvcTestBase(string sampleName, IisFixture fixture, ITestO
{ "/ping", 200 },
{ "/branch/ping", 200 },
{ "/branch/not-found", 404 },
{ "/handled-exception", 500 },
};

protected string GetTestName(string testName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ protected AspNetCoreMvcTestBase(string sampleName, AspNetCoreTestFixture fixture
{ "/ping", 200 },
{ "/branch/ping", 200 },
{ "/branch/not-found", 404 },
{ "/handled-exception", 500 },
};

public void Dispose()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[
{
TraceId: Id_1,
SpanId: Id_2,
Name: aspnet_core.request,
Resource: GET handled-exception,
Service: Samples.AspNetCoreMinimalApis,
Type: web,
Error: 1,
Tags: {
component: aspnet_core,
env: integration_tests,
error.msg: Exception of type 'System.Exception' was thrown.,
error.stack:
System.Exception: Exception of type 'System.Exception' was thrown.
,
error.type: System.Exception,
http.method: GET,
http.request.headers.host: localhost:00000,
http.status_code: 500,
http.url: http://localhost:00000/handled-exception,
language: dotnet,
runtime-id: Guid_1,
span.kind: server,
version: 1.0.0
},
Metrics: {
_dd.top_level: 1.0,
_dd.tracer_kr: 1.0,
_sampling_priority_v1: 1.0
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[
{
TraceId: Id_1,
SpanId: Id_2,
Name: aspnet_core_mvc.request,
Resource: GET /handled-exception,
Service: Samples.AspNetCoreMinimalApis,
Type: web,
ParentId: Id_3,
Error: 1,
Tags: {
aspnet_core.action: handledexception,
aspnet_core.controller: home,
aspnet_core.route: handled-exception,
component: aspnet_core,
env: integration_tests,
error.msg: Exception of type 'System.Exception' was thrown.,
error.stack:
System.Exception: Exception of type 'System.Exception' was thrown.
,
error.type: System.Exception,
language: dotnet,
span.kind: server,
version: 1.0.0
}
},
{
TraceId: Id_1,
SpanId: Id_3,
Name: aspnet_core.request,
Resource: GET /handled-exception,
Service: Samples.AspNetCoreMinimalApis,
Type: web,
Error: 1,
Tags: {
aspnet_core.endpoint: Samples.AspNetCoreMvc.Controllers.HomeController.HandledException (Samples.AspNetCoreMinimalApis),
aspnet_core.route: handled-exception,
component: aspnet_core,
env: integration_tests,
error.msg: The HTTP response has status code 500.,
http.method: GET,
http.request.headers.host: localhost:00000,
http.status_code: 500,
http.url: http://localhost:00000/handled-exception,
language: dotnet,
runtime-id: Guid_1,
span.kind: server,
version: 1.0.0
},
Metrics: {
_dd.top_level: 1.0,
_dd.tracer_kr: 1.0,
_sampling_priority_v1: 1.0
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[
{
TraceId: Id_1,
SpanId: Id_2,
Name: aspnet_core.request,
Resource: GET handled-exception,
Service: Samples.AspNetCoreMinimalApis,
Type: web,
Error: 1,
Tags: {
component: aspnet_core,
env: integration_tests,
error.msg: Exception of type 'System.Exception' was thrown.,
error.stack:
System.Exception: Exception of type 'System.Exception' was thrown.
,
error.type: System.Exception,
http.method: GET,
http.request.headers.host: localhost:00000,
http.status_code: 500,
http.url: http://localhost:00000/handled-exception,
language: dotnet,
runtime-id: Guid_1,
span.kind: server,
version: 1.0.0
},
Metrics: {
_dd.top_level: 1.0,
_dd.tracer_kr: 1.0,
_sampling_priority_v1: 1.0
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[
{
TraceId: Id_1,
SpanId: Id_2,
Name: aspnet_core_mvc.request,
Resource: GET /handled-exception,
Service: Samples.AspNetCoreMinimalApis,
Type: web,
ParentId: Id_3,
Error: 1,
Tags: {
aspnet_core.action: handledexception,
aspnet_core.controller: home,
aspnet_core.route: handled-exception,
component: aspnet_core,
env: integration_tests,
error.msg: Exception of type 'System.Exception' was thrown.,
error.stack:
System.Exception: Exception of type 'System.Exception' was thrown.
,
error.type: System.Exception,
language: dotnet,
span.kind: server,
version: 1.0.0
}
},
{
TraceId: Id_1,
SpanId: Id_3,
Name: aspnet_core.request,
Resource: GET /handled-exception,
Service: Samples.AspNetCoreMinimalApis,
Type: web,
Error: 1,
Tags: {
aspnet_core.endpoint: Samples.AspNetCoreMvc.Controllers.HomeController.HandledException (Samples.AspNetCoreMinimalApis),
aspnet_core.route: handled-exception,
component: aspnet_core,
env: integration_tests,
error.msg: The HTTP response has status code 500.,
http.method: GET,
http.request.headers.host: localhost:00000,
http.status_code: 500,
http.url: http://localhost:00000/handled-exception,
language: dotnet,
runtime-id: Guid_1,
span.kind: server,
version: 1.0.0
},
Metrics: {
_dd.top_level: 1.0,
_dd.tracer_kr: 1.0,
_sampling_priority_v1: 1.0
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[
{
TraceId: Id_1,
SpanId: Id_2,
Name: aspnet_core.request,
Resource: GET handled-exception,
Service: Samples.AspNetCoreMvc21,
Type: web,
Error: 1,
Tags: {
component: aspnet_core,
env: integration_tests,
error.msg: Exception of type 'System.Exception' was thrown.,
error.stack:
System.Exception: Exception of type 'System.Exception' was thrown.
,
error.type: System.Exception,
http.method: GET,
http.request.headers.host: localhost:00000,
http.status_code: 500,
http.url: http://localhost:00000/handled-exception,
language: dotnet,
runtime-id: Guid_1,
span.kind: server,
version: 1.0.0
},
Metrics: {
_dd.top_level: 1.0,
_dd.tracer_kr: 1.0,
_sampling_priority_v1: 1.0
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[
{
TraceId: Id_1,
SpanId: Id_2,
Name: aspnet_core_mvc.request,
Resource: GET /handled-exception,
Service: Samples.AspNetCoreMvc21,
Type: web,
ParentId: Id_3,
Error: 1,
Tags: {
aspnet_core.action: handledexception,
aspnet_core.controller: home,
aspnet_core.route: handled-exception,
component: aspnet_core,
env: integration_tests,
error.msg: Exception of type 'System.Exception' was thrown.,
error.stack:
System.Exception: Exception of type 'System.Exception' was thrown.
,
error.type: System.Exception,
language: dotnet,
span.kind: server,
version: 1.0.0
}
},
{
TraceId: Id_1,
SpanId: Id_3,
Name: aspnet_core.request,
Resource: GET /handled-exception,
Service: Samples.AspNetCoreMvc21,
Type: web,
Error: 1,
Tags: {
aspnet_core.route: handled-exception,
component: aspnet_core,
env: integration_tests,
error.msg: The HTTP response has status code 500.,
http.method: GET,
http.request.headers.host: localhost:00000,
http.status_code: 500,
http.url: http://localhost:00000/handled-exception,
language: dotnet,
runtime-id: Guid_1,
span.kind: server,
version: 1.0.0
},
Metrics: {
_dd.top_level: 1.0,
_dd.tracer_kr: 1.0,
_sampling_priority_v1: 1.0
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[
{
TraceId: Id_1,
SpanId: Id_2,
Name: aspnet_core.request,
Resource: GET handled-exception,
Service: Samples.AspNetCoreMvc30,
Type: web,
Error: 1,
Tags: {
component: aspnet_core,
env: integration_tests,
error.msg: Exception of type 'System.Exception' was thrown.,
error.stack:
System.Exception: Exception of type 'System.Exception' was thrown.
,
error.type: System.Exception,
http.method: GET,
http.request.headers.host: localhost:00000,
http.status_code: 500,
http.url: http://localhost:00000/handled-exception,
language: dotnet,
runtime-id: Guid_1,
span.kind: server,
version: 1.0.0
},
Metrics: {
_dd.top_level: 1.0,
_dd.tracer_kr: 1.0,
_sampling_priority_v1: 1.0
}
}
]
Loading