Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

### Bugs Fixed

- Do not count Functions as App Service
([#41327](https://github.com/Azure/azure-sdk-for-python/pull/41327))

### Other Changes

- Extend version range for `psutil` to include 7.x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ def _is_on_aks():


def _is_attach_enabled():
if _is_on_app_service():
return isdir("/agents/python/")
if _is_on_functions():
return environ.get(_PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY) == "true"
if _is_on_app_service():
return isdir("/agents/python/")
if _is_on_aks():
return _AKS_ARM_NAMESPACE_ID in environ
return False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,14 @@ def _get_attach_metric(self, options: CallbackOptions) -> Iterable[Observation]:
rpId = ""
os_type = platform.system()
# rp, rpId
if _utils._is_on_app_service():
# Web apps
rp = _RP_Names.APP_SERVICE.value
rpId = "{}/{}".format(os.environ.get(_WEBSITE_SITE_NAME), os.environ.get(_WEBSITE_HOME_STAMPNAME, ""))
elif _utils._is_on_functions():
if _utils._is_on_functions():
# Function apps
rp = _RP_Names.FUNCTIONS.value
rpId = os.environ.get(_WEBSITE_HOSTNAME, "")
elif _utils._is_on_app_service():
# Web apps
rp = _RP_Names.APP_SERVICE.value
rpId = "{}/{}".format(os.environ.get(_WEBSITE_SITE_NAME), os.environ.get(_WEBSITE_HOME_STAMPNAME, ""))
elif _utils._is_on_aks():
# AKS
rp = _RP_Names.AKS.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ def test_get_attach_metric_appsvc(self, metadata_mock):
os.environ,
{
"FUNCTIONS_WORKER_RUNTIME": "runtime",
# Functions can have WEBSITE_SITE_NAME
"WEBSITE_SITE_NAME": "site_name",
"WEBSITE_HOSTNAME": "host_name",
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,10 @@ def test_get_sdk_version_prefix_app_service_windows_attach(self, mock_system, mo

@patch.dict(
"azure.monitor.opentelemetry.exporter._utils.environ",
{"FUNCTIONS_WORKER_RUNTIME": TEST_WEBSITE_SITE_NAME},
{
"FUNCTIONS_WORKER_RUNTIME": TEST_WEBSITE_SITE_NAME,
"WEBSITE_SITE_NAME": TEST_WEBSITE_SITE_NAME,
},
clear=True,
)
@patch("azure.monitor.opentelemetry.exporter._utils.platform.system", return_value="")
Expand All @@ -387,7 +390,10 @@ def test_get_sdk_version_prefix_function(self, mock_system):

@patch.dict(
"azure.monitor.opentelemetry.exporter._utils.environ",
{"FUNCTIONS_WORKER_RUNTIME": TEST_WEBSITE_SITE_NAME},
{
"FUNCTIONS_WORKER_RUNTIME": TEST_WEBSITE_SITE_NAME,
"WEBSITE_SITE_NAME": TEST_WEBSITE_SITE_NAME,
},
clear=True,
)
@patch("azure.monitor.opentelemetry.exporter._utils.platform.system", return_value="Linux")
Expand All @@ -397,7 +403,10 @@ def test_get_sdk_version_prefix_function_linux(self, mock_system):

@patch.dict(
"azure.monitor.opentelemetry.exporter._utils.environ",
{"FUNCTIONS_WORKER_RUNTIME": TEST_WEBSITE_SITE_NAME},
{
"FUNCTIONS_WORKER_RUNTIME": TEST_WEBSITE_SITE_NAME,
"WEBSITE_SITE_NAME": TEST_WEBSITE_SITE_NAME,
},
clear=True,
)
@patch("azure.monitor.opentelemetry.exporter._utils.platform.system", return_value="Windows")
Expand All @@ -409,6 +418,7 @@ def test_get_sdk_version_prefix_function_windows(self, mock_system):
"azure.monitor.opentelemetry.exporter._utils.environ",
{
"FUNCTIONS_WORKER_RUNTIME": TEST_WEBSITE_SITE_NAME,
"WEBSITE_SITE_NAME": TEST_WEBSITE_SITE_NAME,
"PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY": "true",
},
clear=True,
Expand All @@ -422,6 +432,7 @@ def test_get_sdk_version_prefix_function_attach(self, mock_system):
"azure.monitor.opentelemetry.exporter._utils.environ",
{
"FUNCTIONS_WORKER_RUNTIME": TEST_WEBSITE_SITE_NAME,
"WEBSITE_SITE_NAME": TEST_WEBSITE_SITE_NAME,
"PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY": "true",
},
clear=True,
Expand All @@ -435,6 +446,7 @@ def test_get_sdk_version_prefix_function_linux_attach(self, mock_system):
"azure.monitor.opentelemetry.exporter._utils.environ",
{
"FUNCTIONS_WORKER_RUNTIME": TEST_WEBSITE_SITE_NAME,
"WEBSITE_SITE_NAME": TEST_WEBSITE_SITE_NAME,
"PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY": "true",
},
clear=True,
Expand Down