...

/

Logging With Context

Logging With Context

Learn about logging and its uses associated with OpenTelemetry in Go.

Logging is probably the most familiar form of telemetry. We probably started logging in the first program we ever authored when we printed Hello World! to STDOUT. Logging is the most natural first step in providing some data about the internal state of an application to an observer. Think about how many times we have added a print statement to our application to determine the value of a variable. We were logging. Printing simple log statements such as Hello World! can be helpful for beginners, but it does not provide the critical data we require to operate complex systems.

Logs can be powerful sources of telemetry data when they are enriched with data to provide context for the events they are describing. For example, if our log statements include a correlation ID in the log entry, we can use that data to associate the log entry with other observability data.

Application or system logs often consist of timestamped text records. These records come in a variety of structures, ranging from completely unstructured text to highly structured schemas with attached metadata. Logs are output in a variety of ways – single files, rotated files, or even to STDOUT. We need to be able to gather logs from multiple sources, transform and extract log data in a consumable format, and then export that transformed data for consumption/indexing.

In this lesson, we will discuss how to improve our logging, moving from plain text to ...