Skip to content

Convert command.Stats to a general-purpose field logger

command.Stats was used to store custom log fields added by the command package. The log fields are attached to gRPC structured logs when a request finishes. That utility is generic enough so that many other packages start using it. This MR converts command.Stats to a general-purpose field logger. It doesn't change how it works, just moves it to a new location with a saner name.

The usage is simple, like the following codes snippet:

if customFields := log.CustomFieldsFromContext(ctx); customFields != nil {
		customFields.RecordSum("count_something", 1)
		customFields.RecordMax("max_something", 1)
		customFields.RecordMetadata("key_a", "hello")
		customFields.RecordMetadata("key_b", "world")
}
Edited by Quang-Minh Nguyen

Merge request reports