forked from phoenix/litellm-mirror
fix otel load test
This commit is contained in:
parent
b80f27dce3
commit
88706488f9
1 changed files with 19 additions and 30 deletions
|
@ -13,48 +13,37 @@ import pytest
|
||||||
|
|
||||||
|
|
||||||
def test_otel_logging_async():
|
def test_otel_logging_async():
|
||||||
# this tests time added to make otel logging calls, vs just acompletion calls
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
os.environ["OTEL_EXPORTER"] = "otlp_http"
|
os.environ["OTEL_EXPORTER"] = "otlp_http"
|
||||||
os.environ["OTEL_ENDPOINT"] = (
|
os.environ["OTEL_ENDPOINT"] = (
|
||||||
"https://exampleopenaiendpoint-production.up.railway.app/traces"
|
"https://exampleopenaiendpoint-production.up.railway.app/traces"
|
||||||
)
|
)
|
||||||
os.environ["OTEL_HEADERS"] = "Authorization=K0BSwd"
|
os.environ["OTEL_HEADERS"] = "Authorization=K0BSwd"
|
||||||
|
|
||||||
# Make 5 calls with an empty success_callback
|
def single_run():
|
||||||
litellm.success_callback = []
|
litellm.callbacks = []
|
||||||
litellm.callbacks = []
|
start_time_empty = asyncio.run(make_async_calls())
|
||||||
litellm._async_success_callback = []
|
print(f"Time with empty callback: {start_time_empty}")
|
||||||
litellm._async_failure_callback = []
|
|
||||||
litellm._async_failure_callback = []
|
|
||||||
litellm.failure_callback = []
|
|
||||||
start_time_empty_callback = asyncio.run(make_async_calls())
|
|
||||||
print("done with no callback test")
|
|
||||||
|
|
||||||
print("starting otel test")
|
litellm.callbacks = ["otel"]
|
||||||
# Make 5 calls with success_callback set to "otel"
|
start_time_otel = asyncio.run(make_async_calls())
|
||||||
litellm.callbacks = ["otel"]
|
print(f"Time with otel callback: {start_time_otel}")
|
||||||
start_time_otel = asyncio.run(make_async_calls())
|
|
||||||
print("done with otel test")
|
|
||||||
|
|
||||||
# Compare the time for both scenarios
|
percent_diff = (
|
||||||
print(f"Time taken with success_callback='otel': {start_time_otel}")
|
abs(start_time_otel - start_time_empty) / start_time_empty * 100
|
||||||
print(f"Time taken with empty success_callback: {start_time_empty_callback}")
|
)
|
||||||
|
print(f"Run performance difference: {percent_diff:.2f}%")
|
||||||
|
return percent_diff
|
||||||
|
|
||||||
# Calculate the percentage difference
|
percent_diffs = [single_run() for _ in range(3)]
|
||||||
percentage_diff = (
|
avg_percent_diff = sum(percent_diffs) / len(percent_diffs)
|
||||||
abs(start_time_otel - start_time_empty_callback)
|
|
||||||
/ start_time_empty_callback
|
print(f"Percentage differences: {percent_diffs}")
|
||||||
* 100
|
print(f"Average performance difference: {avg_percent_diff:.2f}%")
|
||||||
)
|
|
||||||
|
|
||||||
# Assert that the difference is not more than 10%
|
|
||||||
assert (
|
assert (
|
||||||
percentage_diff < 10
|
avg_percent_diff < 10
|
||||||
), f"Performance difference of {percentage_diff:.2f}% exceeds 10% threshold"
|
), f"Average performance difference of {avg_percent_diff:.2f}% exceeds 10% threshold"
|
||||||
|
|
||||||
print(f"Performance difference: {percentage_diff:.2f}%")
|
|
||||||
|
|
||||||
except litellm.Timeout as e:
|
except litellm.Timeout as e:
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue