Back to all reviewers

Contextual structured logging

grafana/grafana
Based on 2 comments
Go

Log messages should provide sufficient context to be meaningful and actionable while following structured logging patterns. Include relevant metrics, ratios, or identifiers that help diagnose issues. Use semantic conventions and structured key-value pairs rather than embedding values in message strings.

Logging Go

Reviewer Prompt

Log messages should provide sufficient context to be meaningful and actionable while following structured logging patterns. Include relevant metrics, ratios, or identifiers that help diagnose issues. Use semantic conventions and structured key-value pairs rather than embedding values in message strings.

Example (Before):

logger.Info("empty refid found", "query_count", len(queries))

Example (After):

logger.Info("empty refid found", "empty_count", 1, "query_count", len(queries))

For error logging, use structured logging with semantic conventions:

// Prefer this
log.ErrorReason(gfErr.Reason)

// Over this
log.Info("errorReason", gfErr.Reason, "error", gfErr.LogMessage)

Well-structured logs with proper context improve observability and make debugging more efficient across the entire system.

2
Comments Analyzed
Go
Primary Language
Logging
Category

Source Discussions