simple test

This commit is contained in:
yujonglee 2024-06-04 13:56:28 +09:00
parent 541336a001
commit 6652227c25
2 changed files with 26 additions and 27 deletions

View file

@ -0,0 +1,26 @@
import asyncio
import litellm
from litellm.integrations.opentelemetry import OpenTelemetry, OpenTelemetryConfig
from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter
def test_otel_callback():
exporter = InMemorySpanExporter()
litellm.callbacks = [OpenTelemetry(OpenTelemetryConfig(exporter=exporter))]
litellm.completion(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "hi"}],
)
asyncio.run(
litellm.acompletion(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "hi"}],
)
)
spans = exporter.get_finished_spans()
assert len(spans) == 1 + 1