2626import asyncio
2727import contextvars
2828import dataclasses
29+ import datetime
2930import functools
3031import importlib .util
3132import inspect
@@ -962,7 +963,14 @@ async def __call__(
962963 Function to send response information
963964
964965 '''
965- timer = Timer (id = str (uuid .uuid4 ()), timestamp = time .time ())
966+ request_id = str (uuid .uuid4 ())
967+
968+ timer = Timer (
969+ id = request_id ,
970+ timestamp = datetime .datetime .now (
971+ datetime .timezone .utc ,
972+ ).strftime ('%Y-%m-%dT%H:%M:%S.%fZ' ),
973+ )
966974
967975 assert scope ['type' ] == 'http'
968976
@@ -978,13 +986,26 @@ async def __call__(
978986 func_name = headers .get (b's2-ef-name' , b'' )
979987 func_endpoint = self .endpoints .get (func_name )
980988
989+ timer .metadata ['function' ] = func_name .decode ('utf-8' ) if func_name else ''
990+
981991 func = None
982992 func_info : Dict [str , Any ] = {}
983993 if func_endpoint is not None :
984994 func , func_info = func_endpoint
985995
986996 # Call the endpoint
987997 if method == 'POST' and func is not None and path == self .invoke_path :
998+
999+ logger .info (
1000+ json .dumps ({
1001+ 'type' : 'function_call' ,
1002+ 'id' : request_id ,
1003+ 'name' : func_name .decode ('utf-8' ),
1004+ 'content_type' : content_type .decode ('utf-8' ),
1005+ 'accepts' : accepts .decode ('utf-8' ),
1006+ }),
1007+ )
1008+
9881009 args_data_format = func_info ['args_data_format' ]
9891010 returns_data_format = func_info ['returns_data_format' ]
9901011 data = []
@@ -1122,9 +1143,7 @@ async def __call__(
11221143 out ['body' ] = body
11231144 await send (out )
11241145
1125- timer .metadata ['function' ] = func_name .decode ('utf-8' ) if func_name else ''
11261146 timer .finish ()
1127- timer .log_metrics ()
11281147
11291148 def _create_link (
11301149 self ,
0 commit comments