automatically log data to sentry if it's present in the environment variables

This commit is contained in:
Krrish Dholakia 2023-08-18 06:20:16 -07:00
parent dc288474f3
commit 0ba0ca6896
4 changed files with 4 additions and 4 deletions

View file

@ -3,7 +3,7 @@
# BASE_URL = 'http://localhost:8080'
# def test_hello_route():
# data = {"model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "hey, how's it going?"}]}
# data = {"model": "claude-instant-1", "messages": [{"role": "user", "content": "hey, how's it going?"}]}
# headers = {'Content-Type': 'application/json'}
# response = requests.get(BASE_URL, headers=headers, data=json.dumps(data))
# print(response.text)

View file

@ -440,7 +440,7 @@ def set_callbacks(callback_list):
global sentry_sdk_instance, capture_exception, add_breadcrumb, posthog, slack_app, alerts_channel, heliconeLogger, aispendLogger, berrispendLogger, supabaseClient
try:
for callback in callback_list:
if callback == "sentry":
if callback == "sentry" or "SENTRY_API_URL" in os.environ:
try:
import sentry_sdk
except ImportError:
@ -449,7 +449,7 @@ def set_callbacks(callback_list):
import sentry_sdk
sentry_sdk_instance = sentry_sdk
sentry_trace_rate = os.environ.get("SENTRY_API_TRACE_RATE") if "SENTRY_API_TRACE_RATE" in os.environ else "1.0"
sentry_sdk_instance.init(dsn=os.environ.get("SENTRY_API_URL"), traces_sample_rate=float(os.environ.get("SENTRY_API_TRACE_RATE")))
sentry_sdk_instance.init(dsn=os.environ.get("SENTRY_API_URL"), traces_sample_rate=float(sentry_trace_rate))
capture_exception = sentry_sdk_instance.capture_exception
add_breadcrumb = sentry_sdk_instance.add_breadcrumb
elif callback == "posthog":

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "litellm"
version = "0.1.424"
version = "0.1.425"
description = "Library to easily interface with LLM API providers"
authors = ["BerriAI"]
license = "MIT License"