Skip to content

Commit fdd3934

Browse files
authored
chore: add debug logging for llm span type and openai operations (#14386)
This PR adds additional debug logging: - Logging the llm span type - Logging OpenAI operations when creating LLM spans [MLOB-3526] ## Checklist - [x] PR author has checked that all the criteria below are met - The PR description includes an overview of the change - The PR description articulates the motivation for the change - The change includes tests OR the PR description describes a testing strategy - The PR description notes risks associated with the change, if any - Newly-added code is easy to change - The change follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) - The change includes or references documentation updates if necessary - Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Reviewer has checked that all the criteria below are met - Title is accurate - All changes are related to the pull request's stated goal - Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - Testing strategy adequately addresses listed risks - Newly-added code is easy to change - Release note makes sense to a user of the library - If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) [MLOB-3526]: https://datadoghq.atlassian.net/browse/MLOB-3526?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent 189052f commit fdd3934

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

ddtrace/llmobs/_integrations/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def trace(self, pin: Pin, operation_id: str, submit_to_llmobs: bool = False, **k
6565
service=int_service(pin, self.integration_config),
6666
span_type=SpanTypes.LLM if (submit_to_llmobs and self.llmobs_enabled) else None,
6767
)
68+
log.debug("Creating LLM span with type %s", span.span_type)
6869
# determine if the span represents a proxy request
6970
base_url = self._get_base_url(**kwargs)
7071
if self._is_instrumented_proxy_url(base_url):

ddtrace/llmobs/_integrations/openai.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from ddtrace._trace.pin import Pin
77
from ddtrace.internal.constants import COMPONENT
8+
from ddtrace.internal.logger import get_logger
89
from ddtrace.internal.utils.version import parse_version
910
from ddtrace.llmobs._constants import CACHE_READ_INPUT_TOKENS_METRIC_KEY
1011
from ddtrace.llmobs._constants import INPUT_DOCUMENTS
@@ -30,6 +31,9 @@
3031
from ddtrace.trace import Span
3132

3233

34+
log = get_logger(__name__)
35+
36+
3337
class OpenAIIntegration(BaseLLMIntegration):
3438
_integration_name = "openai"
3539

@@ -59,6 +63,7 @@ def trace(self, pin: Pin, operation_id: str, submit_to_llmobs: bool = False, **k
5963
traced_operations = ("createCompletion", "createChatCompletion", "createEmbedding", "createResponse")
6064
if operation_id in traced_operations:
6165
submit_to_llmobs = True
66+
log.debug("Creating LLM span for openai operation: %s", operation_id)
6267
return super().trace(pin, operation_id, submit_to_llmobs, **kwargs)
6368

6469
def _set_base_span_tags(self, span: Span, **kwargs) -> None:

0 commit comments

Comments
 (0)