Merge branch 'main' into feat/rag-2

This commit is contained in:
twwu
2025-08-22 17:40:34 +08:00
113 changed files with 1945 additions and 269 deletions

View File

@ -1,4 +1,5 @@
import atexit
import contextlib
import logging
import os
import platform
@ -106,7 +107,7 @@ def init_app(app: DifyApp):
"""Custom logging handler that creates spans for logging.exception() calls"""
def emit(self, record: logging.LogRecord):
try:
with contextlib.suppress(Exception):
if record.exc_info:
tracer = get_tracer_provider().get_tracer("dify.exception.logging")
with tracer.start_as_current_span(
@ -126,9 +127,6 @@ def init_app(app: DifyApp):
if record.exc_info[0]:
span.set_attribute("exception.type", record.exc_info[0].__name__)
except Exception:
pass
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import OTLPMetricExporter as GRPCMetricExporter
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter as GRPCSpanExporter

View File

@ -3,7 +3,7 @@ import logging
import ssl
from collections.abc import Callable
from datetime import timedelta
from typing import TYPE_CHECKING, Any, Union
from typing import TYPE_CHECKING, Any, Optional, Union
import redis
from redis import RedisError
@ -246,7 +246,7 @@ def init_app(app: DifyApp):
app.extensions["redis"] = redis_client
def redis_fallback(default_return: Any = None):
def redis_fallback(default_return: Optional[Any] = None):
"""
decorator to handle Redis operation exceptions and return a default value when Redis is unavailable.