-
Notifications
You must be signed in to change notification settings - Fork 418
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
chore(llmobs): update ragas trace ml app #11952
base: main
Are you sure you want to change the base?
Conversation
|
@@ -290,6 +286,10 @@ def _stop_service(self) -> None: | |||
except ServiceStatusError: | |||
log.debug("Error stopping LLMObs writers") | |||
|
|||
# Remove listener hooks for span events |
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 makes sure hooks aren't removed prematurely while ragas is still running as triggered by self._evaluator_runner.stop()
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.
Was this triggering any bugs?
ddtrace/llmobs/_llmobs.py
Outdated
span._set_ctx_item(ML_APP, ml_app) | ||
|
||
is_ragas_integration_span = False | ||
|
||
if ml_app.startswith(constants.RAGAS_ML_APP_PREFIX): | ||
if ml_app.startswith(constants.TEMP_RAGAS_ML_APP_PREFIX): | ||
is_ragas_integration_span = True | ||
ml_app = ml_app.replace(constants.TEMP_RAGAS_ML_APP_PREFIX, "") |
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.
I'm not a fan of this temporary set/replace/remove behavior. What is the ultimate goal of using the ragas temp prefix? Can we not set a ragas identifier onto the span's internal store object instead of relying on a temporary ml app name?
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.
thanks for the suggestion, just added in logic to use the span's store instead
… into evan.li/ragas-ml-app
RAGAS_ML_APP_PREFIX = "dd-ragas" | ||
# All ragas traces have this context item set so we can differentiate | ||
# spans generated from the ragas integration vs user application spans. | ||
IS_EVALUATION_SPAN = "_is_evaluation_span" |
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.
IS_EVALUATION_SPAN = "_is_evaluation_span" | |
IS_EVALUATION_SPAN = "_ml_obs.evaluation_span" |
Let's use the _ml_obs prefix to make it clear this is coming from us (for future reviewers/users)
is_evaluation_span = _is_evaluation_span(span) | ||
span._set_ctx_item(IS_EVALUATION_SPAN, is_evaluation_span) |
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.
Do we need this check in this function scope?
@@ -210,9 +210,9 @@ def _llmobs_span_event(cls, span: Span) -> Tuple[Dict[str, Any], bool]: | |||
llmobs_span_event["session_id"] = session_id | |||
|
|||
llmobs_span_event["tags"] = cls._llmobs_tags( | |||
span, ml_app, session_id, is_ragas_integration_span=is_ragas_integration_span | |||
span, ml_app, session_id, is_ragas_integration_span=is_evaluation_span |
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.
Seems like we don't necessarily need to pass this information in to _llmobs_tags()
or even return it from this function. Thoughts on just doing the checks individually when needed instead of passing it around?
@@ -290,6 +286,10 @@ def _stop_service(self) -> None: | |||
except ServiceStatusError: | |||
log.debug("Error stopping LLMObs writers") | |||
|
|||
# Remove listener hooks for span events |
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.
Was this triggering any bugs?
while llmobs_parent: | ||
is_evaluation_span = llmobs_parent._get_ctx_item(IS_EVALUATION_SPAN) | ||
if is_evaluation_span is not None: | ||
return is_evaluation_span |
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.
Let's do a bool check to be defensive here
Update the ml application of any ragas evaluation span to be the same as the span being evaluated.
Refresher:
Previous Implementation:
dd-ragas-
prefix to the ML application name for RAGAS spansNow:
_dd_ragas
prefix on ragas span's ml app for identification purposes, except only temporarily.An alternative solution is to utilize
annotation_contexts
to set a tag on auto-instrumented ragas spans. This is a larger refactor that i would like to explore when we clean up the ragas evaluators (more cleanly separate tracing setup vs actual eval logic).Checklist
Reviewer Checklist