feat(core): Support opentelemetry exporter (#1690)

This commit is contained in:
Fangyin Cheng
2024-07-05 15:20:21 +08:00
committed by GitHub
parent 84fc1fc7fe
commit bf978d2bf9
39 changed files with 1176 additions and 218 deletions

View File

@@ -3,7 +3,7 @@ import contextvars
from abc import ABC, abstractmethod
from concurrent.futures import Executor, ThreadPoolExecutor
from functools import partial
from typing import Any, Awaitable, Callable
from typing import Any, Callable, Optional
from dbgpt.component import BaseComponent, ComponentType, SystemApp
@@ -67,6 +67,11 @@ async def blocking_func_to_async(
return await loop.run_in_executor(executor, run_with_context)
async def blocking_func_to_async_no_executor(func: BlockingFunction, *args, **kwargs):
"""Run a potentially blocking function within an executor."""
return await blocking_func_to_async(None, func, *args, **kwargs) # type: ignore
class AsyncToSyncIterator:
def __init__(self, async_iterable, loop: asyncio.BaseEventLoop):
self.async_iterable = async_iterable