Skip to content

Commit 1257b4c

Browse files
committed
feat(tracer): filter tracer http logs
1 parent 31a1254 commit 1257b4c

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

sdk/langchain/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath-langchain"
3-
version = "0.0.82"
3+
version = "0.0.83"
44
description = "UiPath Langchain"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.9"

sdk/langchain/uipath_langchain/tracers/AsyncUiPathTracer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
from langchain_core.tracers.schemas import Run
1414
from pydantic import PydanticDeprecationWarning
1515

16-
from ._utils import _simple_serialize_defaults
16+
from ._utils import _setup_tracer_httpx_logging, _simple_serialize_defaults
1717

1818
logger = logging.getLogger(__name__)
1919

20+
_setup_tracer_httpx_logging("/llmops_/api/Agent/trace/")
21+
2022

2123
class Status:
2224
SUCCESS = 1

sdk/langchain/uipath_langchain/tracers/_utils.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,35 @@
11
import datetime
2+
import logging
23
from zoneinfo import ZoneInfo
34

45

6+
class IgnoreSpecificUrl(logging.Filter):
7+
def __init__(self, url_to_ignore):
8+
super().__init__()
9+
self.url_to_ignore = url_to_ignore
10+
11+
def filter(self, record):
12+
try:
13+
if record.msg == 'HTTP Request: %s %s "%s %d %s"':
14+
# Ignore the log if the URL matches the one we want to ignore
15+
method = record.args[0]
16+
url = record.args[1]
17+
18+
if method == "POST" and url.path.endswith(self.url_to_ignore):
19+
# Check if the URL contains the specific path we want to ignore
20+
return True
21+
return False
22+
23+
except Exception:
24+
return False
25+
26+
27+
def _setup_tracer_httpx_logging(url: str):
28+
# Create a custom logger for httpx
29+
# Add the custom filter to the root logger
30+
logging.getLogger("httpx").addFilter(IgnoreSpecificUrl(url))
31+
32+
533
def _simple_serialize_defaults(obj):
634
if hasattr(obj, "model_dump"):
735
return obj.model_dump(exclude_none=True, mode="json")

0 commit comments

Comments
 (0)