Skip to content

Commit b96ca68

Browse files
authored
Adding updates to the log messages (#805)
1 parent 698c524 commit b96ca68

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

azure_functions_worker/dispatcher.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ async def _handle__invocation_request(self, req):
333333
'Received FunctionInvocationRequest',
334334
f'request ID: {self.request_id}',
335335
f'function ID: {function_id}',
336+
f'function name: {fi.name}',
336337
f'invocation ID: {invocation_id}',
337338
f'function type: {"async" if fi.is_async else "sync"}'
338339
]

azure_functions_worker/testutils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,8 @@ def start_webhost(*, script_dir=None, stdout=None):
722722
proc.wait(20)
723723
except subprocess.TimeoutExpired:
724724
proc.kill()
725-
raise RuntimeError('could not start the webworker')
725+
raise RuntimeError('could not start the webworker in time. Please'
726+
f' check the log file for details: {stdout.name} ')
726727

727728
return _WebHostProxy(proc, addr)
728729

tests/unittests/test_dispatcher.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,15 @@ async def test_sync_invocation_request_log(self):
197197
with patch('azure_functions_worker.dispatcher.logger') as mock_logger:
198198
async with self._ctrl as host:
199199
request_id: str = self._ctrl._worker._request_id
200-
func_id, invoke_id = await self._check_if_function_is_ok(host)
200+
func_id, invoke_id, func_name = (
201+
await self._check_if_function_is_ok(host)
202+
)
201203

202204
mock_logger.info.assert_any_call(
203205
'Received FunctionInvocationRequest, '
204206
f'request ID: {request_id}, '
205207
f'function ID: {func_id}, '
208+
f'function name: {func_name}, '
206209
f'invocation ID: {invoke_id}, '
207210
'function type: sync, '
208211
f'sync threadpool max workers: {self._default_workers}'
@@ -212,14 +215,15 @@ async def test_async_invocation_request_log(self):
212215
with patch('azure_functions_worker.dispatcher.logger') as mock_logger:
213216
async with self._ctrl as host:
214217
request_id: str = self._ctrl._worker._request_id
215-
func_id, invoke_id = (
218+
func_id, invoke_id, func_name = (
216219
await self._check_if_async_function_is_ok(host)
217220
)
218221

219222
mock_logger.info.assert_any_call(
220223
'Received FunctionInvocationRequest, '
221224
f'request ID: {request_id}, '
222225
f'function ID: {func_id}, '
226+
f'function name: {func_name}, '
223227
f'invocation ID: {invoke_id}, '
224228
'function type: async'
225229
)
@@ -230,12 +234,15 @@ async def test_sync_invocation_request_log_threads(self):
230234
with patch('azure_functions_worker.dispatcher.logger') as mock_logger:
231235
async with self._ctrl as host:
232236
request_id: str = self._ctrl._worker._request_id
233-
func_id, invoke_id = await self._check_if_function_is_ok(host)
237+
func_id, invoke_id, func_name = (
238+
await self._check_if_function_is_ok(host)
239+
)
234240

235241
mock_logger.info.assert_any_call(
236242
'Received FunctionInvocationRequest, '
237243
f'request ID: {request_id}, '
238244
f'function ID: {func_id}, '
245+
f'function name: {func_name}, '
239246
f'invocation ID: {invoke_id}, '
240247
'function type: sync, '
241248
'sync threadpool max workers: 5'
@@ -247,14 +254,15 @@ async def test_async_invocation_request_log_threads(self):
247254
with patch('azure_functions_worker.dispatcher.logger') as mock_logger:
248255
async with self._ctrl as host:
249256
request_id: str = self._ctrl._worker._request_id
250-
func_id, invoke_id = (
257+
func_id, invoke_id, func_name = (
251258
await self._check_if_async_function_is_ok(host)
252259
)
253260

254261
mock_logger.info.assert_any_call(
255262
'Received FunctionInvocationRequest, '
256263
f'request ID: {request_id}, '
257264
f'function ID: {func_id}, '
265+
f'function name: {func_name}, '
258266
f'invocation ID: {invoke_id}, '
259267
'function type: async'
260268
)
@@ -267,12 +275,15 @@ async def test_sync_invocation_request_log_in_placeholder_threads(self):
267275
})
268276

269277
request_id: str = self._ctrl._worker._request_id
270-
func_id, invoke_id = await self._check_if_function_is_ok(host)
278+
func_id, invoke_id, func_name = (
279+
await self._check_if_function_is_ok(host)
280+
)
271281

272282
mock_logger.info.assert_any_call(
273283
'Received FunctionInvocationRequest, '
274284
f'request ID: {request_id}, '
275285
f'function ID: {func_id}, '
286+
f'function name: {func_name}, '
276287
f'invocation ID: {invoke_id}, '
277288
'function type: sync, '
278289
'sync threadpool max workers: 5'
@@ -286,14 +297,15 @@ async def test_async_invocation_request_log_in_placeholder_threads(self):
286297
})
287298

288299
request_id: str = self._ctrl._worker._request_id
289-
func_id, invoke_id = (
300+
func_id, invoke_id, func_name = (
290301
await self._check_if_async_function_is_ok(host)
291302
)
292303

293304
mock_logger.info.assert_any_call(
294305
'Received FunctionInvocationRequest, '
295306
f'request ID: {request_id}, '
296307
f'function ID: {func_id}, '
308+
f'function name: {func_name}, '
297309
f'invocation ID: {invoke_id}, '
298310
'function type: async'
299311
)
@@ -308,7 +320,8 @@ async def _assert_workers_threadpool(self, ctrl, host,
308320

309321
async def _check_if_function_is_ok(self, host) -> Tuple[str, str]:
310322
# Ensure the function can be properly loaded
311-
func_id, load_r = await host.load_function('show_context')
323+
function_name = "show_context"
324+
func_id, load_r = await host.load_function(function_name)
312325
self.assertEqual(load_r.response.function_id, func_id)
313326
self.assertEqual(load_r.response.result.status,
314327
protos.StatusResult.Success)
@@ -329,10 +342,11 @@ async def _check_if_function_is_ok(self, host) -> Tuple[str, str]:
329342
self.assertEqual(call_r.response.result.status,
330343
protos.StatusResult.Success)
331344

332-
return func_id, invoke_id
345+
return func_id, invoke_id, function_name
333346

334347
async def _check_if_async_function_is_ok(self, host) -> Tuple[str, str]:
335348
# Ensure the function can be properly loaded
349+
function_name = "show_context_async"
336350
func_id, load_r = await host.load_function('show_context_async')
337351
self.assertEqual(load_r.response.function_id, func_id)
338352
self.assertEqual(load_r.response.result.status,
@@ -354,7 +368,7 @@ async def _check_if_async_function_is_ok(self, host) -> Tuple[str, str]:
354368
self.assertEqual(call_r.response.result.status,
355369
protos.StatusResult.Success)
356370

357-
return func_id, invoke_id
371+
return func_id, invoke_id, function_name
358372

359373

360374
class TestThreadPoolSettingsPython38(TestThreadPoolSettingsPython37):

0 commit comments

Comments
 (0)