mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-29 16:58:34 +00:00
feat: metrics including pprof, expvars
This commit is contained in:
parent
91ffb7617d
commit
35eb165f63
9 changed files with 530 additions and 1 deletions
19
infra/conf/metrics.go
Normal file
19
infra/conf/metrics.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package conf
|
||||
|
||||
import (
|
||||
"github.com/xtls/xray-core/app/metrics"
|
||||
)
|
||||
|
||||
type MetricsConfig struct {
|
||||
Tag string `json:"tag"`
|
||||
}
|
||||
|
||||
func (c *MetricsConfig) Build() (*metrics.Config, error) {
|
||||
if c.Tag == "" {
|
||||
return nil, newError("metrics tag can't be empty.")
|
||||
}
|
||||
|
||||
return &metrics.Config{
|
||||
Tag: c.Tag,
|
||||
}, nil
|
||||
}
|
|
@ -411,6 +411,7 @@ type Config struct {
|
|||
Transport *TransportConfig `json:"transport"`
|
||||
Policy *PolicyConfig `json:"policy"`
|
||||
API *APIConfig `json:"api"`
|
||||
Metrics *MetricsConfig `json:"metrics"`
|
||||
Stats *StatsConfig `json:"stats"`
|
||||
Reverse *ReverseConfig `json:"reverse"`
|
||||
FakeDNS *FakeDNSConfig `json:"fakeDns"`
|
||||
|
@ -461,6 +462,9 @@ func (c *Config) Override(o *Config, fn string) {
|
|||
if o.API != nil {
|
||||
c.API = o.API
|
||||
}
|
||||
if o.Metrics != nil {
|
||||
c.Metrics = o.Metrics
|
||||
}
|
||||
if o.Stats != nil {
|
||||
c.Stats = o.Stats
|
||||
}
|
||||
|
@ -566,7 +570,13 @@ func (c *Config) Build() (*core.Config, error) {
|
|||
}
|
||||
config.App = append(config.App, serial.ToTypedMessage(apiConf))
|
||||
}
|
||||
|
||||
if c.Metrics != nil {
|
||||
metricsConf, err := c.Metrics.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
config.App = append(config.App, serial.ToTypedMessage(metricsConf))
|
||||
}
|
||||
if c.Stats != nil {
|
||||
statsConf, err := c.Stats.Build()
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue