mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-09 20:09:02 +02:00
refac(telemetry): drop deprecated semconv SpanAttributes subclass (#25784)
constants.py subclassed opentelemetry.semconv.trace.SpanAttributes, which is deprecated since semconv 1.25.0 (emits a DeprecationWarning; the pinned 0.63b1 has it live). Source the legacy span-attribute keys from the non-deprecated _incubating attribute modules instead: http.url / http.method / http.status_code <- _incubating http_attributes db.name / db.statement / db.operation <- _incubating db_attributes The stable http module renamed these (http.request.method, ...), so only the incubating module preserves the original values. Custom keys (db.instance/type/ip/port, error.*, result.*) stay literals. Verified: emitted attribute keys are byte-identical before/after for every key instrumentors.py reads, and importing constants no longer emits a DeprecationWarning.
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
from opentelemetry.semconv.trace import SpanAttributes as _SpanAttributes
|
||||
from opentelemetry.semconv._incubating.attributes import (
|
||||
db_attributes as _db,
|
||||
)
|
||||
from opentelemetry.semconv._incubating.attributes import (
|
||||
http_attributes as _http,
|
||||
)
|
||||
|
||||
# Span Tags
|
||||
SPAN_DB_TYPE = 'mysql'
|
||||
@@ -9,11 +14,29 @@ SPAN_SQL_EXPLAIN = 'explain'
|
||||
SPAN_ERROR_TYPE = 'error'
|
||||
|
||||
|
||||
class SpanAttributes(_SpanAttributes):
|
||||
"""
|
||||
Span Attributes
|
||||
class SpanAttributes:
|
||||
"""Span attribute keys used by the telemetry instrumentors.
|
||||
|
||||
Legacy semconv keys (http.* and db.*) are sourced from the `_incubating`
|
||||
attribute modules, which still define these exact string values.
|
||||
`opentelemetry.semconv.trace.SpanAttributes` (previously subclassed here)
|
||||
is deprecated since semconv 1.25.0, and the *stable* http module renamed
|
||||
the keys (e.g. `http.request.method`), so only the incubating module keeps
|
||||
the original `http.method` / `http.url` / `http.status_code` / `db.*` values.
|
||||
Sourcing from it keeps emitted span attribute keys unchanged.
|
||||
"""
|
||||
|
||||
# HTTP — legacy keys retained in the incubating module
|
||||
HTTP_URL = _http.HTTP_URL # 'http.url'
|
||||
HTTP_METHOD = _http.HTTP_METHOD # 'http.method'
|
||||
HTTP_STATUS_CODE = _http.HTTP_STATUS_CODE # 'http.status_code'
|
||||
|
||||
# DB — incubating semconv keys
|
||||
DB_NAME = _db.DB_NAME # 'db.name'
|
||||
DB_STATEMENT = _db.DB_STATEMENT # 'db.statement'
|
||||
DB_OPERATION = _db.DB_OPERATION # 'db.operation'
|
||||
|
||||
# Open WebUI custom keys (not part of semconv)
|
||||
DB_INSTANCE = 'db.instance'
|
||||
DB_TYPE = 'db.type'
|
||||
DB_IP = 'db.ip'
|
||||
|
||||
Reference in New Issue
Block a user