elastic / apm-agent-dotnet

https://www.elastic.co/guide/en/apm/agent/dotnet/current/index.html
Apache License 2.0
585 stars 209 forks source link

[BUG] NTLM negotiation logged as ERROR #2466

Open dsantos98 opened 1 month ago

dsantos98 commented 1 month ago

APM Agent version

1.30.0

Environment

Windows .NET Framework 4.8 WebApp

Describe the bug

The situation I came across is when my web application receives a request and that request triggers a request/transaction using HttpWebRequest (System.Net) with NTLM authentication. This transaction is logged as an error (401) which is the NTLM negotiation response despite the transaction actually giving 200.

Expected behavior

The transaction will be logged as success instead of the current error state

stevejgordon commented 6 days ago

Thanks for raising this @dsantos98. It might be hard to investigate as I don't know how to replicate the NTLM scenario. Are you saying there is a single HTTP request resulting in a 200 status code? Where is the 401 coming from? We treat that as a failure. Can you share any code to provide more context? Can you collect Agent trace logs to share with us, as those may also help?

dsantos98 commented 6 days ago

Hi,

There is some code where a make a HTTP request using .Net WebClient class. Here i make a request to an URL using Windows Credencials (NTLM):

Image

As we can see in the below image of Fiddler, this request generate o flow to autenticate the credencials:

Image

So the 401 response come from the windows service saying to the client that the request need user credencials:

Image

Image

Image

The transaction sample view is showing the WebClient request as an error

Image

And the span detail show that the response is a 401

Image

but this status code response is not the final