Skip to content

Commit

Permalink
revert removing llm spantype if llmobs disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Yun-Kim committed May 29, 2024
1 parent 0d4c6fa commit f2732a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ddtrace/llmobs/_integrations/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def trace(self, pin: Pin, operation_id: str, submit_to_llmobs: bool = False, **k
self._set_base_span_tags(span, **kwargs)
if submit_to_llmobs:
span.span_type = SpanTypes.LLM
if span.get_tag(PROPAGATED_PARENT_ID_KEY) is None:
if self.llmobs_enabled and span.get_tag(PROPAGATED_PARENT_ID_KEY) is None:
# For non-distributed traces or spans in the first service of a distributed trace,
# The LLMObs parent ID tag is not set at span start time. We need to manually set the parent ID tag now
# in these cases to avoid conflicting with the later propagated tags.
Expand Down
6 changes: 6 additions & 0 deletions ddtrace/llmobs/_integrations/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
from ddtrace.llmobs._constants import MODEL_NAME
from ddtrace.llmobs._constants import MODEL_PROVIDER
from ddtrace.llmobs._constants import OUTPUT_MESSAGES
from ddtrace.llmobs._constants import PARENT_ID_KEY
from ddtrace.llmobs._constants import PROPAGATED_PARENT_ID_KEY
from ddtrace.llmobs._constants import SPAN_KIND
from ddtrace.llmobs._integrations import BaseLLMIntegration
from ddtrace.llmobs._utils import _get_llmobs_parent_id


log = get_logger(__name__)
Expand All @@ -31,6 +34,9 @@ def llmobs_set_tags(
"""Extract prompt/response tags from a completion and set them as temporary "_ml_obs.*" tags."""
if not self.llmobs_enabled:
return
if span.get_tag(PROPAGATED_PARENT_ID_KEY) is None:
parent_id = _get_llmobs_parent_id(span) or "undefined"
span.set_tag(PARENT_ID_KEY, parent_id)
parameters = {"temperature": float(span.get_tag("bedrock.request.temperature") or 0.0)}
max_tokens = int(span.get_tag("bedrock.request.max_tokens") or 0)
if max_tokens:
Expand Down

0 comments on commit f2732a7

Please sign in to comment.