Skip to content

Commit

Permalink
fix_the_test
Browse files Browse the repository at this point in the history
  • Loading branch information
Gekko0114 committed Sep 30, 2024
1 parent ee3ff0f commit bcb7ea4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
8 changes: 4 additions & 4 deletions ddtrace/llmobs/_llmobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ def enable(
:param str env: Your environment name.
:param str service: Your service name.
"""
if cls.enabled:
log.debug("%s already enabled", cls.__name__)
return

if os.getenv("DD_LLMOBS_ENABLED") and not asbool(os.getenv("DD_LLMOBS_ENABLED")):
log.debug("LLMObs.enable() called when DD_LLMOBS_ENABLED is set to false or 0, not starting LLMObs service")
cls.enabled = False
return

if cls.enabled:
log.debug("%s already enabled", cls.__name__)
return
# grab required values for LLMObs
config._dd_site = site or config._dd_site
config._dd_api_key = api_key or config._dd_api_key
Expand Down
5 changes: 1 addition & 4 deletions tests/llmobs/test_llmobs_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def test_llm_span(LLMObs, mock_llmobs_span_writer):

def test_llm_span_with_dd_llmobs_disabled(LLMObs, mock_llmobs_span_writer, monkeypatch):
monkeypatch.setenv("DD_LLMOBS_ENABLED", "0")
assert llmobs_service.enabled
LLMObs.enable()

with LLMObs.llm(model_name="test_model", name="test_llm_call", model_provider="test_provider") as span:
Expand All @@ -225,13 +226,9 @@ def test_llm_span_with_dd_llmobs_disabled(LLMObs, mock_llmobs_span_writer, monke
assert span.get_tag(MODEL_NAME) == "test_model"
assert span.get_tag(MODEL_PROVIDER) == "test_provider"

mock_llmobs_span_writer.enqueue.assert_called_with(
_expected_llmobs_llm_span_event(span, "llm", model_name="test_model", model_provider="test_provider")
)
assert not llmobs_service.enabled



def test_llm_span_agentless(AgentlessLLMObs, mock_llmobs_span_agentless_writer):
with AgentlessLLMObs.llm(model_name="test_model", name="test_llm_call", model_provider="test_provider") as span:
assert span.name == "test_llm_call"
Expand Down

0 comments on commit bcb7ea4

Please sign in to comment.