Azure / data-api-builder

Data API builder provides modern REST and GraphQL endpoints to your Azure Databases and on-prem stores.
https://aka.ms/dab/docs
MIT License
949 stars 197 forks source link

[Logging] Improve logging in DAB: Use `StructuredLoggingInterpolatedStringHandler` #2442

Open sezal98 opened 4 weeks ago

sezal98 commented 4 weeks ago

Traditional structured logging is a quite expensive operation as it involves parsing the template string at runtime, and its memory is allocated for the arguments array even if the specified log level is disabled. Also, it is easy to forget some arguments or use a wrong argument order.

Please look at the following links

Image

Looking at the above screenshot, we observe that by using traditional Structured Logging we get 94.43 ns and by using the custom string interpolation techniques we get almost 14ns. Also, memory usage is nil when the log level is disabled by using the custom handler. We should explore this or any other efficient log method further.