github.com/anycable/anycable-go@v1.5.1/metrics/config.go (about)

     1  package metrics
     2  
     3  // Config contains metrics configuration
     4  type Config struct {
     5  	Log            bool
     6  	LogInterval    int // Deprecated
     7  	RotateInterval int
     8  	LogFormatter   string
     9  	// Print only specified metrics
    10  	LogFilter []string
    11  	HTTP      string
    12  	Host      string
    13  	Port      int
    14  	Tags      map[string]string
    15  	Statsd    StatsdConfig
    16  }
    17  
    18  // NewConfig creates an empty Config struct
    19  func NewConfig() Config {
    20  	return Config{
    21  		RotateInterval: 15,
    22  		Statsd:         NewStatsdConfig(),
    23  	}
    24  }
    25  
    26  // LogEnabled returns true iff any log option is specified
    27  func (c *Config) LogEnabled() bool {
    28  	return c.Log || c.LogFormatterEnabled()
    29  }
    30  
    31  // HTTPEnabled returns true iff HTTP is not empty
    32  func (c *Config) HTTPEnabled() bool {
    33  	return c.HTTP != ""
    34  }
    35  
    36  // LogFormatterEnabled returns true iff LogFormatter is not empty
    37  func (c *Config) LogFormatterEnabled() bool {
    38  	return c.LogFormatter != ""
    39  }