[GH-ISSUE #23938] issue: OpenTelemetry callback for webui.users.active.today is async def, causing "coroutine is not iterable" on every export #58782

Closed
opened 2026-05-05 23:54:22 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @flobrunner on GitHub (Apr 21, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/23938

Check Existing Issues

  • I have searched for any existing and/or related issues.
  • I have searched for any existing and/or related discussions.
  • I have also searched in the CLOSED issues AND CLOSED discussions and found no related items (your issue might already be addressed on the development branch!).
  • I am using the latest version of Open WebUI.

Installation Method

Docker

Open WebUI Version

v0.9.0

Ollama Version (if applicable)

No response

Operating System

Debian 12 & k8s

Browser (if applicable)

No response

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided every relevant configuration, setting, and environment variable used in my setup.
  • I have clearly listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc).
  • I have documented step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation. My steps:
  • Start with the initial platform/version/OS and dependencies used,
  • Specify exact install/launch/configure commands,
  • List URLs visited, user input (incl. example values/emails/passwords if needed),
  • Describe all options and toggles enabled or changed,
  • Include any files or environmental changes,
  • Identify the expected and actual result at each stage,
  • Ensure any reasonably skilled user can follow and hit the same issue.

Expected Behavior

The observable gauge webui.users.active.today (introduced in v0.6.38 via #19236) should export a value each OTEL metrics interval without errors.

Actual Behavior

Every export cycle, the OpenTelemetry SDK logs:

Steps to Reproduce

you need to enable OTEL
ENABLE_OTEL = True

Logs & Screenshots

ERROR | opentelemetry.sdk.metrics._internal.instrument:callback:149 -
Callback failed for instrument webui.users.active.today.
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/opentelemetry/sdk/metrics/_internal/instrument.py", line 140, in callback
for api_measurement in callback(callback_options):
TypeError: 'coroutine' object is not iterable

Additional Information

regression from https://github.com/open-webui/open-webui/commit/2716912

observe_users_active_today(options) -> Sequence[metrics.Observation]:
return [metrics.Observation(value=await Users.get_num_users_active_today())]

not validated: claude suggestion

1. Provide a sync variant of the query (cleanest):

def observe_users_active_today(options): return [metrics.Observation(value=Users.get_num_users_active_today_sync())]

2. Run the coroutine from the OTEL worker thread:

import asyncio def observe_users_active_today(options): try: loop = asyncio.new_event_loop() val = loop.run_until_complete(Users.get_num_users_active_today()) finally: loop.close() return [metrics.Observation(value=val)]

3. Cached value pattern: a background async task updates a module-level counter; the sync callback only reads it.

Option 1 is the most idiomatic. Option 3 is best if the query becomes expensive at scale.

Originally created by @flobrunner on GitHub (Apr 21, 2026). Original GitHub issue: https://github.com/open-webui/open-webui/issues/23938 ### Check Existing Issues - [x] I have searched for any existing and/or related issues. - [x] I have searched for any existing and/or related discussions. - [x] I have also searched in the CLOSED issues AND CLOSED discussions and found no related items (your issue might already be addressed on the development branch!). - [x] I am using the latest version of Open WebUI. ### Installation Method Docker ### Open WebUI Version v0.9.0 ### Ollama Version (if applicable) _No response_ ### Operating System Debian 12 & k8s ### Browser (if applicable) _No response_ ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have **provided every relevant configuration, setting, and environment variable used in my setup.** - [x] I have clearly **listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup** (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc). - [x] I have documented **step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation**. My steps: - Start with the initial platform/version/OS and dependencies used, - Specify exact install/launch/configure commands, - List URLs visited, user input (incl. example values/emails/passwords if needed), - Describe all options and toggles enabled or changed, - Include any files or environmental changes, - Identify the expected and actual result at each stage, - Ensure any reasonably skilled user can follow and hit the same issue. ### Expected Behavior The observable gauge `webui.users.active.today` (introduced in v0.6.38 via #19236) should export a value each OTEL metrics interval without errors. ### Actual Behavior Every export cycle, the OpenTelemetry SDK logs: ### Steps to Reproduce you need to enable OTEL ENABLE_OTEL = True ### Logs & Screenshots ERROR | opentelemetry.sdk.metrics._internal.instrument:callback:149 - Callback failed for instrument webui.users.active.today. Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/opentelemetry/sdk/metrics/_internal/instrument.py", line 140, in callback for api_measurement in callback(callback_options): TypeError: 'coroutine' object is not iterable ### Additional Information regression from https://github.com/open-webui/open-webui/commit/2716912 observe_users_active_today(options) -> Sequence[metrics.Observation]: return [metrics.Observation(value=await Users.get_num_users_active_today())] not validated: claude suggestion ### 1. Provide a sync variant of the query (cleanest): `def observe_users_active_today(options): return [metrics.Observation(value=Users.get_num_users_active_today_sync())]` ### 2. Run the coroutine from the OTEL worker thread: `import asyncio def observe_users_active_today(options): try: loop = asyncio.new_event_loop() val = loop.run_until_complete(Users.get_num_users_active_today()) finally: loop.close() return [metrics.Observation(value=val)]` ### 3. Cached value pattern: a background async task updates a module-level counter; the sync callback only reads it. Option 1 is the most idiomatic. Option 3 is best if the query becomes expensive at scale.
GiteaMirror added the bug label 2026-05-05 23:54:22 -05:00
Author
Owner

@moritzderallerechte commented on GitHub (Apr 22, 2026):

I have the same issue.
With Version v0.9.0 they updated their Database Abstraction Models to use async.

<!-- gh-comment-id:4296253755 --> @moritzderallerechte commented on GitHub (Apr 22, 2026): I have the same issue. With Version v0.9.0 they updated their Database Abstraction Models to use async.
Author
Owner

@dude75 commented on GitHub (Apr 22, 2026):

I have the same issue.

<!-- gh-comment-id:4297679626 --> @dude75 commented on GitHub (Apr 22, 2026): I have the same issue.
Author
Owner

@nwon910 commented on GitHub (Apr 22, 2026):

I have the same issue on v0.9.1 as well

<!-- gh-comment-id:4299787021 --> @nwon910 commented on GitHub (Apr 22, 2026): I have the same issue on v0.9.1 as well
Author
Owner

@lebajez commented on GitHub (Apr 22, 2026):

me too

<!-- gh-comment-id:4300143705 --> @lebajez commented on GitHub (Apr 22, 2026): me too
Author
Owner

@tjbck commented on GitHub (Apr 24, 2026):

Addressed in dev.

<!-- gh-comment-id:4311037398 --> @tjbck commented on GitHub (Apr 24, 2026): Addressed in dev.
Author
Owner

@lebajez commented on GitHub (Apr 25, 2026):

me too

somehow the new update solved this for me

<!-- gh-comment-id:4318668329 --> @lebajez commented on GitHub (Apr 25, 2026): > me too somehow the new update solved this for me
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#58782