mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 19:38:46 -05:00
[PR #14197] [MERGED] feat: Add OpenTelemetry Metrics Support via OTLP Exporter #62265
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/14197
Author: @jk-f5
Created: 5/22/2025
Status: ✅ Merged
Merged: 6/16/2025
Merged by: @tjbck
Base:
dev← Head:otel_metrics📝 Commits (2)
6325613Merge pull request #14675 from open-webui/dev210dc74feat: Add OpenTelemetry Metrics Support via OTLP Exporter📊 Changes
3 files changed (+121 additions, -1 deletions)
View changed files
📝
backend/open_webui/env.py(+1 -0)➕
backend/open_webui/utils/telemetry/metrics.py(+110 -0)📝
backend/open_webui/utils/telemetry/setup.py(+10 -1)📄 Description
Description:
This merge request introduces support for collecting and exporting OpenTelemetry metrics from Open WebUI using the OTLP protocol. The new implementation includes an HTTP middleware that tracks request counts and durations, and exports to the same collector endpoint used for traces. Metric collection is feature-flagged via the
ENABLE_OTEL_METRICSenvironment variable.Summary of changes:
backend/open_webui/utils/telemetry/metrics.py:http.server.requests(counter) andhttp.server.duration(histogram)./metricsendpoint; use an OTLP-compatible collector (such as the OpenTelemetry Collector) to expose Prometheus or other endpoints.ENABLE_OTEL_METRICS(default: False, opt-in).backend/open_webui/env.py.backend/open_webui/utils/telemetry/setup.py) to conditionally initialize metric collection ifENABLE_OTEL_METRICSis set.Usage:
ENABLE_OTEL_METRICS=truein your environment.OTEL_EXPORTER_OTLP_ENDPOINTto point at your OpenTelemetry collector's OTLP/gRPC metrics receiver./metricsendpoint, configure your collector accordingly.Testing:
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.