From 024fd54392d5011c0da1e062f7d27373d1b59cad Mon Sep 17 00:00:00 2001 From: Nisha Lad Date: Tue, 11 Dec 2018 15:16:03 +0000 Subject: [PATCH] edited logging variable format to fit same standard across all fn related projects (#1350) --- api/agent/resource.go | 18 +++++++++--------- api/agent/runner_client.go | 8 ++++---- api/logs/s3/s3.go | 12 ++++++------ api/mqs/redis/redis.go | 6 +++--- api/server/server.go | 6 +++--- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/api/agent/resource.go b/api/agent/resource.go index 0825d5fb5..003be2b37 100644 --- a/api/agent/resource.go +++ b/api/agent/resource.go @@ -386,16 +386,16 @@ func (a *resourceTracker) initializeCPU(cfg *Config) { } logrus.WithFields(logrus.Fields{ - "totalCPU": totalCPU, - "availCPU": availCPU, + "total_cpu": totalCPU, + "avail_cpu": availCPU, }).Info("available cpu") a.cpuTotal = availCPU a.cpuAsyncHWMark = availCPU * 8 / 10 logrus.WithFields(logrus.Fields{ - "cpu": a.cpuTotal, - "cpuAsyncHWMark": a.cpuAsyncHWMark, + "cpu": a.cpuTotal, + "cpu_async_hw_mark": a.cpuAsyncHWMark, }).Info("cpu reservations") if a.cpuTotal == 0 { @@ -437,9 +437,9 @@ func (a *resourceTracker) initializeMemory(cfg *Config) { availMemory = availMemory - headRoom logrus.WithFields(logrus.Fields{ - "totalMemory": totalMemory, - "headRoom": headRoom, - "cgroupLimit": cGroupLimit, + "total_memory": totalMemory, + "head_room": headRoom, + "cgroup_limit": cGroupLimit, }).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 logrus.WithFields(logrus.Fields{ - "availMemory": a.ramTotal, - "ramAsyncHWMark": a.ramAsyncHWMark, + "avail_memory": a.ramTotal, + "ram_async_hw_mark": a.ramAsyncHWMark, }).Info("ram reservations") if a.ramTotal == 0 { diff --git a/api/agent/runner_client.go b/api/agent/runner_client.go index c82852496..75502754c 100644 --- a/api/agent/runner_client.go +++ b/api/agent/runner_client.go @@ -395,10 +395,10 @@ DataLoop: func logCallFinish(log logrus.FieldLogger, msg *pb.RunnerMsg_Finished, headers http.Header, httpStatus int32) { log.WithFields(logrus.Fields{ - "RunnerSuccess": msg.Finished.GetSuccess(), - "RunnerErrorCode": msg.Finished.GetErrorCode(), - "RunnerHttpStatus": httpStatus, - "FnHttpStatus": headers.Get("Fn-Http-Status"), + "runner_success": msg.Finished.GetSuccess(), + "runner_error_code": msg.Finished.GetErrorCode(), + "runner_http_status": httpStatus, + "fn_http_status": headers.Get("Fn-Http-Status"), }).Infof("Call finished Details=%v ErrorStr=%v", msg.Finished.GetDetails(), msg.Finished.GetErrorStr()) } diff --git a/api/logs/s3/s3.go b/api/logs/s3/s3.go index 62a606a49..62aa82c82 100644 --- a/api/logs/s3/s3.go +++ b/api/logs/s3/s3.go @@ -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") } - 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) // 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"), } - 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) if err != nil { 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() 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 target := &aws.WriteAtBuffer{} @@ -207,7 +207,7 @@ func (s *store) InsertCall(ctx context.Context, call *models.Call) error { 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) if err != nil { 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() 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) } @@ -356,7 +356,7 @@ func (s *store) GetCalls(ctx context.Context, filter *models.CallFilter) (*model // TODO we should reuse the buffer to decode these call, err := s.getCallByKey(ctx, objectName) 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 } diff --git a/api/mqs/redis/redis.go b/api/mqs/redis/redis.go index 7e0998440..bda69e2cf 100644 --- a/api/mqs/redis/redis.go +++ b/api/mqs/redis/redis.go @@ -152,20 +152,20 @@ func (mq *RedisMQ) processDelayedCalls() { if err == redis.ErrNil { continue } 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 } var job models.Call err = json.Unmarshal(buf, &job) 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 } _, err = redisPush(conn, mq.queueName, &job) 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 } conn.Do("HDEL", mq.k("delayed_jobs"), resID) diff --git a/api/server/server.go b/api/server/server.go index 5aa90e8c9..dc232c75c 100644 --- a/api/server/server.go +++ b/api/server/server.go @@ -1059,12 +1059,12 @@ func (s *Server) startGears(ctx context.Context, cancel context.CancelFunc) { nth, recv, wasSend := reflect.Select(cases) if wasSend { logrus.WithFields(logrus.Fields{ - "ctxNumber": nth, - "receivedValue": recv.String(), + "ctx_number": nth, + "received_value": recv.String(), }).Debug("Stopping because of received value from done context.") } else { logrus.WithFields(logrus.Fields{ - "ctxNumber": nth, + "ctx_number": nth, }).Debug("Stopping because of closed channel from done context.") }