Skip to content

Commit 4fb451f

Browse files
authored
Merge branch 'main' into LANGPLAT-642/django.refactor.traced.response
2 parents 6d0488b + a04c67b commit 4fb451f

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

ddtrace/llmobs/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def _get_ml_app(span: Span) -> Optional[str]:
180180
if ml_app is not None:
181181
return ml_app
182182
llmobs_parent = _get_nearest_llmobs_ancestor(llmobs_parent)
183-
return ml_app or span.context._meta.get(PROPAGATED_ML_APP_KEY) or config._llmobs_ml_app
183+
return ml_app or span.context._meta.get(PROPAGATED_ML_APP_KEY) or config._llmobs_ml_app or config.service
184184

185185

186186
def _get_session_id(span: Span) -> Optional[str]:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
features:
3+
- |
4+
LLM Observability: ``ml_app`` is now optional, defaulting to ``service``. while it is still recommended to set ``ml_app``, enabling LLM Observability will no longer throw if one is not provided or propagated from an upstream service.

tests/llmobs/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,14 @@ def llmobs_no_ml_app(tracer):
288288
llmobs_service.disable()
289289

290290

291+
@pytest.fixture
292+
def llmobs_empty_ml_app(tracer):
293+
with override_global_config(dict(_llmobs_ml_app="")):
294+
llmobs_service.enable(_tracer=tracer)
295+
yield llmobs_service
296+
llmobs_service.disable()
297+
298+
291299
@pytest.fixture
292300
def llmobs_events(llmobs, llmobs_span_writer):
293301
return llmobs_span_writer.events

tests/llmobs/test_llmobs_service.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,18 @@ def test_service_enable_does_not_override_global_patch_config(mock_tracer_patch,
220220
llmobs_service.disable()
221221

222222

223-
def test_start_span_with_no_ml_app_throws(llmobs_no_ml_app):
224-
with pytest.raises(ValueError):
225-
with llmobs_no_ml_app.task():
226-
pass
223+
def test_start_span_with_no_ml_app_defaults_to_service_name(llmobs_no_ml_app):
224+
with llmobs_no_ml_app.task() as span:
225+
pass
226+
227+
assert span._get_ctx_item(ML_APP) == "tests.llmobs"
228+
229+
230+
def test_start_span_empty_ml_app_defaults_to_service_name(llmobs_empty_ml_app):
231+
with llmobs_empty_ml_app.task() as span:
232+
pass
233+
234+
assert span._get_ctx_item(ML_APP) == "tests.llmobs"
227235

228236

229237
def test_start_span_without_ml_app_does_noop():

0 commit comments

Comments
 (0)