-
Notifications
You must be signed in to change notification settings - Fork 3.6k
feat(telemetry): tag content-bearing trace and log keys with lk.pii. for redaction AGT-3074 #6356
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?
Changes from all commits
1f004f7
1b8bf72
00c0dfc
4f142cd
b438a78
dacdcd4
355a42f
139dd3f
9294350
60a590a
2456461
a5a5aec
6421a84
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -673,7 +673,7 @@ def prepare_function_arguments( | |
| except ValueError as e: | ||
| logger.error( | ||
| f"error parsing arguments for `{fnc.info.name}`", | ||
| extra={"function": fnc.info.name, "arguments": json_arguments}, | ||
| extra={"function": fnc.info.name, "lk.pii.arguments": json_arguments}, | ||
| ) | ||
| raise ToolError(f"Error parsing arguments for `{fnc.info.name}`: {e}") from e | ||
|
|
||
|
|
@@ -692,13 +692,13 @@ def prepare_function_arguments( | |
| except (pydantic.ValidationError, ValueError, TypeError) as e: | ||
| logger.error( | ||
| f"error parsing arguments for `{fnc.info.name}`", | ||
| extra={"function": fnc.info.name, "arguments": json_arguments}, | ||
| extra={"function": fnc.info.name, "lk.pii.arguments": json_arguments}, | ||
| ) | ||
| raise ToolError(f"Error parsing arguments for `{fnc.info.name}`: {e}") from e | ||
| except Exception: | ||
| logger.exception( | ||
| f"error parsing arguments for `{fnc.info.name}`", | ||
| extra={"function": fnc.info.name, "arguments": json_arguments}, | ||
| extra={"function": fnc.info.name, "lk.pii.arguments": json_arguments}, | ||
| ) | ||
| raise | ||
|
|
||
|
|
@@ -956,7 +956,7 @@ def make_function_call_output( | |
| if not _is_valid_function_output(output): | ||
| logger.error( | ||
| f"AI function `{fnc_call.name}` returned an invalid output", | ||
| extra={"call_id": fnc_call.call_id, "output": output}, | ||
| extra={"call_id": fnc_call.call_id, "lk.pii.output": output}, | ||
|
devin-ai-integration[bot] marked this conversation as resolved.
|
||
| ) | ||
| return FunctionCallResult( | ||
| fnc_call=fnc_call, | ||
|
|
@@ -1032,7 +1032,7 @@ async def execute_function_call( | |
| if not isinstance(e, ToolError): | ||
| logger.exception( | ||
| f"exception executing AI function `{tool_call.name}`", | ||
| extra={"call_id": tool_call.call_id, "arguments": tool_call.arguments}, | ||
| extra={"call_id": tool_call.call_id, "lk.pii.arguments": tool_call.arguments}, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Some logs still send tool arguments, transcripts and chat history in a form that cannot be scrubbed Several log entries that carry conversational data are still recorded under untagged names (e.g. alongside the tagged call at Untagged content-bearing log fields left behind by the renameThe PR tags content keys with an
Because the collector matches only on the Prompt for agentsWas this helpful? React with 👍 or 👎 to provide feedback.
devin-ai-integration[bot] marked this conversation as resolved.
|
||
| ) | ||
| out = make_function_call_output(fnc_call=fnc_call, output=None, exception=e) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,13 +6,41 @@ | |
|
|
||
| from opentelemetry import trace | ||
|
|
||
| from ..types import NOT_GIVEN, NotGivenOr | ||
| from . import trace_types | ||
|
|
||
| if TYPE_CHECKING: | ||
| from ..metrics import RealtimeModelMetrics | ||
|
|
||
|
|
||
| def record_exception(span: trace.Span, exception: Exception) -> None: | ||
| REDACTED_EXCEPTION_MESSAGE = "exception details redacted" | ||
|
|
||
|
|
||
| def _redaction_enabled() -> bool: | ||
| from ..job import get_job_context | ||
|
|
||
| job_ctx = get_job_context(required=False) | ||
| if job_ctx is None: | ||
| return False | ||
| return job_ctx._redaction_enabled | ||
|
|
||
|
|
||
| def record_exception( | ||
| span: trace.Span, exception: Exception, *, redacted: NotGivenOr[bool] = NOT_GIVEN | ||
| ) -> None: | ||
| if redacted is NOT_GIVEN: | ||
| redacted = _redaction_enabled() | ||
|
|
||
| if redacted: | ||
| attrs = { | ||
| trace_types.ATTR_EXCEPTION_TYPE: exception.__class__.__name__, | ||
| trace_types.ATTR_EXCEPTION_MESSAGE: REDACTED_EXCEPTION_MESSAGE, | ||
| } | ||
| span.add_event("exception", attrs) | ||
| span.set_status(trace.Status(trace.StatusCode.ERROR, REDACTED_EXCEPTION_MESSAGE)) | ||
| span.set_attributes(attrs) | ||
| return | ||
|
Comment on lines
+28
to
+42
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Error details can still reach telemetry uncensored when redaction is turned on Error text and stack traces are only suppressed for spans opened through the framework's own span helper ( Only _DynamicTracer.start_as_current_span is guarded; trace.use_span call sites keep OTel defaultsThe new guard rewrites kwargs only inside A fix would be to centralize the redaction decision (e.g. a wrapper around Was this helpful? React with 👍 or 👎 to provide feedback.
devin-ai-integration[bot] marked this conversation as resolved.
|
||
|
|
||
| span.record_exception(exception) | ||
| span.set_status(trace.Status(trace.StatusCode.ERROR, str(exception))) | ||
| # set the exception in span attributes in case the exception event is not rendered | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.