mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-23 00:41:40 +00:00
(cleanup) proxy
This commit is contained in:
parent
2bce2ee7e3
commit
325eb35b44
1 changed files with 0 additions and 35 deletions
|
|
@ -9,14 +9,6 @@ import warnings
|
|||
import importlib
|
||||
import warnings
|
||||
|
||||
from datadog import statsd, initialize as datadog_initialize
|
||||
|
||||
# Define DataDog client
|
||||
|
||||
options = {"statsd_host": "127.0.0.1", "statsd_port": 8125}
|
||||
|
||||
datadog_initialize(**options) # type: ignore
|
||||
|
||||
|
||||
def showwarning(message, category, filename, lineno, file=None, line=None):
|
||||
traceback_info = f"{filename}:{lineno}: {category.__name__}: {message}\n"
|
||||
|
|
@ -237,30 +229,6 @@ try:
|
|||
except:
|
||||
pass
|
||||
|
||||
from starlette.middleware.base import BaseHTTPMiddleware
|
||||
|
||||
|
||||
class DatadogMetricsMiddleware(BaseHTTPMiddleware):
|
||||
async def dispatch(self, request: Request, call_next):
|
||||
start_time = time.time()
|
||||
|
||||
# Request Count
|
||||
statsd.increment("litellm.proxy.requests")
|
||||
|
||||
try:
|
||||
response = await call_next(request)
|
||||
except Exception as e:
|
||||
# Error Count
|
||||
statsd.increment("litellm.proxy.errors")
|
||||
raise e
|
||||
|
||||
# Calculate response time
|
||||
response_time = (time.time() - start_time) * 1000 # in milliseconds
|
||||
statsd.distribution("litellm.proxy.response_time", response_time)
|
||||
|
||||
return response
|
||||
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=origins,
|
||||
|
|
@ -269,9 +237,6 @@ app.add_middleware(
|
|||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
app.add_middleware(DatadogMetricsMiddleware)
|
||||
|
||||
|
||||
from typing import Dict
|
||||
|
||||
api_key_header = APIKeyHeader(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue