-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(Feat)
datadog_llm_observability
callback - emit request_tags
on …
…logs (#7883) * dd - emit tags on llm obs payload * dd - show requester tags on traces * test_get_datadog_tags * _get_datadog_tags * fix dd POD_NAME * test_get_datadog_tags
- Loading branch information
1 parent
4b88635
commit 806df5d
Showing
5 changed files
with
82 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -274,7 +274,9 @@ def create_datadog_logging_payload( | |
|
||
dd_payload = DatadogPayload( | ||
ddsource=self._get_datadog_source(), | ||
ddtags=self._get_datadog_tags(), | ||
ddtags=self._get_datadog_tags( | ||
standard_logging_object=standard_logging_object | ||
), | ||
hostname=self._get_datadog_hostname(), | ||
message=json_payload, | ||
service=self._get_datadog_service(), | ||
|
@@ -444,8 +446,33 @@ def _create_v0_logging_payload( | |
return dd_payload | ||
|
||
@staticmethod | ||
def _get_datadog_tags(): | ||
return f"env:{os.getenv('DD_ENV', 'unknown')},service:{os.getenv('DD_SERVICE', 'litellm')},version:{os.getenv('DD_VERSION', 'unknown')},HOSTNAME:{DataDogLogger._get_datadog_hostname()},POD_NAME:{os.getenv('POD_NAME', 'unknown')}" | ||
def _get_datadog_tags( | ||
standard_logging_object: Optional[StandardLoggingPayload] = None, | ||
) -> str: | ||
""" | ||
Get the datadog tags for the request | ||
DD tags need to be as follows: | ||
- tags: ["user_handle:[email protected]", "app_version:1.0.0"] | ||
""" | ||
base_tags = { | ||
"env": os.getenv("DD_ENV", "unknown"), | ||
"service": os.getenv("DD_SERVICE", "litellm"), | ||
"version": os.getenv("DD_VERSION", "unknown"), | ||
"HOSTNAME": DataDogLogger._get_datadog_hostname(), | ||
"POD_NAME": os.getenv("POD_NAME", "unknown"), | ||
} | ||
|
||
tags = [f"{k}:{v}" for k, v in base_tags.items()] | ||
|
||
if standard_logging_object: | ||
_request_tags: List[str] = ( | ||
standard_logging_object.get("request_tags", []) or [] | ||
) | ||
request_tags = [f"request_tag:{tag}" for tag in _request_tags] | ||
tags.extend(request_tags) | ||
|
||
return ",".join(tags) | ||
|
||
@staticmethod | ||
def _get_datadog_source(): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters