NClient
NClient copied to clipboard
Support capturing diagnostics information using DiagnosticSource
DiagnosticSource is a tool that will allow client users to subscribe to events and use them to log and send metrics. As an example, we can take the Elastic client.
Sample list of events:
- [ ] NClient.Transport.Request.Start
- [ ] NClient.Transport.Request.Stop
- [ ] NClient.Resilience.Attempt.Start
- [ ] NClient.Resilience.Attempt.Stop
- [ ] NClient.Exceptions.UnhandledException
- [ ] NClient.Exceptions.TransportException
- [ ] NClient.Exceptions.ValidationException
- [ ] NClient.Exceptions.ArgumentException
Additional links:
Hey! Can I work on this issue?
Hi @JorgChrist ! Sure :) I think you'll need ClientInterceptor.cs class. Write if you have any questions, I will be glad to help
Hello, @JorgChrist! Can I help you with something? Or did you not want to take this issue?
Hey, @smolchanovsky, sorry for the late reply. I do need some guidance actually.
I know how DiagnosticSource works for the most part and how it's implemented but I'm confused about where shall I implement it in the project!
Sorry, I know this is a newbie problem but I haven't dealt with big projects without guidance before.
Hi, @JorgChrist! The project has really become quite large, it seems I need to work on a guide for contributors to make it clearer. Unfortunately, I can't do it right now, because I can't do it fast, but I have good news: you know how DiagnosticSource works, which means you're halfway there :)
I will briefly describe where I would add events:
-
NClient.Transport.Request.*
events should be added inTransportNClient
class, in this method. This class is responsible for executing requests at the transport layer (usually HTTP). -
NClient.Resilience.Attempt.*
events should be added in the same class, but in an other method. -
NClient.Exceptions.*
events should be added inClientInterceptor
class. All client requests begin and end with this class, so all exceptions are intercepted there.
Thus, it is enough to focus on just two classes: ClientInterceptor
and TransportNClient
. If you need help or you want me to tell you in more detail how these classes work, write, I will be glad to help.
Hey @smolchanovsky. Thank you very much for taking the time to explain this! I'm on it and I'll get back to you with feedback when I make some progress :)