All Articles

Google Cloud Tracer output to a log

Google Cloud Platform Tracing is a great tool to understand how your application performs and how requests propagate in your system. When developing locally and with performance in mind, I was missing a way to utilize the already defined spans to monitor how long they were running. Hence this quick and simple implementation came to mind.

Example log to console output:

[15:03:35.046] info: Microsoft.Hosting.Lifetime[0] Now listening on: http://localhost:5000
[15:03:35.061] info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down.
[15:03:35.063] info: Microsoft.Hosting.Lifetime[0] Hosting environment: Development
[15:03:42.515] dbug: GCP.LoggerManagedTracer.LoggerManagedTracer[0] [WeatherForecastControllerGet] [291 ms]
[15:03:44.938] dbug: GCP.LoggerManagedTracer.LoggerManagedTracer[0] [WeatherForecastControllerGet] [308 ms]
[15:03:46.676] dbug: GCP.LoggerManagedTracer.LoggerManagedTracer[0] [WeatherForecastControllerGet] [435 ms]

https://github.com/stigrune/GCP.LoggerManagedTracer https://www.nuget.org/packages/GCP.LoggerManagedTracer