Skip to content

Commit

Permalink
remove dogstatsd error logs
Browse files Browse the repository at this point in the history
  • Loading branch information
mabdinur committed Feb 26, 2025
1 parent 03c302d commit 06d8a7e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import json
import os
from pathlib import Path
import re
import subprocess
import sys
import time
Expand Down Expand Up @@ -1230,7 +1231,9 @@ def __eq__(self, other):


def call_program(*args, **kwargs):
ignore_connection_errors = kwargs.pop("ignore_connection_errors", True)
timeout = kwargs.pop("timeout", None)

if "env" in kwargs:
# Remove all keys with the value None from env, None is used to unset an environment variable
env = kwargs.pop("env")
Expand All @@ -1243,9 +1246,21 @@ def call_program(*args, **kwargs):
except subprocess.TimeoutExpired:
subp.terminate()
stdout, stderr = subp.communicate(timeout=timeout)
if ignore_connection_errors:
stderr = remove_connection_error_logs(stderr)
return stdout, stderr, subp.wait(), subp.pid


def remove_connection_error_logs(text):
"""Remove connection error logs from the given text"""
# Removes dogstatsd connection error logs
# These connection errors are expected when runtime metrics are enabled and the test agent is used
# TODO: Update test-agent to support receiving dogstatsd metrics
pattern = rb"Error submitting packet: .*?, dropping the packet and closing the socket"
cleaned_text = re.sub(pattern, b"", text)
return cleaned_text


def request_token(request):
# type: (pytest.FixtureRequest) -> str
token = ""
Expand Down

0 comments on commit 06d8a7e

Please sign in to comment.