Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException during reflection of diagnostic events #102

Open
artsiomrusak opened this issue Aug 8, 2023 · 0 comments
Open

NullReferenceException during reflection of diagnostic events #102

artsiomrusak opened this issue Aug 8, 2023 · 0 comments

Comments

@artsiomrusak
Copy link

artsiomrusak commented Aug 8, 2023

Hello, we're using opentracing library for ASP.NET Core project and we're experiencing the NullReferenceException all the time.

WARN 2023-01-11 08:16:17,048 class:OpenTracing.Contrib.NetCore.AspNetCore.AspNetCoreDiagnostics topic:null ip:null reqid:5e01741e-f6b3-47a4-af32-5a41e5879cb3 partner:null action:null uid:null msg:Event-Exception: Microsoft.AspNetCore.Mvc.BeforeActionResult
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Object.GetType()
at OpenTracing.Contrib.NetCore.AspNetCore.MvcEventProcessor.ProcessEvent(String eventName, Object arg)
at OpenTracing.Contrib.NetCore.AspNetCore.AspNetCoreDiagnostics.OnNext(String eventName, Object untypedArg)
at OpenTracing.Contrib.NetCore.Internal.DiagnosticListenerObserver.System.IObserver<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.OnNext(KeyValuePair`2 value)

I've investigated library code and found that during event BeforeActionResult for ASP.NET Core, we're trying to grab property Result using typeInfo.GetDeclaredProperty() of type BeforeActionResultEventData (https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.diagnostics.beforeactionresulteventdata?view=aspnetcore-7.0).

The only problem is that this property name is passed to PropertyFetcher in lowercase (aka "result" instead of "Result") which always results in null, because GetDeclaredProperty method is case-sensitive.

Code line with the issue: https://github.com/opentracing-contrib/csharp-netcore/blob/master/src/OpenTracing.Contrib.NetCore/AspNetCore/AspNetCoreDiagnostics.cs#L224C54-L224C54

Could you please advice - is it smth that is expected or I'm doing smth wrong?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant