Skip to content

Commit b1375e6

Browse files
authored
Fix logging and metric tags used by shadow worker (#1076)
1 parent fcc703e commit b1375e6

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

internal/workflow_shadower_worker.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ func newShadowWorker(
6666
// include domain name in tasklist to avoid confliction
6767
// since all shadow workflow will be run in a single system domain
6868
params.TaskList = generateShadowTaskList(domain, params.TaskList)
69+
if params.MetricsScope != nil {
70+
params.MetricsScope = tagScope(params.MetricsScope, tagTaskList, params.TaskList)
71+
}
72+
if params.Logger != nil {
73+
params.Logger = params.Logger.With(zap.String(tagTaskList, params.TaskList))
74+
}
6975
}
7076

7177
params.UserContext = context.WithValue(params.UserContext, serviceClientContextKey, service)

internal/workflow_shadower_worker_test.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ func (s *shadowWorkerSuite) TestStartShadowWorker_Failed_ShadowOptionNotSpecifie
9696
testDomain,
9797
nil,
9898
workerExecutionParameters{
99-
TaskList: testTaskList,
99+
TaskList: testTaskList,
100+
UserContext: context.Background(),
100101
},
101102
newRegistry(),
102103
)
@@ -112,7 +113,8 @@ func (s *shadowWorkerSuite) TestStartShadowWorker_Failed_InvalidShadowOption() {
112113
Mode: ShadowModeContinuous, // exit condition is not specified
113114
},
114115
workerExecutionParameters{
115-
TaskList: testTaskList,
116+
TaskList: testTaskList,
117+
UserContext: context.Background(),
116118
},
117119
newRegistry(),
118120
)
@@ -130,8 +132,9 @@ func (s *shadowWorkerSuite) TestStartShadowWorker_Failed_DomainNotExist() {
130132
testDomain,
131133
&ShadowOptions{},
132134
workerExecutionParameters{
133-
TaskList: testTaskList,
134-
Logger: zaptest.NewLogger(s.T()),
135+
TaskList: testTaskList,
136+
Logger: zaptest.NewLogger(s.T()),
137+
UserContext: context.Background(),
135138
},
136139
newRegistry(),
137140
)
@@ -148,7 +151,9 @@ func (s *shadowWorkerSuite) TestStartShadowWorker_Failed_TaskListNotSpecified()
148151
s.mockService,
149152
testDomain,
150153
&ShadowOptions{},
151-
workerExecutionParameters{},
154+
workerExecutionParameters{
155+
UserContext: context.Background(),
156+
},
152157
newRegistry(),
153158
)
154159

@@ -169,7 +174,8 @@ func (s *shadowWorkerSuite) TestStartShadowWorker_Failed_StartWorkflowError() {
169174
testDomain,
170175
&ShadowOptions{},
171176
workerExecutionParameters{
172-
TaskList: testTaskList,
177+
TaskList: testTaskList,
178+
UserContext: context.Background(),
173179
},
174180
newRegistry(),
175181
)
@@ -211,7 +217,8 @@ func (s *shadowWorkerSuite) TestStartShadowWorker_Succeed() {
211217
Concurrency: concurrency,
212218
},
213219
workerExecutionParameters{
214-
TaskList: testTaskList,
220+
TaskList: testTaskList,
221+
UserContext: context.Background(),
215222
},
216223
newRegistry(),
217224
)

0 commit comments

Comments
 (0)