mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-29 16:58:34 +00:00
Metrics: Add direct listen (#4409)
This commit is contained in:
parent
c5de08bea6
commit
4b01eb4398
4 changed files with 49 additions and 13 deletions
|
@ -6,15 +6,21 @@ import (
|
|||
)
|
||||
|
||||
type MetricsConfig struct {
|
||||
Tag string `json:"tag"`
|
||||
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 == "" {
|
||||
return nil, errors.New("metrics tag can't be empty.")
|
||||
c.Tag = "Metrics"
|
||||
}
|
||||
|
||||
return &metrics.Config{
|
||||
Tag: c.Tag,
|
||||
Tag: c.Tag,
|
||||
Listen: c.Listen,
|
||||
}, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue