edited logging variable format to fit same standard across all fn related projects (#1350)

This commit is contained in:
Nisha Lad
2018-12-11 15:16:03 +00:00
committed by Gerardo Viedma
parent 39ed3b64e7
commit 024fd54392
5 changed files with 25 additions and 25 deletions

View File

@@ -386,16 +386,16 @@ func (a *resourceTracker) initializeCPU(cfg *Config) {
} }
logrus.WithFields(logrus.Fields{ logrus.WithFields(logrus.Fields{
"totalCPU": totalCPU, "total_cpu": totalCPU,
"availCPU": availCPU, "avail_cpu": availCPU,
}).Info("available cpu") }).Info("available cpu")
a.cpuTotal = availCPU a.cpuTotal = availCPU
a.cpuAsyncHWMark = availCPU * 8 / 10 a.cpuAsyncHWMark = availCPU * 8 / 10
logrus.WithFields(logrus.Fields{ logrus.WithFields(logrus.Fields{
"cpu": a.cpuTotal, "cpu": a.cpuTotal,
"cpuAsyncHWMark": a.cpuAsyncHWMark, "cpu_async_hw_mark": a.cpuAsyncHWMark,
}).Info("cpu reservations") }).Info("cpu reservations")
if a.cpuTotal == 0 { if a.cpuTotal == 0 {
@@ -437,9 +437,9 @@ func (a *resourceTracker) initializeMemory(cfg *Config) {
availMemory = availMemory - headRoom availMemory = availMemory - headRoom
logrus.WithFields(logrus.Fields{ logrus.WithFields(logrus.Fields{
"totalMemory": totalMemory, "total_memory": totalMemory,
"headRoom": headRoom, "head_room": headRoom,
"cgroupLimit": cGroupLimit, "cgroup_limit": cGroupLimit,
}).Info("available memory") }).Info("available memory")
} }
@@ -453,8 +453,8 @@ func (a *resourceTracker) initializeMemory(cfg *Config) {
// For non-linux OS, we expect these (or their defaults) properly configured from command-line/env // For non-linux OS, we expect these (or their defaults) properly configured from command-line/env
logrus.WithFields(logrus.Fields{ logrus.WithFields(logrus.Fields{
"availMemory": a.ramTotal, "avail_memory": a.ramTotal,
"ramAsyncHWMark": a.ramAsyncHWMark, "ram_async_hw_mark": a.ramAsyncHWMark,
}).Info("ram reservations") }).Info("ram reservations")
if a.ramTotal == 0 { if a.ramTotal == 0 {

View File

@@ -395,10 +395,10 @@ DataLoop:
func logCallFinish(log logrus.FieldLogger, msg *pb.RunnerMsg_Finished, headers http.Header, httpStatus int32) { func logCallFinish(log logrus.FieldLogger, msg *pb.RunnerMsg_Finished, headers http.Header, httpStatus int32) {
log.WithFields(logrus.Fields{ log.WithFields(logrus.Fields{
"RunnerSuccess": msg.Finished.GetSuccess(), "runner_success": msg.Finished.GetSuccess(),
"RunnerErrorCode": msg.Finished.GetErrorCode(), "runner_error_code": msg.Finished.GetErrorCode(),
"RunnerHttpStatus": httpStatus, "runner_http_status": httpStatus,
"FnHttpStatus": headers.Get("Fn-Http-Status"), "fn_http_status": headers.Get("Fn-Http-Status"),
}).Infof("Call finished Details=%v ErrorStr=%v", msg.Finished.GetDetails(), msg.Finished.GetErrorStr()) }).Infof("Call finished Details=%v ErrorStr=%v", msg.Finished.GetDetails(), msg.Finished.GetErrorStr())
} }

View File

@@ -115,7 +115,7 @@ func (s3StoreProvider) New(ctx context.Context, u *url.URL) (models.LogStore, er
return nil, errors.New("must provide non-empty bucket name in path of s3 api url. e.g. s3://s3.com/us-east-1/my_bucket") return nil, errors.New("must provide non-empty bucket name in path of s3 api url. e.g. s3://s3.com/us-east-1/my_bucket")
} }
logrus.WithFields(logrus.Fields{"bucketName": bucketName, "region": region, "endpoint": endpoint, "access_key_id": accessKeyID, "useSSL": useSSL}).Info("checking / creating s3 bucket") logrus.WithFields(logrus.Fields{"bucket_name": bucketName, "region": region, "endpoint": endpoint, "access_key_id": accessKeyID, "use_ssl": useSSL}).Info("checking / creating s3 bucket")
store := createStore(bucketName, endpoint, region, accessKeyID, secretAccessKey, useSSL) store := createStore(bucketName, endpoint, region, accessKeyID, secretAccessKey, useSSL)
// ensure the bucket exists, creating if it does not // ensure the bucket exists, creating if it does not
@@ -152,7 +152,7 @@ func (s *store) InsertLog(ctx context.Context, call *models.Call, callLog io.Rea
ContentType: aws.String("text/plain"), ContentType: aws.String("text/plain"),
} }
logrus.WithFields(logrus.Fields{"bucketName": s.bucket, "key": objectName}).Debug("Uploading log") logrus.WithFields(logrus.Fields{"bucket_name": s.bucket, "key": objectName}).Debug("Uploading log")
_, err := s.uploader.UploadWithContext(ctx, params) _, err := s.uploader.UploadWithContext(ctx, params)
if err != nil { if err != nil {
return fmt.Errorf("failed to write log, %v", err) return fmt.Errorf("failed to write log, %v", err)
@@ -167,7 +167,7 @@ func (s *store) GetLog(ctx context.Context, appID, callID string) (io.Reader, er
defer span.End() defer span.End()
objectName := logKey(appID, callID) objectName := logKey(appID, callID)
logrus.WithFields(logrus.Fields{"bucketName": s.bucket, "key": objectName}).Debug("Downloading log") logrus.WithFields(logrus.Fields{"bucket_name": s.bucket, "key": objectName}).Debug("Downloading log")
// stream the logs to an in-memory buffer // stream the logs to an in-memory buffer
target := &aws.WriteAtBuffer{} target := &aws.WriteAtBuffer{}
@@ -207,7 +207,7 @@ func (s *store) InsertCall(ctx context.Context, call *models.Call) error {
ContentType: aws.String("text/plain"), ContentType: aws.String("text/plain"),
} }
logrus.WithFields(logrus.Fields{"bucketName": s.bucket, "key": objectName}).Debug("Uploading call") logrus.WithFields(logrus.Fields{"bucket_name": s.bucket, "key": objectName}).Debug("Uploading call")
_, err = s.uploader.UploadWithContext(ctx, params) _, err = s.uploader.UploadWithContext(ctx, params)
if err != nil { if err != nil {
return fmt.Errorf("failed to insert call, %v", err) return fmt.Errorf("failed to insert call, %v", err)
@@ -222,7 +222,7 @@ func (s *store) GetCall(ctx context.Context, fnID, callID string) (*models.Call,
defer span.End() defer span.End()
objectName := callKey(fnID, callID) objectName := callKey(fnID, callID)
logrus.WithFields(logrus.Fields{"bucketName": s.bucket, "key": objectName}).Debug("Downloading call") logrus.WithFields(logrus.Fields{"bucket_name": s.bucket, "key": objectName}).Debug("Downloading call")
return s.getCallByKey(ctx, objectName) return s.getCallByKey(ctx, objectName)
} }
@@ -356,7 +356,7 @@ func (s *store) GetCalls(ctx context.Context, filter *models.CallFilter) (*model
// TODO we should reuse the buffer to decode these // TODO we should reuse the buffer to decode these
call, err := s.getCallByKey(ctx, objectName) call, err := s.getCallByKey(ctx, objectName)
if err != nil { if err != nil {
common.Logger(ctx).WithError(err).WithFields(logrus.Fields{"fnID": fnID, "id": id}).Error("error filling call object") common.Logger(ctx).WithError(err).WithFields(logrus.Fields{"fn_id": fnID, "id": id}).Error("error filling call object")
continue continue
} }

View File

@@ -152,20 +152,20 @@ func (mq *RedisMQ) processDelayedCalls() {
if err == redis.ErrNil { if err == redis.ErrNil {
continue continue
} else if err != nil { } else if err != nil {
logrus.WithError(err).WithFields(logrus.Fields{"reservationId": resID}).Error("Error HGET delayed_jobs") logrus.WithError(err).WithFields(logrus.Fields{"reservation_id": resID}).Error("Error HGET delayed_jobs")
continue continue
} }
var job models.Call var job models.Call
err = json.Unmarshal(buf, &job) err = json.Unmarshal(buf, &job)
if err != nil { if err != nil {
logrus.WithError(err).WithFields(logrus.Fields{"buf": buf, "reservationId": resID}).Error("Error unmarshaling job") logrus.WithError(err).WithFields(logrus.Fields{"buf": buf, "reservation_id": resID}).Error("Error unmarshaling job")
return return
} }
_, err = redisPush(conn, mq.queueName, &job) _, err = redisPush(conn, mq.queueName, &job)
if err != nil { if err != nil {
logrus.WithError(err).WithFields(logrus.Fields{"reservationId": resID}).Error("Pushing delayed job") logrus.WithError(err).WithFields(logrus.Fields{"reservation_id": resID}).Error("Pushing delayed job")
return return
} }
conn.Do("HDEL", mq.k("delayed_jobs"), resID) conn.Do("HDEL", mq.k("delayed_jobs"), resID)

View File

@@ -1059,12 +1059,12 @@ func (s *Server) startGears(ctx context.Context, cancel context.CancelFunc) {
nth, recv, wasSend := reflect.Select(cases) nth, recv, wasSend := reflect.Select(cases)
if wasSend { if wasSend {
logrus.WithFields(logrus.Fields{ logrus.WithFields(logrus.Fields{
"ctxNumber": nth, "ctx_number": nth,
"receivedValue": recv.String(), "received_value": recv.String(),
}).Debug("Stopping because of received value from done context.") }).Debug("Stopping because of received value from done context.")
} else { } else {
logrus.WithFields(logrus.Fields{ logrus.WithFields(logrus.Fields{
"ctxNumber": nth, "ctx_number": nth,
}).Debug("Stopping because of closed channel from done context.") }).Debug("Stopping because of closed channel from done context.")
} }