Azure / Azure/azure-functions-python-worker

[Bug] PYTHON_ENABLE_OPENTELEMETRY=true crashes every async invocation (NoneType.extract) on v2 runtime, Python 3.13

オープン 初心者向け
#1,881 コメント 2 件 リアクション 2 件 担当者 0 名 GitHub で見る
bug python
主要言語
Python
スター
357
フォーク
116
平均マージ
32分
マージ済み PR(30日)
1

説明

### Expected Behavior

With `host.json` `telemetryMode: OpenTelemetry` and app setting `PYTHON_ENABLE_OPENTELEMETRY=true`, async functions should invoke normally (the worker should either initialize the OpenTelemetry trace-context propagator or no-op safely)

### Actual Behavior

Every async invocation returns HTTP 500. In v2 `worker_init` (runtimes/v2/azure_functions_runtime/handle_event.py), `PYTHON_ENABLE_OPENTELEMETRY=true` only calls `otel_manager.set_otel_libs_available(True)` and never calls `update_opentelemetry_status()` (unlike the `PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY` path). The propagator stays None, so per-invocation context activation crashes:

AttributeError: 'NoneType' object has no attribute 'extract'
File ".../azure_functions_runtime/otel.py", line 112, in configure_opentelemetry
ctx = otel_manager.get_trace_context_propagator().extract(carrier)

Removing the setting makes the app healthy. Appears to be the crash manifestation of #1870.

### Steps to Reproduce

1. Deploy a Python 3.13 Flex Consumption function app with an async HTTP trigger.
2. `host.json`: `{ "version": "2.0", "telemetryMode": "OpenTelemetry" }`.
3. Add app setting `PYTHON_ENABLE_OPENTELEMETRY=true`.
4. Call any async function -> HTTP 500 with the AttributeError above.
5. Remove `PYTHON_ENABLE_OPENTELEMETRY` -> healthy.

### Relevant code being tried

```shell
host.json: `{ "version": "2.0", "telemetryMode": "OpenTelemetry" }`

App setting:  PYTHON_ENABLE_OPENTELEMETRY=true 
(App also calls  azure.monitor.opentelemetry.configure_azure_monitor(...) at startup; removing that call does not change the crash.)
```

### Relevant log output

```shell
AttributeError: 'NoneType' object has no attribute 'extract'
File ".../azure_functions_runtime/otel.py", line ~112, in configure_opentelemetry
ctx = otel_manager.get_trace_context_propagator().extract(carrier)
```

### requirements.txt file

```shell
azure-functions
azure-functions-durable
azure-monitor-opentelemetry
```

### Where are you facing this problem?

Production Environment (explain below)

### Function app name

_No response_

### Additional Information

Hosting: Azure Functions Flex Consumption (FC1), Python 3.13, v2 azure_functions_runtime.

Related:
#1870 (worker-side auto-init gap),
#1626 (late context propagation).

Suggested fix: call  update_opentelemetry_status()  in the  PYTHON_ENABLE_OPENTELEMETRY  branch of worker_init  (symmetric to the App Insights path), and/or add a  None  guard in  configure_opentelemetry() .

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

runtimes/v2/azure_functions_runtime/handle_event.py の worker_init から始め、PYTHON_ENABLE_OPENTELEMETRY ブランチと PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY パスを比較します。次に runtimes/v2/azure_functions_runtime/otel.py の configure_opentelemetry を調べます。設定が有効な場合でも非同期呼び出しが失敗せず、トレースコンテキストが初期化されるか安全に処理されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
azure, python
領域
backend, observability-sre
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
活発
明瞭さ
明確に書かれている
初心者へのやさしさ
78/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。