Skip to content

Commit 1f60165

Browse files
committed
Added Otel flag
1 parent ad39c32 commit 1f60165

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

azure_functions_worker/constants.py

+3
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,6 @@
8080

8181
# Base extension supported Python minor version
8282
BASE_EXT_SUPPORTED_PY_MINOR_VERSION = 8
83+
84+
PYTHON_ENABLE_OPENTELEMETRY = "PYTHON_ENABLE_OPENTELEMETRY"
85+
PYTHON_ENABLE_OPENTELEMETRY_DEFAULT = True

azure_functions_worker/dispatcher.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
PYTHON_SCRIPT_FILE_NAME,
3131
PYTHON_SCRIPT_FILE_NAME_DEFAULT,
3232
PYTHON_LANGUAGE_RUNTIME, PYTHON_ENABLE_INIT_INDEXING,
33-
METADATA_PROPERTIES_WORKER_INDEXED)
33+
METADATA_PROPERTIES_WORKER_INDEXED, PYTHON_ENABLE_OPENTELEMETRY,
34+
PYTHON_ENABLE_OPENTELEMETRY_DEFAULT)
3435
from .extension import ExtensionManager
3536
from .http_v2 import http_coordinator, initialize_http_server, HttpV2Registry, \
3637
sync_http_request, HttpServerInitError
@@ -318,10 +319,12 @@ async def _handle__worker_init_request(self, request):
318319
constants.SHARED_MEMORY_DATA_TRANSFER: _TRUE,
319320
}
320321

321-
self.update_opentelemetry_status()
322+
if get_app_setting(setting=PYTHON_ENABLE_OPENTELEMETRY,
323+
default_value=PYTHON_ENABLE_OPENTELEMETRY_DEFAULT):
324+
self.update_opentelemetry_status()
322325

323-
if self._otel_libs_available:
324-
capabilities[constants.WORKER_OPEN_TELEMETRY_ENABLED] = _TRUE
326+
if self._otel_libs_available:
327+
capabilities[constants.WORKER_OPEN_TELEMETRY_ENABLED] = _TRUE
325328

326329
if DependencyManager.should_load_cx_dependencies():
327330
DependencyManager.prioritize_customer_dependencies()
@@ -708,9 +711,12 @@ async def _handle__function_environment_reload_request(self, request):
708711
bindings.load_binding_registry()
709712

710713
capabilities = {}
711-
self.update_opentelemetry_status()
712-
if self._otel_libs_available:
713-
capabilities[constants.WORKER_OPEN_TELEMETRY_ENABLED] = _TRUE
714+
if get_app_setting(setting=PYTHON_ENABLE_OPENTELEMETRY,
715+
default_value=PYTHON_ENABLE_OPENTELEMETRY_DEFAULT):
716+
self.update_opentelemetry_status()
717+
718+
if self._otel_libs_available:
719+
capabilities[constants.WORKER_OPEN_TELEMETRY_ENABLED] = _TRUE
714720

715721
if is_envvar_true(PYTHON_ENABLE_INIT_INDEXING):
716722
try:

0 commit comments

Comments
 (0)