Skip to content
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
1 change: 1 addition & 0 deletions Containerfile.sweep
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ RUN pip3 install -v --no-cache-dir \
jinja2 \
redis \
specfile \
sentry-sdk>=2.13.0 \
&& dnf -y remove gcc gcc-c++ python3-devel \
&& dnf clean all

Expand Down
2 changes: 2 additions & 0 deletions openshift/cronjob-sweep-dependency.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ spec:
name: jira-env
- secretRef:
name: jira-env
- secretRef:
name: sentry-env
resources:
limits:
cpu: "200m"
Expand Down
2 changes: 2 additions & 0 deletions openshift/cronjob-sweep-no-patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ spec:
name: jira-env
- secretRef:
name: jira-env
- secretRef:
name: sentry-env
resources:
limits:
cpu: "200m"
Expand Down
2 changes: 2 additions & 0 deletions openshift/cronjob-sweep-pr-pending.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ spec:
name: jira-env
- secretRef:
name: gitlab-env
- secretRef:
name: sentry-env
resources:
limits:
cpu: "200m"
Expand Down
2 changes: 2 additions & 0 deletions openshift/cronjob-sweep-y-stream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ spec:
name: jira-env
- secretRef:
name: jira-env
- secretRef:
name: sentry-env
resources:
limits:
cpu: "200m"
Expand Down
3 changes: 1 addition & 2 deletions ymir/agents/backport_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
get_agent_execution_config,
get_chat_model,
get_tool_call_checker_config,
init_sentry,
is_reasoning_enabled,
mcp_tools,
render_template,
Expand Down Expand Up @@ -95,7 +94,7 @@
ShippedZStreamCandidate,
Task,
)
from ymir.common.utils import get_all_patches
from ymir.common.utils import get_all_patches, init_sentry
from ymir.common.version_utils import is_older_zstream, parse_rhel_version
from ymir.tools.unprivileged.commands import RunShellCommandTool
from ymir.tools.unprivileged.distgit_detector import DistgitDetectorTool
Expand Down
3 changes: 1 addition & 2 deletions ymir/agents/mr_consolidation_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
get_agent_execution_config,
get_chat_model,
get_tool_call_checker_config,
init_sentry,
is_reasoning_enabled,
mcp_tools,
render_template,
Expand All @@ -62,7 +61,7 @@
MRConsolidationInputSchema,
MRConsolidationOutputSchema,
)
from ymir.common.utils import get_all_patches
from ymir.common.utils import get_all_patches, init_sentry
from ymir.tools.unprivileged.commands import RunShellCommandTool
from ymir.tools.unprivileged.filesystem import GetCWDTool, RemoveTool
from ymir.tools.unprivileged.specfile import GetPackageInfoTool
Expand Down
3 changes: 1 addition & 2 deletions ymir/agents/rebase_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
get_agent_execution_config,
get_chat_model,
get_tool_call_checker_config,
init_sentry,
is_reasoning_enabled,
mcp_tools,
render_template,
Expand All @@ -63,7 +62,7 @@
RebaseOutputSchema,
Task,
)
from ymir.common.utils import extract_text_from_adf
from ymir.common.utils import extract_text_from_adf, init_sentry
from ymir.tools.unprivileged.commands import RunShellCommandTool
from ymir.tools.unprivileged.filesystem import GetCWDTool, RemoveTool
from ymir.tools.unprivileged.text import (
Expand Down
2 changes: 1 addition & 1 deletion ymir/agents/rebuild_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from ymir.agents.utils import (
format_mr_triage_details,
get_agent_execution_config,
init_sentry,
mcp_tools,
render_template,
resolve_chat_model_override,
Expand All @@ -45,6 +44,7 @@
RebuildOutputSchema,
Task,
)
from ymir.common.utils import init_sentry

logger = logging.getLogger(__file__)
redis_logger = logging.getLogger("agent.redis")
Expand Down
2 changes: 1 addition & 1 deletion ymir/agents/reproducer_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
get_agent_execution_config,
get_chat_model,
get_tool_call_checker_config,
init_sentry,
is_reasoning_enabled,
mcp_tools,
render_template,
Expand Down Expand Up @@ -61,6 +60,7 @@
sweep_stale_reproducer_locks,
try_acquire_reproducer_lock,
)
from ymir.common.utils import init_sentry
from ymir.common.version_utils import construct_internal_branch_name, parse_rhel_version
from ymir.tools.privileged.jira import fetch_jira_issue_issuelinks
from ymir.tools.unprivileged.commands import RunShellCommandTool
Expand Down
2 changes: 1 addition & 1 deletion ymir/agents/triage_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
get_agent_execution_config,
get_chat_model,
get_tool_call_checker_config,
init_sentry,
is_reasoning_enabled,
mcp_tools,
render_template,
Expand Down Expand Up @@ -74,6 +73,7 @@
check_build_in_buildroot,
extract_text_from_adf,
get_latest_candidate_build,
init_sentry,
)
from ymir.common.version_utils import (
construct_internal_branch_name,
Expand Down
36 changes: 0 additions & 36 deletions ymir/agents/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,39 +209,3 @@ def format_mr_triage_details(
body = "\n\n".join(parts)
return wrap_details("Triage Details", body) + "\n\n"
return ""


def init_sentry() -> None:
"""Initialize Sentry, if the DSN is set."""
if not (dsn := os.getenv("SENTRY_DSN")):
# no DSN, no reporting
return

import sentry_sdk
from sentry_sdk.integrations.asyncio import AsyncioIntegration
from sentry_sdk.integrations.litellm import LiteLLMIntegration
from sentry_sdk.integrations.logging import (
ignore_logger,
ignore_logger_for_sentry_logs,
)

sentry_sdk.init(
dsn=dsn,
environment=os.getenv("SENTRY_ENVIRONMENT"),
enable_logs=True,
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# Add data like inputs and responses;
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
stream_gen_ai_spans=True,
send_default_pii=True,
integrations=[
AsyncioIntegration(),
LiteLLMIntegration(),
],
)

for ignored_logger in ("agent.redis", "agent.task_loop", "agent.trajectory"):
ignore_logger(ignored_logger)
ignore_logger_for_sentry_logs(ignored_logger)
37 changes: 37 additions & 0 deletions ymir/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import asyncio
import logging
import os
from collections.abc import AsyncGenerator, Callable
from contextlib import asynccontextmanager
from datetime import timedelta
Expand Down Expand Up @@ -401,3 +402,39 @@ def extract_text_from_adf(adf_body) -> str:
if isinstance(adf_body, list):
return " ".join(extract_text_from_adf(item) for item in adf_body)
return ""


def init_sentry() -> None:
"""Initialize Sentry, if the DSN is set."""
if not (dsn := os.getenv("SENTRY_DSN")):
# no DSN, no reporting
return

import sentry_sdk
from sentry_sdk.integrations.asyncio import AsyncioIntegration
from sentry_sdk.integrations.litellm import LiteLLMIntegration
from sentry_sdk.integrations.logging import (
ignore_logger,
ignore_logger_for_sentry_logs,
)

sentry_sdk.init(
dsn=dsn,
environment=os.getenv("SENTRY_ENVIRONMENT"),
enable_logs=True,
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# Add data like inputs and responses;
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
stream_gen_ai_spans=True,
send_default_pii=True,
integrations=[
AsyncioIntegration(),
LiteLLMIntegration(),
],
)

for ignored_logger in ("agent.redis", "agent.task_loop", "agent.trajectory"):
ignore_logger(ignored_logger)
ignore_logger_for_sentry_logs(ignored_logger)
14 changes: 8 additions & 6 deletions ymir/sweep/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,13 @@
import sys

from ymir.common.base_utils import redis_client
from ymir.common.utils import init_sentry
from ymir.supervisor.http_utils import with_requests_session
from ymir.sweep.dependency import DependencySweep
from ymir.sweep.no_patch import NoPatchSweep
from ymir.sweep.pr_pending import PRPendingSweep
from ymir.sweep.y_stream import YStreamSweep

logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s %(message)s",
stream=sys.stdout,
)

logger = logging.getLogger(__name__)

STRATEGIES: dict = {
Expand Down Expand Up @@ -59,6 +54,13 @@ async def run_sweep(strategy_names: list[str]) -> None:


if __name__ == "__main__":
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s %(message)s",
stream=sys.stdout,
)
init_sentry()
Comment thread
jpodivin marked this conversation as resolved.

parser = argparse.ArgumentParser(description="Run postponed-issue sweep")
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
Expand Down
Loading