Skip to content

Commit 5ba3131

Browse files
committed
changes
1 parent b34fd26 commit 5ba3131

File tree

4 files changed

+9
-25
lines changed

4 files changed

+9
-25
lines changed

azure_functions_worker/constants.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,13 @@
8282
BASE_EXT_SUPPORTED_PY_MINOR_VERSION = 8
8383

8484
# Appsetting to turn on OpenTelemetry support/features
85-
# A value of "true" enables the setting, defaults to "false"
85+
# A value of "true" enables the setting
8686
PYTHON_ENABLE_OPENTELEMETRY = "PYTHON_ENABLE_OPENTELEMETRY"
87-
PYTHON_ENABLE_OPENTELEMETRY_DEFAULT = "false"
8887

8988
# Appsetting to turn on ApplicationInsights support/features
90-
# A value of "true" enables the setting, defaults to "false"
89+
# A value of "true" enables the setting
9190
PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY = \
9291
"PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY"
93-
PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY_DEFAULT = "false"
9492

9593
# Appsetting to specify root logger name of logger to collect telemetry for
9694
# Used by Azure monitor distro (Application Insights)

azure_functions_worker/dispatcher.py

+5-20
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@
3131
PYTHON_ENABLE_DEBUG_LOGGING,
3232
PYTHON_ENABLE_INIT_INDEXING,
3333
PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY,
34-
PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY_DEFAULT,
3534
PYTHON_ENABLE_OPENTELEMETRY,
36-
PYTHON_ENABLE_OPENTELEMETRY_DEFAULT,
3735
PYTHON_LANGUAGE_RUNTIME,
3836
PYTHON_ROLLBACK_CWD_PATH,
3937
PYTHON_SCRIPT_FILE_NAME,
@@ -386,20 +384,11 @@ async def _handle__worker_init_request(self, request):
386384
constants.SHARED_MEMORY_DATA_TRANSFER: _TRUE,
387385
}
388386

389-
opentelemetry_app_setting = get_app_setting(
390-
setting=PYTHON_ENABLE_OPENTELEMETRY,
391-
default_value=PYTHON_ENABLE_OPENTELEMETRY_DEFAULT,
392-
)
393-
394-
appinsights_app_setting = get_app_setting(
395-
setting=PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY,
396-
default_value=PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY_DEFAULT,
397-
)
398-
if appinsights_app_setting and appinsights_app_setting.lower() == "true":
387+
if is_envvar_true(PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY):
399388
self.initialize_azure_monitor()
400389

401-
if opentelemetry_app_setting and opentelemetry_app_setting.lower() == "true":
402-
self._otel_libs_available = True
390+
if is_envvar_true(PYTHON_ENABLE_OPENTELEMETRY):
391+
self.initialize_azure_monitor()
403392

404393
if self._azure_monitor_available or self._otel_libs_available:
405394
capabilities[constants.WORKER_OPEN_TELEMETRY_ENABLED] = _TRUE
@@ -795,13 +784,9 @@ async def _handle__function_environment_reload_request(self, request):
795784
bindings.load_binding_registry()
796785

797786
capabilities = {}
798-
if get_app_setting(
799-
setting=PYTHON_ENABLE_OPENTELEMETRY,
800-
default_value=PYTHON_ENABLE_OPENTELEMETRY_DEFAULT):
787+
if is_envvar_true(PYTHON_ENABLE_OPENTELEMETRY):
801788
self._otel_libs_available = True
802-
if get_app_setting(
803-
setting=PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY,
804-
default_value=PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY_DEFAULT):
789+
if is_envvar_true(PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY):
805790
self.initialize_azure_monitor()
806791

807792
if self._azure_monitor_available or self._otel_libs_available:

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Repository = "https://github.com/Azure/azure-functions-python-worker"
4545
dev = [
4646
"azure-eventhub", # Used for EventHub E2E tests
4747
"azure-functions-durable", # Used for Durable E2E tests
48+
"azure-monitor-opentelemetry", # Used for Azure Monitor unit tests
4849
"flask",
4950
"fastapi~=0.103.2",
5051
"pydantic",

tests/unittests/test_opentelemetry.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def test_init_request_enable_opentelemetry_enabled_app_setting(
169169
self.assertIn("WorkerOpenTelemetryEnabled", capabilities)
170170
self.assertEqual(capabilities["WorkerOpenTelemetryEnabled"], "true")
171171

172-
@patch.dict(os.environ, {})
172+
@patch.dict(os.environ, {'PYTHON_ENABLE_OPENTELEMETRY': 'false'})
173173
def test_init_request_enable_opentelemetry_default_app_setting(
174174
self,
175175
):

0 commit comments

Comments
 (0)