Zimmergren/LogAnalytics.Client

Do not create a new HttpClient instance for every call to SendLogEntries

Closed this issue · 3 comments

First, thank you for sharing your knowledge and code!

I notice in the SendLogEntries method, an HttpClient is instantiated local to the method. Considering the possibility that this method might be called frequently and in rapid succession, the HttpClient should probably be an instance-level object.

For an overview of the things that can go wrong with HttpClient instances, see https://docs.microsoft.com/en-us/azure/architecture/antipatterns/improper-instantiation/.

Hi @SvenAelterman,

You're right - it started out as a quick functionality-demo, but as it has seen more traction it definitely makes sense to improve it where possible. Thanks for pointing this issue out. I've fixed it with the #4 PR.

Hi @Zimmergren, it appears you committed the code with a log analytics ID and key :)

The workspace and keys were a demo and are invalid at this point. Thanks for the heads up anyway, appreciate it.