@@ -47,16 +47,16 @@ def intrinsics_populator(application, context):
4747 resource_group_name = AZURE_RESOURCE_GROUP_NAME_PARTIAL_RE .search (website_owner_name ).group (1 )
4848 else :
4949 resource_group_name = os .environ .get ("WEBSITE_RESOURCE_GROUP" , "Unknown" )
50- azure_function_app_name = os .environ .get ("WEBSITE_SITE_NAME" , application . name )
50+ azure_function_app_name = os .environ .get ("WEBSITE_SITE_NAME" , getattr ( application , " name" , "Azure Function App" ) )
5151
52- cloud_resource_id = f"/subscriptions/{ subscription_id } /resourceGroups/{ resource_group_name } /providers/Microsoft.Web/sites/{ azure_function_app_name } /functions/{ context . function_name } "
53- faas_name = f"{ azure_function_app_name } /{ context . function_name } "
52+ cloud_resource_id = f"/subscriptions/{ subscription_id } /resourceGroups/{ resource_group_name } /providers/Microsoft.Web/sites/{ azure_function_app_name } /functions/{ getattr ( context , ' function_name' , 'Unknown' ) } "
53+ faas_name = f"{ azure_function_app_name } /{ getattr ( context , ' function_name' , 'Unknown' ) } "
5454
5555 return {
5656 "cloud.resource_id" : cloud_resource_id ,
5757 "faas.name" : faas_name ,
5858 "faas.trigger" : trigger_type ,
59- "faas.invocation_id" : context . invocation_id ,
59+ "faas.invocation_id" : getattr ( context , " invocation_id" , "Unknown" ) ,
6060 }
6161
6262
@@ -79,12 +79,20 @@ async def wrap_dispatcher__handle__invocation_request(wrapped, instance, args, k
7979 if not request :
8080 return await wrapped (* args , ** kwargs )
8181
82- # For now, NR only supports HTTP triggers
83- function_id = request .invocation_request .function_id
84-
85- binding_type = instance ._functions .get_function (function_id ).trigger_metadata ["type" ]
86- if not binding_type .startswith ("http" ):
87- return await wrapped (* args , ** kwargs )
82+ try :
83+ # Once other trigger types are supported, we need
84+ # to create attribute checks for this functionality:
85+ function_id = request .invocation_request .function_id
86+ binding_type = instance ._functions .get_function (function_id ).trigger_metadata ["type" ]
87+
88+ # For now, NR only supports HTTP triggers.
89+ # In the future, we will have setup logic for other
90+ # trigger types within this instrumentation.
91+ if not binding_type .startswith ("http" ):
92+ return await wrapped (* args , ** kwargs )
93+
94+ except Exception :
95+ pass
8896
8997 return await wrapped (* args , ** kwargs )
9098
@@ -119,13 +127,13 @@ async def wrap_dispatcher__run_async_func(wrapped, instance, args, kwargs):
119127 if http_request :
120128 transaction = WebTransaction (
121129 application = application ,
122- name = context . function_name ,
130+ name = getattr ( context , " function_name" , "azure_function" ) ,
123131 group = "AzureFunction" ,
124132 scheme = scheme ,
125133 host = host ,
126134 port = port ,
127- request_method = http_request . method ,
128- request_path = http_request . url ,
135+ request_method = getattr ( http_request , " method" , None ) ,
136+ request_path = getattr ( http_request , " url" , None ) ,
129137 query_string = query ,
130138 headers = dict (http_request .headers ),
131139 source = func ,
@@ -185,13 +193,13 @@ def wrap_dispatcher__run_sync_func(wrapped, instance, args, kwargs):
185193 if http_request :
186194 transaction = WebTransaction (
187195 application = application ,
188- name = context . function_name ,
196+ name = getattr ( context , " function_name" , "azure_function" ) ,
189197 group = "AzureFunction" ,
190198 scheme = scheme ,
191199 host = host ,
192200 port = port ,
193- request_method = http_request . method ,
194- request_path = http_request . url ,
201+ request_method = getattr ( http_request , " method" , None ) ,
202+ request_path = getattr ( http_request , " url" , None ) ,
195203 query_string = query ,
196204 headers = dict (http_request .headers ),
197205 source = func ,
0 commit comments