mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-02-23 09:10:44 +00:00
27 lines
568 B
Go
27 lines
568 B
Go
package conf
|
|
|
|
import (
|
|
"github.com/xtls/xray-core/app/metrics"
|
|
"github.com/xtls/xray-core/common/errors"
|
|
)
|
|
|
|
type MetricsConfig struct {
|
|
Tag string `json:"tag"`
|
|
Listen string `json:"listen"`
|
|
}
|
|
|
|
func (c *MetricsConfig) Build() (*metrics.Config, error) {
|
|
if c.Listen == "" && c.Tag == "" {
|
|
return nil, errors.New("Metrics must have a tag or listen address.")
|
|
}
|
|
// If the tag is empty but have "listen" set a default "Metrics" for compatibility.
|
|
if c.Tag == "" {
|
|
c.Tag = "Metrics"
|
|
}
|
|
|
|
return &metrics.Config{
|
|
Tag: c.Tag,
|
|
Listen: c.Listen,
|
|
}, nil
|
|
}
|