diff --git a/skyvern/__init__.py b/skyvern/__init__.py index 88f066c7..b374bba5 100644 --- a/skyvern/__init__.py +++ b/skyvern/__init__.py @@ -1,15 +1,23 @@ from ddtrace import tracer -from ddtrace.filters import FilterRequestsOnUrl - +from ddtrace.trace import TraceFilter, Span +from ddtrace.ext import http +import re from skyvern.forge.sdk.forge_log import setup_logger -tracer.configure( - settings={ - "FILTERS": [ - FilterRequestsOnUrl(r"http://.*/heartbeat$"), - ], - }, -) + +class FilterHeartbeat(TraceFilter): + _HB_URL = re.compile(r"http://.*/heartbeat$") + + def process_trace(self, trace: list[Span]) -> list[Span] | None: + for span in trace: + url = span.get_tag(http.URL) + if span.parent_id is None and url is not None and self._HB_URL.match(url): + # drop the full trace chunk + return None + return trace + + +tracer.configure(trace_processors=[FilterHeartbeat()]) setup_logger()