Skip to content
Closed
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
6 changes: 6 additions & 0 deletions eng/pack/Microsoft.Azure.Functions.V4.PythonWorker.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
<copyright>© .NET Foundation. All rights reserved.</copyright>
</metadata>
<files>
<file src="..\..\3.9_WINDOWS_X64\**" target="tools\3.9\WINDOWS\X64" />
<file src="..\..\3.9_WINDOWS_X86\**" target="tools\3.9\WINDOWS\X86" />
<file src="..\..\3.9_LINUX_X64\**" target="tools\3.9\LINUX\X64" />
<file src="..\..\3.9_OSX_X64\**" target="tools\3.9\OSX\X64" />
<file src="..\..\3.9_OSX_ARM64\**" target="tools\3.9\OSX\Arm64" />
<file src="..\..\3.9_LINUX_ARM64\**" target="tools\3.9\LINUX\Arm64" />
<file src="..\..\3.10_WINDOWS_X64\**" target="tools\3.10\WINDOWS\X64" />
<file src="..\..\3.10_WINDOWS_X86\**" target="tools\3.10\WINDOWS\X86" />
<file src="..\..\3.10_LINUX_X64\**" target="tools\3.10\LINUX\X64" />
Expand Down
2 changes: 2 additions & 0 deletions eng/templates/jobs/ci-dependency-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:

strategy:
matrix:
Python39:
PYTHON_VERSION: '3.9'
Python310:
PYTHON_VERSION: '3.10'
Python311:
Expand Down
2 changes: 2 additions & 0 deletions eng/templates/jobs/ci-emulator-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:

strategy:
matrix:
Python39:
PYTHON_VERSION: '3.9'
Python310:
PYTHON_VERSION: '3.10'
Python311:
Expand Down
2 changes: 2 additions & 0 deletions eng/templates/jobs/ci-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:

strategy:
matrix:
Python39:
PYTHON_VERSION: '3.9'
Python310:
PYTHON_VERSION: '3.10'
Python311:
Expand Down
18 changes: 18 additions & 0 deletions eng/templates/official/jobs/build-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ jobs:
os: windows
strategy:
matrix:
Python39V4:
pythonVersion: '3.9'
normalizedPythonVersion: '3.9'
Python310V4:
pythonVersion: '3.10'
normalizedPythonVersion: '3.10'
Expand Down Expand Up @@ -43,6 +46,9 @@ jobs:
os: windows
strategy:
matrix:
Python39V4:
pythonVersion: '3.9'
normalizedPythonVersion: '3.9'
Python310V4:
pythonVersion: '3.10'
normalizedPythonVersion: '3.10'
Expand Down Expand Up @@ -79,6 +85,9 @@ jobs:
os: linux
strategy:
matrix:
Python39V4:
pythonVersion: '3.9'
normalizedPythonVersion: '3.9'
Python310V4:
pythonVersion: '3.10'
normalizedPythonVersion: '3.10'
Expand Down Expand Up @@ -372,6 +381,9 @@ jobs:
os: macOS
strategy:
matrix:
Python39V4:
pythonVersion: '3.9'
normalizedPythonVersion: '3.9'
Python310V4:
pythonVersion: '3.10'
normalizedPythonVersion: '3.10'
Expand Down Expand Up @@ -407,6 +419,9 @@ jobs:
os: macOS
strategy:
matrix:
Python39V4:
pythonVersion: '3.9'
normalizedPythonVersion: '3.9'
Python310V4:
pythonVersion: '3.10'
normalizedPythonVersion: '3.10'
Expand Down Expand Up @@ -442,6 +457,9 @@ jobs:
os: linux
strategy:
matrix:
Python39V4:
pythonVersion: '3.9'
normalizedPythonVersion: '3.9'
Python310V4:
pythonVersion: '3.10'
normalizedPythonVersion: '3.10'
Expand Down
6 changes: 6 additions & 0 deletions eng/templates/official/jobs/ci-docker-dedicated-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ jobs:

strategy:
matrix:
Python39:
PYTHON_VERSION: '3.9'
STORAGE_CONNECTION: $(LinuxStorageConnectionString39)
SQL_CONNECTION: $(LinuxSqlConnectionString39)
EVENTGRID_URI: $(LinuxEventGridTopicUriString39)
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString39)
Python310:
PYTHON_VERSION: '3.10'
STORAGE_CONNECTION: $(LinuxStorageConnectionString310)
Expand Down
6 changes: 6 additions & 0 deletions eng/templates/official/jobs/ci-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ jobs:

