1313# limitations under the License.
1414
1515import os
16- import re
1716import urllib .parse as urlparse
1817
1918from newrelic .api .application import application_instance
2019from newrelic .api .transaction import current_transaction
2120from newrelic .api .web_transaction import WebTransaction
2221from newrelic .common .object_wrapper import wrap_function_wrapper
2322from newrelic .common .signature import bind_args
24- from newrelic .common .utilization import AzureFunctionUtilization
25-
26- RESOURCE_GROUP_NAME_PARTIAL_RE = AzureFunctionUtilization .RESOURCE_GROUP_NAME_PARTIAL_RE
27- RESOURCE_GROUP_NAME_RE = AzureFunctionUtilization .RESOURCE_GROUP_NAME_RE
2823
2924
3025def original_agent_instance ():
@@ -38,18 +33,12 @@ def intrinsics_populator(application, context):
3833 trigger_type = "http"
3934
4035 website_owner_name = os .environ .get ("WEBSITE_OWNER_NAME" , None )
41- if not website_owner_name :
42- subscription_id = "Unknown"
43- else :
44- subscription_id = re .search (r"(?:(?!\+).)*" , website_owner_name ) and re .search (
45- r"(?:(?!\+).)*" , website_owner_name
46- ).group (0 )
47- if website_owner_name and website_owner_name .endswith ("-Linux" ):
48- resource_group_name = RESOURCE_GROUP_NAME_RE .search (website_owner_name ).group (1 )
49- elif website_owner_name :
50- resource_group_name = RESOURCE_GROUP_NAME_PARTIAL_RE .search (website_owner_name ).group (1 )
51- else :
52- resource_group_name = os .environ .get ("WEBSITE_RESOURCE_GROUP" , "Unknown" )
36+
37+ subscription_id = "Unknown"
38+ if website_owner_name and "+" in website_owner_name :
39+ subscription_id = website_owner_name .split ("+" )[0 ] or "Unknown"
40+
41+ resource_group_name = os .environ .get ("WEBSITE_RESOURCE_GROUP" , "Unknown" )
5342 azure_function_app_name = os .environ .get ("WEBSITE_SITE_NAME" , getattr (application , "name" , "Azure Function App" ))
5443
5544 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' )} "
0 commit comments