DataDog / dd-trace-dotnet

.NET Client Library for Datadog APM
https://docs.datadoghq.com/tracing/
Apache License 2.0
458 stars 141 forks source link

ASP.NET Core 2.2 targeting .NET Framework 4.8 apps hosted in IIS do not emit traces on received HTTP requests #1756

Closed yhan closed 3 years ago

yhan commented 3 years ago

Describe the bug All processes are coded under ASP.NET CORE 2.2 targeting .NET Framework 4.8 hosted in IIS do not emit traces on received HTTP requests.

To Reproduce Here is a sample code with which we can reproduce the problem: https://github.com/yhan/aspdotnetcore.target.dotnetfwk4.8

When I am invoking a testing endpoint: GET http://localhost/api/values/query-google

The tracer DID NOT create an index for GET http://localhost/api/values/query-google, but did created a span for the out-going one:

2021-09-07 11:48:30.572 +00:00 [DBG] Span started: [s_id: 3100843836161607905, p_id: null, t_id: 8685263773301423586]
{ MachineName: ".", Process: "[21192 AspNetCore.API.Fwk]", AppDomain: "[1 AspNetCore.API.Fwk.exe]", TracerVersion: "1.28.4.0" }
2021-09-07 11:48:30.573 +00:00 [DBG] Using the global sampling rate: 1
{ MachineName: ".", Process: "[21192 AspNetCore.API.Fwk]", AppDomain: "[1 AspNetCore.API.Fwk.exe]", TracerVersion: "1.28.4.0" }
2021-09-07 11:48:30.573 +00:00 [DBG] Matched on rule global-rate-rule. Applying rate of 1 to trace id 8685263773301423586
{ MachineName: ".", Process: "[21192 AspNetCore.API.Fwk]", AppDomain: "[1 AspNetCore.API.Fwk.exe]", TracerVersion: "1.28.4.0" }
2021-09-07 11:48:30.781 +00:00 [DBG] Span closed: [s_id: 3100843836161607905, p_id: null, t_id: 8685263773301423586] for (Service: AspNetCore.API.Fwk-http-client, Resource: GET www.google.com/, Operation: http.request, Tags: [_dd.rule_psr (metric):1env (tag):recette,span.kind (tag):client,http.status_code (tag):200,http-client-handler-type (tag):System.Net.Http.HttpClientHandler,http.method (tag):GET,http.url (tag):https://www.google.com/,component (tag):HttpMessageHandler,_dd.limit_psr (metric):1,_sampling_priority_v1 (metric):1,_dd.tracer_kr (metric):0,])
{ MachineName: ".", Process: "[21192 AspNetCore.API.Fwk]", AppDomain: "[1 AspNetCore.API.Fwk.exe]", TracerVersion: "1.28.4.0" }
2021-09-07 11:48:31.225 +00:00 [DBG] Flushing 1 spans across 1 traces
{ MachineName: ".", Process: "[21192 AspNetCore.API.Fwk]", AppDomain: "[1 AspNetCore.API.Fwk.exe]", TracerVersion: "1.28.4.0" }
2021-09-07 11:48:31.225 +00:00 [DBG] Sending 1 traces to the DD agent
{ MachineName: ".", Process: "[21192 AspNetCore.API.Fwk]", AppDomain: "[1 AspNetCore.API.Fwk.exe]", TracerVersion: "1.28.4.0" }
2021-09-07 11:48:31.227 +00:00 [DBG] Successfully sent 1 traces to the DD agent
{ MachineName: ".", Process: "[21192 AspNetCore.API.Fwk]", AppDomain: "[1 AspNetCore.API.Fwk.exe]", TracerVersion: "1.28.4.0" }

I expect not only the HTTP client used in the service is detected, but also the server side, which is missing (i.e, aspnetcore.api.fwk) image

Which results the httpclient detected: https://app.datadoghq.eu/apm/traces?query=service%3Aaspnetcore.api.fwk-http-client%20env%3Arecette%20operation_name%3Ahttp.request&cols=core_service%2Ccore_resource_name%2Clog_duration%2Clog_http.method%2Clog_http.status_code&messageDisplay=inline&sort=desc&streamTraces=true&start=1630999636639&end=1631172436639&paused=false

image

What I consider as expected behavior is that the Tracer emits traces regarding receiving HTTP requests like this:

2021-09-07 13:28:28.702 +00:00 [DBG] Span started: [s_id: 8620027838976557152, p_id: null, t_id: 6599115652145885128]
{ MachineName: ".", Process: "[3864 w3wp]", AppDomain: "[2 /LM/W3SVC/503/ROOT-1-132754806224061999]", TracerVersion: "1.28.4.0" }
2021-09-07 13:28:28.702 +00:00 [DBG] Using the global sampling rate: 1
{ MachineName: ".", Process: "[3864 w3wp]", AppDomain: "[2 /LM/W3SVC/503/ROOT-1-132754806224061999]", TracerVersion: "1.28.4.0" }
2021-09-07 13:28:28.702 +00:00 [DBG] Matched on rule global-rate-rule. Applying rate of 1 to trace id 6599115652145885128
{ MachineName: ".", Process: "[3864 w3wp]", AppDomain: "[2 /LM/W3SVC/503/ROOT-1-132754806224061999]", TracerVersion: "1.28.4.0" }
2021-09-07 13:28:28.711 +00:00 [DBG] Span started: [s_id: 1785054733444111821, p_id: 8620027838976557152, t_id: 6599115652145885128]
{ MachineName: ".", Process: "[3864 w3wp]", AppDomain: "[2 /LM/W3SVC/503/ROOT-1-132754806224061999]", TracerVersion: "1.28.4.0" }
2021-09-07 13:28:28.716 +00:00 [DBG] Span closed: [s_id: 1785054733444111821, p_id: 8620027838976557152, t_id: 6599115652145885128] for (Service: fxk_api-recette, Resource: GET api/welcome/{id}, Operation: aspnet-webapi.request, Tags: [env (tag):recette,version (tag):0.0.1,span.kind (tag):server,http.status_code (tag):200,http.method (tag):GET,http.request.headers.host (tag):api-recette.finexkap.com,http.url (tag):https://api-recette.finexkap.com/api/welcome,language (tag):dotnet,aspnet.route (tag):api/{controller}/{id},aspnet.controller (tag):welcome,])
{ MachineName: ".", Process: "[3864 w3wp]", AppDomain: "[2 /LM/W3SVC/503/ROOT-1-132754806224061999]", TracerVersion: "1.28.4.0" }
2021-09-07 13:28:28.716 +00:00 [DBG] Span closed: [s_id: 8620027838976557152, p_id: null, t_id: 6599115652145885128] for (Service: fxk_api-recette, Resource: GET /api/welcome, Operation: aspnet.request, Tags: [cookie (tag):_ga=GA1.2.1714330434.1623414683; _fbp=fb.1.1623414683102.364088884; _hjid=59f54b48-e10a-4b68-882f-bc8d990dbf31; ABTasty=uid=xnd6xmyhcg1xc3e8&fst=1623414682945&pst=1629739966096&cst=1629981578042&ns=9&pvt=11&pvis=11&th=,_dd.rule_psr (metric):1env (tag):recette,version (tag):0.0.1,span.kind (tag):server,http.status_code (tag):200,http.method (tag):GET,http.request.headers.host (tag):api-recette.finexkap.com,http.url (tag):/api/welcome,language (tag):dotnet,_dd.limit_psr (metric):1,_sampling_priority_v1 (metric):1,_dd.tracer_kr (metric):0,])

...

2021-09-07 13:28:29.682 +00:00 [DBG] Flushing 4 spans across 2 traces
{ MachineName: ".", Process: "[3864 w3wp]", AppDomain: "[2 /LM/W3SVC/503/ROOT-1-132754806224061999]", TracerVersion: "1.28.4.0" }
2021-09-07 13:28:29.682 +00:00 [DBG] Sending 2 traces to the DD agent

The expected behavior as above of Microsoft ASP.NET (not ASP.NET Core) targetting .NET Framework 4.8. All processes in ASP.NET CORE 2.2 targeting .NET Framework 4.8 do not work.

Can you please suggest?

Runtime environment (please complete the following information):

yhan commented 3 years ago

@kevingosse confirmed that this is not supported: https://twitter.com/KooKiz/status/1435878364913541125

lucaspimentel commented 3 years ago

@yhan, the libraries we support on .NET Framework are listed in the docs here: https://docs.datadoghq.com/tracing/setup_overview/compatibility_requirements/dotnet-framework/#integrations

ASP.NET Core and Devart.Data.PostgreSql and not listed there, which means the .NET Tracer does not automatically instrument those libraries. Please reach out to support@datadoghq.com if you have any questions about support for a specific library or to request support for a new library. Thanks!