strategy:
matrix:
Python39:
PYTHON_VERSION: '3.9'
STORAGE_CONNECTION: $(LinuxStorageConnectionString39)
SQL_CONNECTION: $(LinuxSqlConnectionString39)
EVENTGRID_URI: $(LinuxEventGridTopicUriString39)
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString39)
Python310:
PYTHON_VERSION: '3.10'
STORAGE_CONNECTION: $(LinuxStorageConnectionString310)
Expand Down
23 changes: 8 additions & 15 deletions runtimes/v1/azure_functions_runtime_v1/handle_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
from .functions import FunctionInfo, Registry
from .loader import load_function, install
from .logging import logger
from .otel import (configure_opentelemetry,
initialize_azure_monitor,
otel_manager,
update_opentelemetry_status)
from .otel import otel_manager, initialize_azure_monitor, configure_opentelemetry
from .version import VERSION

from .bindings.context import get_context
Expand Down Expand Up @@ -73,7 +70,6 @@ async def worker_init_request(request):

if is_envvar_true(PYTHON_ENABLE_OPENTELEMETRY):
otel_manager.set_otel_libs_available(True)
update_opentelemetry_status()

if (otel_manager.get_azure_monitor_available()
or otel_manager.get_otel_libs_available()):
Expand Down Expand Up @@ -160,15 +156,6 @@ async def invocation_request(request):
fi: FunctionInfo = _functions.get_function(
function_id)
assert fi is not None

# Initialize context and configure OpenTelemetry before emitting
# invocation-scoped logs so they include trace context (Operation Id)
fi_context = get_context(invoc_request, fi.name,
fi.directory)
if (otel_manager.get_azure_monitor_available()
or otel_manager.get_otel_libs_available()):
configure_opentelemetry(fi_context)

logger.info("Function name: %s, Function Type: %s",
fi.name,
("async" if fi.is_async else "sync"))
Expand All @@ -187,6 +174,9 @@ async def invocation_request(request):
pb,
trigger_metadata=trigger_metadata)

fi_context = get_context(invoc_request, fi.name,
fi.directory)

# Use local thread storage to store the invocation ID
# for a customer's threads
fi_context.thread_local_storage.invocation_id = invocation_id
Expand All @@ -198,6 +188,9 @@ async def invocation_request(request):
args[name] = Out()

if fi.is_async:
if otel_manager.get_azure_monitor_available():
configure_opentelemetry(fi_context)

# Not supporting Extensions
call_result = await execute_async(fi.func, args)
else:
Expand Down Expand Up @@ -239,6 +232,7 @@ async def invocation_request(request):

# Actively flush customer print() function to console
sys.stdout.flush()

logger.debug("Successfully completed WorkerInvocationRequest.")
return protos.InvocationResponse(
invocation_id=invocation_id,
Expand Down Expand Up @@ -297,7 +291,6 @@ async def function_environment_reload_request(request):
capabilities = {}
if is_envvar_true(PYTHON_ENABLE_OPENTELEMETRY):
otel_manager.set_otel_libs_available(True)
update_opentelemetry_status()

if is_envvar_true(PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY):
initialize_azure_monitor()
Expand Down
9 changes: 2 additions & 7 deletions runtimes/v1/azure_functions_runtime_v1/otel.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,10 @@ def initialize_azure_monitor():


def configure_opentelemetry(invocation_context):
trace_context_propagator = otel_manager.get_trace_context_propagator()
context_api = otel_manager.get_context_api()
if trace_context_propagator is None or context_api is None:
return

carrier = {TRACEPARENT: invocation_context.trace_context.trace_parent,
TRACESTATE: invocation_context.trace_context.trace_state}
ctx = trace_context_propagator.extract(carrier)
context_api.attach(ctx)
ctx = otel_manager.get_trace_context_propagator().extract(carrier)
otel_manager.get_context_api().attach(ctx)


otel_manager = OTelManager()
4 changes: 4 additions & 0 deletions runtimes/v1/azure_functions_runtime_v1/utils/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

from typing import Any

from ..otel import otel_manager, configure_opentelemetry


def get_current_loop():
return asyncio.events.get_event_loop()
Expand All @@ -29,6 +31,8 @@ def run_sync_func(invocation_id, context, func, params):
context.thread_local_storage.invocation_id = invocation_id
token = invocation_id_cv.set(invocation_id)
try:
if otel_manager.get_azure_monitor_available():
configure_opentelemetry(context)
result = functools.partial(execute_sync, func)
return result(params)
finally:
Expand Down
57 changes: 0 additions & 57 deletions runtimes/v1/tests/unittests/test_executor.py

This file was deleted.

Loading
Loading