Skip to content

Commit d0bb691

Browse files
committed
Move a few occurrences of variables logged inline into tags
1 parent cd00f83 commit d0bb691

File tree

9 files changed

+37
-17
lines changed

9 files changed

+37
-17
lines changed

common/log/tag/tags.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,3 +993,18 @@ func Cause(cause string) ZapTag {
993993
func NexusOperation(operation string) ZapTag {
994994
return NewStringTag("nexus-operation", operation)
995995
}
996+
997+
// WorkflowRuleID returns tag for WorkflowRuleID
998+
func WorkflowRuleID(ruleID string) ZapTag {
999+
return NewStringTag("wf-rule-id", ruleID)
1000+
}
1001+
1002+
// URL returns tag for URL
1003+
func URL(url string) ZapTag {
1004+
return NewStringTag("url", url)
1005+
}
1006+
1007+
// TaskPriority returns tag for TaskPriority
1008+
func TaskPriority(priority string) ZapTag {
1009+
return NewStringTag("task-priority", priority)
1010+
}

common/rpc/encryption/local_store_tls_provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ func (s *localStoreTlsProvider) checkCertExpiration() {
428428
if window != 0 {
429429
expiring, expired, err := s.GetExpiringCerts(window)
430430
if err != nil {
431-
s.logger.Error(fmt.Sprintf("error while checking for certificate expiration: %v", err))
431+
s.logger.Error("error while checking for certificate expiration", tag.Error(err))
432432
return
433433
}
434434
if s.metricsHandler != nil {

service/frontend/namespace_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ func (d *namespaceHandler) removeOldestExpiredWorkflowRule(rules map[string]*rul
748748
}
749749

750750
if found {
751-
d.logger.Info(fmt.Sprintf("Removed expired workflow rule %s", oldestKey))
751+
d.logger.Info("Removed expired workflow rule", tag.WorkflowRuleID(oldestKey))
752752
delete(rules, oldestKey)
753753
}
754754
}

service/frontend/nexus_handler.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ func parseLinks(links []*nexuspb.Link, logger log.Logger) []nexus.Link {
484484
if err != nil {
485485
// TODO(rodrigozhou): links are non-essential for the execution of the workflow,
486486
// so ignoring the error for now; we will revisit how to handle these errors later.
487-
logger.Error(fmt.Sprintf("failed to parse link url: %s", link.Url), tag.Error(err))
487+
logger.Error("failed to parse link url", tag.URL(link.Url), tag.Error(err))
488488
continue
489489
}
490490
nexusLinks = append(nexusLinks, nexus.Link{
@@ -678,7 +678,11 @@ func (h *nexusHandler) nexusClientForActiveCluster(oc *operationContext, service
678678
TaskQueue: oc.taskQueue,
679679
}))
680680
if err != nil {
681-
oc.logger.Error(fmt.Sprintf("failed to forward Nexus request. error constructing ServiceBaseURL. baseURL=%s namespace=%s task_queue=%s", httpClient.BaseURL(), oc.namespaceName, oc.taskQueue), tag.Error(err))
681+
oc.logger.Error("failed to forward Nexus request. error constructing ServiceBaseURL",
682+
tag.URL(httpClient.BaseURL()),
683+
tag.WorkflowNamespace(oc.namespaceName),
684+
tag.WorkflowTaskQueueName(oc.taskQueue),
685+
tag.Error(err))
682686
oc.metricsHandler = oc.metricsHandler.WithTags(metrics.OutcomeTag("request_forwarding_failed"))
683687
return nil, nexus.HandlerErrorf(nexus.HandlerErrorTypeInternal, "request forwarding failed")
684688
}

service/history/replication/stream_sender.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,10 @@ func (s *StreamSenderImpl) sendTasks(
427427
endExclusiveWatermark int64,
428428
) error {
429429
if beginInclusiveWatermark > endExclusiveWatermark {
430-
err := serviceerror.NewInternal(fmt.Sprintf("StreamWorkflowReplication encountered invalid task range [%v, %v)",
430+
errMsg := fmt.Sprintf("StreamWorkflowReplication encountered invalid task range [%v, %v)",
431431
beginInclusiveWatermark,
432-
endExclusiveWatermark,
433-
))
434-
return err
432+
endExclusiveWatermark)
433+
return serviceerror.NewInternal(errMsg)
435434
}
436435
if beginInclusiveWatermark == endExclusiveWatermark {
437436
return s.sendToStream(&historyservice.StreamWorkflowReplicationMessagesResponse{

service/history/replication/stream_sender_flow_controller.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package replication
44

55
import (
66
"context"
7-
"fmt"
87
"sync"
98
"time"
109

@@ -106,9 +105,9 @@ func (s *SenderFlowControllerImpl) Wait(ctx context.Context, priority enumsspb.T
106105
state.mu.Lock()
107106
if !state.resume {
108107
state.waiters++
109-
s.logger.Info(fmt.Sprintf("%v sender is paused", priority.String()))
108+
s.logger.Info("sender is paused", tag.TaskPriority(priority.String()))
110109
state.cond.Wait()
111-
s.logger.Info(fmt.Sprintf("%s sender is resumed", priority.String()))
110+
s.logger.Info("sender is resumed", tag.TaskPriority(priority.String()))
112111
state.waiters--
113112
}
114113
state.mu.Unlock()

service/history/replication/sync_state_retriever.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ func (s *SyncStateRetrieverImpl) getNewRunInfo(ctx context.Context, namespaceId
326326
switch err.(type) {
327327
case nil:
328328
case *serviceerror.NotFound:
329-
s.logger.Info(fmt.Sprintf("SyncWorkflowState new run not found, newRunId: %v", newRunId),
329+
s.logger.Info("SyncWorkflowState new run not found",
330+
tag.WorkflowNewRunID(newRunId),
330331
tag.WorkflowNamespaceID(namespaceId.String()),
331332
tag.WorkflowID(execution.WorkflowId),
332333
tag.WorkflowRunID(execution.RunId))
@@ -350,7 +351,8 @@ func (s *SyncStateRetrieverImpl) getNewRunInfo(ctx context.Context, namespaceId
350351
switch err.(type) {
351352
case nil:
352353
case *serviceerror.NotFound:
353-
s.logger.Info(fmt.Sprintf("SyncWorkflowState new run event not found, newRunId: %v", newRunId),
354+
s.logger.Info("SyncWorkflowState new run event not found",
355+
tag.WorkflowNewRunID(newRunId),
354356
tag.WorkflowNamespaceID(namespaceId.String()),
355357
tag.WorkflowID(execution.WorkflowId),
356358
tag.WorkflowRunID(execution.RunId))
@@ -359,7 +361,8 @@ func (s *SyncStateRetrieverImpl) getNewRunInfo(ctx context.Context, namespaceId
359361
return nil, err
360362
}
361363
if len(newRunEvents) == 0 {
362-
s.logger.Info(fmt.Sprintf("SyncWorkflowState new run event is empty, newRunId: %v", newRunId),
364+
s.logger.Info("SyncWorkflowState new run event is empty",
365+
tag.WorkflowNewRunID(newRunId),
363366
tag.WorkflowNamespaceID(namespaceId.String()),
364367
tag.WorkflowID(execution.WorkflowId),
365368
tag.WorkflowRunID(execution.RunId))

service/history/transfer_queue_active_task_executor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ func (t *transferQueueActiveTaskExecutor) processCancelExecution(
500500
requestCancelInfo,
501501
attributes,
502502
); err != nil {
503-
t.logger.Debug(fmt.Sprintf("Failed to cancel external workflow execution. Error: %v", err))
503+
t.logger.Debug("Failed to cancel external workflow execution", tag.Error(err))
504504

505505
// Check to see if the error is non-transient, in which case add RequestCancelFailed
506506
// event and complete transfer task by returning nil error.

service/worker/scanner/scanner.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,9 @@ func (s *Scanner) startWorkflow(
265265
if _, ok := err.(*serviceerror.WorkflowExecutionAlreadyStarted); ok {
266266
return nil
267267
}
268-
s.context.logger.Error("error starting "+workflowType+" workflow", tag.Error(err))
268+
s.context.logger.Error("error starting workflow", tag.WorkflowType(workflowType), tag.Error(err))
269269
return err
270270
}
271-
s.context.logger.Info(workflowType + " workflow successfully started")
271+
s.context.logger.Info("workflow successfully started", tag.WorkflowType(workflowType))
272272
return nil
273273
}

0 commit comments

Comments
 (0)