From b6ac934d004db14b52065d0017d3bf5b7b4c0b46 Mon Sep 17 00:00:00 2001 From: Andrew Dawson Date: Mon, 10 Jun 2019 17:24:16 -0700 Subject: [PATCH] Archival tag activity logger with workflowID and runID (#1984) --- service/worker/archiver/activities.go | 6 +++--- service/worker/archiver/util.go | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/service/worker/archiver/activities.go b/service/worker/archiver/activities.go index b09cc2ca595..34226eba410 100644 --- a/service/worker/archiver/activities.go +++ b/service/worker/archiver/activities.go @@ -92,7 +92,7 @@ func uploadHistoryActivity(ctx context.Context, request ArchiveRequest) (err err } }() - logger := tagLoggerWithRequest(container.Logger, request).WithTags(tag.Attempt(activity.GetInfo(ctx).Attempt)) + logger := tagLoggerWithRequest(tagLoggerWithActivityInfo(container.Logger, activity.GetInfo(ctx)), request) domainCache := container.DomainCache clusterMetadata := container.ClusterMetadata domainCacheEntry, err := getDomainByID(ctx, domainCache, request.DomainID) @@ -283,7 +283,7 @@ func deleteHistoryActivity(ctx context.Context, request ArchiveRequest) (err err } } }() - logger := tagLoggerWithRequest(container.Logger, request).WithTags(tag.Attempt(activity.GetInfo(ctx).Attempt)) + logger := tagLoggerWithRequest(tagLoggerWithActivityInfo(container.Logger, activity.GetInfo(ctx)), request) if request.EventStoreVersion == persistence.EventStoreVersionV2 { if err := deleteHistoryV2(ctx, container, request); err != nil { logger.Error("failed to delete history from events v2", tag.ArchivalDeleteHistoryFailReason(errorDetails(err)), tag.Error(err)) @@ -317,7 +317,7 @@ func deleteBlobActivity(ctx context.Context, request ArchiveRequest) (err error) } } }() - logger := tagLoggerWithRequest(container.Logger, request).WithTags(tag.Attempt(activity.GetInfo(ctx).Attempt)) + logger := tagLoggerWithRequest(tagLoggerWithActivityInfo(container.Logger, activity.GetInfo(ctx)), request) blobstoreClient := container.Blobstore if err := validateArchivalRequest(&request); err != nil { diff --git a/service/worker/archiver/util.go b/service/worker/archiver/util.go index a65b12ea4d1..3cd044466a5 100644 --- a/service/worker/archiver/util.go +++ b/service/worker/archiver/util.go @@ -32,6 +32,7 @@ import ( "github.com/uber/cadence/common/log" "github.com/uber/cadence/common/log/tag" "go.uber.org/cadence" + "go.uber.org/cadence/activity" ) // MaxArchivalIterationTimeout returns the max allowed timeout for a single iteration of archival workflow @@ -78,6 +79,13 @@ func tagLoggerWithRequest(logger log.Logger, request ArchiveRequest) log.Logger ) } +func tagLoggerWithActivityInfo(logger log.Logger, activityInfo activity.Info) log.Logger { + return logger.WithTags( + tag.WorkflowID(activityInfo.WorkflowExecution.ID), + tag.WorkflowRunID(activityInfo.WorkflowExecution.RunID), + tag.Attempt(activityInfo.Attempt)) +} + func contextExpired(ctx context.Context) bool { select { case <-ctx.Done():