Back to all reviewers

Structured contextual logging

temporalio/temporal
Based on 3 comments
Go

Always use structured logging with appropriate tags instead of string concatenation or formatting. Include relevant contextual information that would help in troubleshooting, such as namespace, operation ID, or workflow ID.

Logging Go

Reviewer Prompt

Always use structured logging with appropriate tags instead of string concatenation or formatting. Include relevant contextual information that would help in troubleshooting, such as namespace, operation ID, or workflow ID.

Instead of this:

logger.Debug("ShowTaskQueueConfig : " + strconv.FormatBool(req.ShowTaskQueueConfig))
logger.Info(fmt.Sprintf("Removed expired workflow rule %s", oldestKey))

Do this:

logger.Debug("Show task queue config", tag.Bool("showTaskQueueConfig", req.ShowTaskQueueConfig))
logger.Info("Removed expired workflow rule", tag.WorkflowRuleID(oldestKey), tag.WorkflowNamespaceID(namespaceID))

Structured logging with proper context tags makes logs:

  • More consistent and standardized across the codebase
  • Easier to search, filter, and aggregate
  • Machine-parsable for log analysis tools
  • More useful when diagnosing issues

Always consider what contextual information would be helpful for someone debugging an issue, and include those as tags rather than embedding them in the message text.

3
Comments Analyzed
Go
Primary Language
Logging
Category

Source Discussions