Google created the Go programming language to address issues with network scale in hyperscale environments. Since then, enterprises, such as Uber and Dropbox, have implemented Go for its speed, scalability and simplicity.
Much of Go's appeal is in its concurrency and support for cross-compilation, features that enable users to run multiple processes at once and code across different OSes and servers, according to Adam Woodbeck, senior software engineer at Barracuda Networks and author of Network Programming with Go from No Starch Press.
Woodbeck said he works with tens of thousands of devices that constantly communicate with each other and other services. Troubleshooting those devices in a traditional way would mean sifting through heaps of data to discover the root cause.
"If someone asked me, 'How come this one device is having this problem?' it is a massive undertaking to try to filter that down in real time to the relevant log entries," Woodbeck said. Instead, he uses Go structured logging -- which adds relevant metadata to log entries -- and logger tools to quickly pinpoint issues.
But not everyone works in large enterprises or hyperscale companies with thousands of devices. Smaller enterprises that operate at a lower scale can position themselves so they have the ability to pivot easily as they grow, Woodbeck said. For example, they could use Go for logging and metrics so they can get more visibility into their environments, where there might be less at stake and more room for curiosity.
Below is an excerpt from Chapter 13, "Logging and Metrics," from Network Programming with Go. In this chapter, Woodbeck provides examples of Go code for specific logging scenarios and explains concepts like log levels, structured logging and sampling.
Explore Network Programming with Go
Click here to read Chapter 13, "Logging and Metrics."