-
Notifications
You must be signed in to change notification settings - Fork 441
[MLOB-3112] make shared base classes for llmobs traced streams #13736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Bootstrap import analysisComparison of import times between this PR and base. SummaryThe average import time from this PR is: 286 ± 4 ms. The average import time from base is: 293 ± 7 ms. The import time difference between this PR and base is: -7.3 ± 0.3 ms. Import time breakdownThe following import paths have shrunk:
|
|
||
def __exit__(self, exc_type, exc_val, exc_tb): | ||
self.__wrapped__.__exit__(exc_type, exc_val, exc_tb) | ||
class BaseOpenAIStreamHandler: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BenchmarksBenchmark execution time: 2025-06-23 20:03:58 Comparing candidate commit 7626f40 in PR branch Found 0 performance improvements and 2 performance regressions! Performance is the same for 499 metrics, 3 unstable metrics. scenario:iastaspects-lower_aspect
scenario:iastaspects-upper_aspect
|
) | ||
self._dd_span.finish() | ||
|
||
class BaseVertexAIStreamHandler: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from ddtrace.llmobs._integrations.utils import get_generation_config_google | ||
from ddtrace.llmobs._integrations.utils import get_system_instructions_from_google_model | ||
from ddtrace.llmobs._integrations.utils import tag_request_content_part_google | ||
from ddtrace.llmobs._integrations.utils import tag_response_part_google | ||
|
||
class BaseGoogleGenerativeAIStramHandler: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return traced_stream | ||
|
||
async def __aexit__(self, exc_type, exc_val, exc_tb): | ||
await self.__wrapped__.__aexit__(exc_type, exc_val, exc_tb) | ||
class BaseAnthropicStreamHandler: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from ddtrace.llmobs._integrations.base_stream_handler import make_traced_stream | ||
from ddtrace.llmobs._integrations.base_stream_handler import StreamHandler | ||
|
||
class BaseLangchainStreamHandler: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR attempts to create shared base classes for tracing streams in our LLMObs integrations. The Anthropic, Gemini, Langchain, LiteLLM, Open AI / Azure Open AI, and Vertex AI integrations were all refactored to use this new standardized interface.
How it works
todo
Checklist
Reviewer Checklist