projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch '10117-fuse-refcount' refs #10117
[arvados.git]
/
services
/
datamanager
/
loggerutil
/
loggerutil.go
diff --git
a/services/datamanager/loggerutil/loggerutil.go
b/services/datamanager/loggerutil/loggerutil.go
index 58abb119ac128a7ba94920ad6e3a29101df8e8cc..8111425d7af76a9fa55ca71a3b3620a1d0a095a1 100644
(file)
--- a/
services/datamanager/loggerutil/loggerutil.go
+++ b/
services/datamanager/loggerutil/loggerutil.go
@@
-10,13
+10,13
@@
import (
"time"
)
"time"
)
-// Useful to call at the begining of execution to log info about the
+// Useful to call at the begin
n
ing of execution to log info about the
// current run.
func LogRunInfo(arvLogger *logger.Logger) {
if arvLogger != nil {
now := time.Now()
arvLogger.Update(func(p map[string]interface{}, e map[string]interface{}) {
// current run.
func LogRunInfo(arvLogger *logger.Logger) {
if arvLogger != nil {
now := time.Now()
arvLogger.Update(func(p map[string]interface{}, e map[string]interface{}) {
- runInfo :=
make(map[string]interface{}
)
+ runInfo :=
logger.GetOrCreateMap(p, "run_info"
)
runInfo["started_at"] = now
runInfo["args"] = os.Args
hostname, err := os.Hostname()
runInfo["started_at"] = now
runInfo["args"] = os.Args
hostname, err := os.Hostname()
@@
-26,26
+26,25
@@
func LogRunInfo(arvLogger *logger.Logger) {
runInfo["hostname"] = hostname
}
runInfo["pid"] = os.Getpid()
runInfo["hostname"] = hostname
}
runInfo["pid"] = os.Getpid()
- p["run_info"] = runInfo
})
}
}
// A LogMutator that records the current memory usage. This is most useful as a logger write hook.
})
}
}
// A LogMutator that records the current memory usage. This is most useful as a logger write hook.
-//
-// Assumes we already have a map named "run_info" in properties. LogRunInfo() can create such a map for you if you call it.
func LogMemoryAlloc(p map[string]interface{}, e map[string]interface{}) {
func LogMemoryAlloc(p map[string]interface{}, e map[string]interface{}) {
- runInfo :=
p["run_info"].(map[string]interface{}
)
+ runInfo :=
logger.GetOrCreateMap(p, "run_info"
)
var memStats runtime.MemStats
runtime.ReadMemStats(&memStats)
var memStats runtime.MemStats
runtime.ReadMemStats(&memStats)
- runInfo["alloc_bytes_in_use"] = memStats.Alloc
+ runInfo["memory_bytes_in_use"] = memStats.Alloc
+ runInfo["memory_bytes_reserved"] = memStats.Sys
}
func FatalWithMessage(arvLogger *logger.Logger, message string) {
if arvLogger != nil {
arvLogger.FinalUpdate(func(p map[string]interface{}, e map[string]interface{}) {
p["FATAL"] = message
}
func FatalWithMessage(arvLogger *logger.Logger, message string) {
if arvLogger != nil {
arvLogger.FinalUpdate(func(p map[string]interface{}, e map[string]interface{}) {
p["FATAL"] = message
- p["run_info"].(map[string]interface{})["finished_at"] = time.Now()
+ runInfo := logger.GetOrCreateMap(p, "run_info")
+ runInfo["finished_at"] = time.Now()
})
}
})
}