CPU profiling changes:
cgr-engine.go:
- use filepath.Join instead of path.Join
- handle *CoreService.StopCPUProfiling error inside deferred function
- same with the error from *os.File.Close()
cores/core.go:
- StartCPUProfile now returns an *os.File (as opposed to an io.WriteCloser),
because os.File.Stat is used beforehand to check if a handler of the file is
already active and confirm the status of profiling. Asserting the type would
have worked as well.
- handle pprof.StartCPUProfile error and ensure file is closed before returning
- log file close error as a warning if it occurs
- return missing mandatory error with correct path field name ('DirPath')
- no need to check if fileCPU is nil for profiling status
- pprof.StartCPUProfiling will return an error if profiling is already started
- os.File.Close() will return ErrClosed if profiling is already stopped
- differentiate between calling StopCPUProfiling when profiling hasn't started
and when it was already stopped by returning appropriate errors
Memory profiling changes:
- merge StopChanMemProf with StopMemoryProfiling
- remove fileMEM and stopMemProf from struct and constructors
- add separate mutex for memory profiling, ensure thread safety
- handle all significant errors
- log error if StopMemoryProfiling fails during CoreS Shutdown
- ignore errors if profiling inactive in Shutdown and deferred Stop
- move validations inside V1 functions
- return error if StartMemoryProfiling already started
- return error if StopMemoryProfiling already stopped or never started
- close profiling loop on error, not the cgr-engine
- StopMemoryProfiling closes channel and profiling loop writes final profile
- rename Path to DirPath for mandatory field error
- rename memprof_nrfiles flag to memprof_maxfiles
- increase default memprof_interval
- consider MaxFiles <= 0 as unlimited
- move memory profiling logic after starting services
- use CoreService Start/StopMemoryProfiling in main
- remove final memory profile block (created by deferred Stop)
- convert MemProfiling to method on CoreService and rename to profileMemory
- use Ticker for recurrent actions instead of Timer
- compute mem_final.prof full path in StartMemoryProfiling
- suffix profile files with current time instead of numbers
- update dispatcher methods after changes
- move MemoryPrf from utils to cores, rename to MemoryProfilingParams
- add logs for starting/stopping profiling
- added the possibility to disable timestamps in the memory profile file names
and use increments of 1 instead.
Other changes:
- improved integration tests for flags (now table tests)
- improved profiling integration tests
- added hook support (executed after parsing config but before starting
engine)
- renamed TestEnvironment.Setup -> TestEngine.Run as it represents the
setup for a single cgr-engine instance
- replaced t.Log with t.Error for engine process kill error
- improved option comments
- added support for dynamic configuration for dbs
- ConfigJSON field can now be used to partially overwrite an existing
configuration
- extra cgr-engine flags can now be passed to the Run method
- added default db configs for mongo/internal
- implemented helper to load using cgr-loader
- Updated to use the test suite
- Deleted kafka_ssl sample configuration (moved to test file)
- Revised Kafka server SSL setup comment
- Ensured exporters are synchronous to avoid missing errors
- Implemented helper function to create and clean up kafka topics
- ERs sometimes took too long to receive a message.
Setting kafkaGroupID to "" prevents this.
- Kafka reader took 10s to close (default MaxWait).
Set MaxWait to 1ms.
- Exporters took 1s each to export due to BatchSize
not being hit. Set BatchSize to 1 to prevent it.
200 -> 16
Previously, considering the fibonacci back off strategy, if engine failed to
start it would have tried to attempt connections for 2.862799e+33 years.
Now, the amount of attempts is 16, equivalent to around 2 and a half seconds.
Should be more than enough, considering that usually 6-7 attempts are enough.
- added hook support (executed after parsing config but before
starting engine)
- made db resets configurable
- merged config parsing helper with the main Setup function
- removed engineDelay parameter
- replaced t.Log with t.Error for engine process kill error
- improved option comments
NewFileCSVStorage() now returns an error besides the storage struct itself, which is
logged and returned instead of calling log.Fatal() which was causing the engine to
crash.
Fixed compilation errors by creating the CSVStorage separately and passing it as an
argument to the TpReader constructor.
Fixes#3962
Add StorDB to config and services.
Put back the store_cdrs option under cdrs and update the CDRs
service to depend on StorDB.
Define the StorDB interface and add a constructor for it.
Add a constructor for postgres storage.
Add a config sanity check to validate SSL modes for postgres.
Update cgr-engine to consider StorDB on startup.