Skip to content

Commit

Permalink
remove redundant config: entity.sentinel.enableMetricLog
Browse files Browse the repository at this point in the history
  • Loading branch information
louyuting committed Jun 28, 2020
1 parent 132e632 commit bb961c8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 21 deletions.
7 changes: 2 additions & 5 deletions api/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,8 @@ func InitWithConfigFile(configPath string) error {
// initCoreComponents init core components with default config
// it's better SetDefaultConfig before initCoreComponents
func initCoreComponents() error {
if config.EnableMetricLog() {
err := metric.InitTask()
if err != nil {
return err
}
if err := metric.InitTask(); err != nil {
return err
}

system.InitCollector(config.SystemStatCollectIntervalMs())
Expand Down
4 changes: 0 additions & 4 deletions core/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,3 @@ func SystemStatCollectIntervalMs() uint32 {
func UseCacheTime() bool {
return globalCfg.UseCacheTime()
}

func EnableMetricLog() bool {
return globalCfg.EnableMetricLog()
}
9 changes: 1 addition & 8 deletions core/config/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ type SentinelConfig struct {
// Type indicates the classification of the service (e.g. web service, API gateway).
Type int32
}
// EnableMetricLog represents whether to enable metric monitor log
EnableMetricLog bool `yaml:"enableMetricLog"`
// Log represents configuration items related to logging.
Log LogConfig
// Stat represents configuration items related to statistics.
Expand Down Expand Up @@ -83,8 +81,7 @@ func NewDefaultConfig() *Entity {
CollectIntervalMs: DefaultSystemStatCollectIntervalMs,
},
},
EnableMetricLog: true,
UseCacheTime: true,
UseCacheTime: true,
},
}
}
Expand Down Expand Up @@ -155,7 +152,3 @@ func (entity *Entity) SystemStatCollectIntervalMs() uint32 {
func (entity *Entity) UseCacheTime() bool {
return entity.Sentinel.UseCacheTime
}

func (entity *Entity) EnableMetricLog() bool {
return entity.Sentinel.EnableMetricLog
}
9 changes: 5 additions & 4 deletions core/log/metric/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ var (

func InitTask() (err error) {
initOnce.Do(func() {
flushInterval := config.MetricLogFlushIntervalSec()
if flushInterval == 0 {
return
}

metricWriter, err = NewDefaultMetricLogWriter(config.MetricLogSingleFileMaxSize(), config.MetricLogMaxFileAmount())
if err != nil {
logger.Errorf("Failed to initialize the MetricLogWriter: %+v", err)
Expand All @@ -40,10 +45,6 @@ func InitTask() (err error) {
// Schedule the log flushing task
go util.RunWithRecover(writeTaskLoop, logger)
// Schedule the log aggregating task
flushInterval := config.MetricLogFlushIntervalSec()
if flushInterval == 0 {
return
}
ticker := time.NewTicker(time.Duration(flushInterval) * time.Second)
go util.RunWithRecover(func() {
for {
Expand Down

0 comments on commit bb961c8

Please sign in to comment.