30
30
PYTHON_SCRIPT_FILE_NAME ,
31
31
PYTHON_SCRIPT_FILE_NAME_DEFAULT ,
32
32
PYTHON_LANGUAGE_RUNTIME , PYTHON_ENABLE_INIT_INDEXING ,
33
- METADATA_PROPERTIES_WORKER_INDEXED )
33
+ METADATA_PROPERTIES_WORKER_INDEXED ,
34
+ PYTHON_ENABLE_OPENTELEMETRY ,
35
+ PYTHON_ENABLE_OPENTELEMETRY_DEFAULT )
34
36
from .extension import ExtensionManager
35
37
from .http_v2 import http_coordinator , initialize_http_server , HttpV2Registry , \
36
38
sync_http_request , HttpServerInitError
@@ -318,10 +320,12 @@ async def _handle__worker_init_request(self, request):
318
320
constants .SHARED_MEMORY_DATA_TRANSFER : _TRUE ,
319
321
}
320
322
321
- self .update_opentelemetry_status ()
323
+ if get_app_setting (setting = PYTHON_ENABLE_OPENTELEMETRY ,
324
+ default_value = PYTHON_ENABLE_OPENTELEMETRY_DEFAULT ):
325
+ self .update_opentelemetry_status ()
322
326
323
- if self ._otel_libs_available :
324
- capabilities [constants .WORKER_OPEN_TELEMETRY_ENABLED ] = _TRUE
327
+ if self ._otel_libs_available :
328
+ capabilities [constants .WORKER_OPEN_TELEMETRY_ENABLED ] = _TRUE
325
329
326
330
if DependencyManager .should_load_cx_dependencies ():
327
331
DependencyManager .prioritize_customer_dependencies ()
@@ -383,8 +387,10 @@ def load_function_metadata(self, function_app_directory, caller_info):
383
387
function_path = os .path .join (function_app_directory ,
384
388
script_file_name )
385
389
390
+ # For V1, the function path will not exist and
391
+ # return None.
386
392
self ._function_metadata_result = (
387
- self .index_functions (function_path )) \
393
+ self .index_functions (function_path , function_app_directory )) \
388
394
if os .path .exists (function_path ) else None
389
395
390
396
async def _handle__functions_metadata_request (self , request ):
@@ -439,8 +445,9 @@ async def _handle__function_load_request(self, request):
439
445
440
446
logger .info (
441
447
'Received WorkerLoadRequest, request ID %s, function_id: %s,'
442
- 'function_name: %s' ,
443
- self .request_id , function_id , function_name )
448
+ 'function_name: %s, function_app_directory : %s' ,
449
+ self .request_id , function_id , function_name ,
450
+ function_app_directory )
444
451
445
452
programming_model = "V2"
446
453
try :
@@ -705,9 +712,14 @@ async def _handle__function_environment_reload_request(self, request):
705
712
bindings .load_binding_registry ()
706
713
707
714
capabilities = {}
708
- self .update_opentelemetry_status ()
709
- if self ._otel_libs_available :
710
- capabilities [constants .WORKER_OPEN_TELEMETRY_ENABLED ] = _TRUE
715
+ if get_app_setting (
716
+ setting = PYTHON_ENABLE_OPENTELEMETRY ,
717
+ default_value = PYTHON_ENABLE_OPENTELEMETRY_DEFAULT ):
718
+ self .update_opentelemetry_status ()
719
+
720
+ if self ._otel_libs_available :
721
+ capabilities [constants .WORKER_OPEN_TELEMETRY_ENABLED ] = (
722
+ _TRUE )
711
723
712
724
if is_envvar_true (PYTHON_ENABLE_INIT_INDEXING ):
713
725
try :
@@ -749,7 +761,7 @@ async def _handle__function_environment_reload_request(self, request):
749
761
request_id = self .request_id ,
750
762
function_environment_reload_response = failure_response )
751
763
752
- def index_functions (self , function_path : str ):
764
+ def index_functions (self , function_path : str , function_dir : str ):
753
765
indexed_functions = loader .index_function_app (function_path )
754
766
logger .info (
755
767
"Indexed function app and found %s functions" ,
@@ -760,7 +772,8 @@ def index_functions(self, function_path: str):
760
772
fx_metadata_results , fx_bindings_logs = (
761
773
loader .process_indexed_function (
762
774
self ._functions ,
763
- indexed_functions ))
775
+ indexed_functions ,
776
+ function_dir ))
764
777
765
778
indexed_function_logs : List [str ] = []
766
779
indexed_function_bindings_logs = []
0 commit comments