Fredrik Ljung

Lead Developer and Architect at Datema Retail

Monitoring and Logging in .NET with OpenTelemetry

No matter how skilled you are as a developer, once you put your system into production and users are allowed in, unexpected things will happen. While most users are just doing their job, some may have far more nefarious purposes for interacting with your system. In both cases you need insight into what is happening in your system so you can ensure the legitimate users are able to do their jobs, while preventing the bad actors from abusing your system. This is where monitoring and logging really can make a difference by providing necessary data to improve and protect your system.

In this session we'll explore what monitoring is, how to effectively monitor an application in .NET. We'll look at what metrics .NET generates by default and how to create and collect custom application metrics. We'll trace requests as they move through the system and we'll use the Activity API's to add custom spans to the data. Additionally, we'll look at structured logging to log important application events and how to add your application specific data to the output.

Finally we'll look at how to correlated metrics, traces and logs using OpenTelemetry and export this data into a monitoring platform such as Azure Monitor or Datadog. With all the data centralized, you'll see how metrics can be displayed on dashboards, traces visualized as they propagate through your services, and alerts configured for key events or changes in system behavior. When things go wrong, or you need deeper insights, the correlated, searchable logs will significantly speed up your investigation and help you get to a resolution faster.

Fredrik Ljung

Fredrik Ljung has been a professional developer since 2007, after spending nearly as long digitizing building drawings, installing building automation systems, and delivering snail mail. He has spent the past 12 years on the .NET platform, developing anything from embedded systems for handhelds to cloud-based services and APIs.

Today he works as a Lead Developer and Architect at Datema Retail, where he fights code entropy with his head in the clouds. After 15 years of reading and writing code, he has found an appreciation for code that has a clear structure and is easy to understand.