Skip to content

feat(tracer): filter tracer http logs #235

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

Merged
merged 1 commit into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/langchain/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath-langchain"
version = "0.0.82"
version = "0.0.83"
description = "UiPath Langchain"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.9"
Expand Down
4 changes: 3 additions & 1 deletion sdk/langchain/uipath_langchain/tracers/AsyncUiPathTracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
from langchain_core.tracers.schemas import Run
from pydantic import PydanticDeprecationWarning

from ._utils import _simple_serialize_defaults
from ._utils import _setup_tracer_httpx_logging, _simple_serialize_defaults

logger = logging.getLogger(__name__)

_setup_tracer_httpx_logging("/llmops_/api/Agent/trace/")


class Status:
SUCCESS = 1
Expand Down
28 changes: 28 additions & 0 deletions sdk/langchain/uipath_langchain/tracers/_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
import datetime
import logging
from zoneinfo import ZoneInfo


class IgnoreSpecificUrl(logging.Filter):
def __init__(self, url_to_ignore):
super().__init__()
self.url_to_ignore = url_to_ignore

def filter(self, record):
try:
if record.msg == 'HTTP Request: %s %s "%s %d %s"':
# Ignore the log if the URL matches the one we want to ignore
method = record.args[0]
url = record.args[1]

if method == "POST" and url.path.endswith(self.url_to_ignore):
# Check if the URL contains the specific path we want to ignore
return True
return False

except Exception:
return False


def _setup_tracer_httpx_logging(url: str):
# Create a custom logger for httpx
# Add the custom filter to the root logger
logging.getLogger("httpx").addFilter(IgnoreSpecificUrl(url))


def _simple_serialize_defaults(obj):
if hasattr(obj, "model_dump"):
return obj.model_dump(exclude_none=True, mode="json")
Expand Down
Loading