Skip to content

feat(sentry): add uptime section to morning digest via sentry-summary skill (#4070)#4133

Open
Devesh36 wants to merge 5 commits into
Tracer-Cloud:mainfrom
Devesh36:sentry
Open

feat(sentry): add uptime section to morning digest via sentry-summary skill (#4070)#4133
Devesh36 wants to merge 5 commits into
Tracer-Cloud:mainfrom
Devesh36:sentry

Conversation

@Devesh36

@Devesh36 Devesh36 commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Fixes #4070

Describe the changes you have made in this PR -

Adds slice 1 of the Sentry uptime follow-ups: morning digest can now include an Uptime / downtime (last 24h) section, delivered through the existing sentry-summary skill + gateway headless runner — not a new deterministic digest module.

What changed

  • Uptime watch transition log (integrations/sentry/uptime.py)

    • Persist DOWN / RECOVERED events in WatchState.transitions
    • 7-day retention with founding-DOWN pinning for open incidents
    • load_all_watch_states() to merge history across watch tasks
  • New agent tool (get_sentry_uptime_digest)

    • Reads the local watch transition log and returns structured rollup data
    • Supports still-down monitors, recovered-in-window, project scoping, and host-level dedupe
    • Used by the agent during morning digest composition
  • sentry-summary skill (integrations/sentry/tools/skills/sentry-summary/SKILL.md)

    • Adds get_sentry_uptime_digest to the skill tool list
    • New uptime step: still-down before Issues, recovered after Issues
    • Quiet when no uptime watch history exists
  • Morning digest runner (integrations/sentry/morning_digest_runner.py)

    • Keeps the headless gateway/skill path (LLM + tools)
    • Prompt extended to include uptime status from the watch transition log
  • Docs (docs/sentry.mdx)

    • Morning digest runs via sentry-summary skill through the gateway
    • Uptime section requires a running uptime watch schedule

Out of scope (remaining #4070 follow-ups)

  • Inbound Sentry webhooks
  • Auto-remediation + attempt report

Demo/Screenshot for feature changes and bug fixes -

Flow:

Scheduler → morning_digest_runner → HeadlessAgent (gateway)
  → sentry-summary skill
    → search_sentry_issues
    → get_sentry_uptime_digest
  → LLM composes digest → Slack/Telegram

Example digest shape:

  • Header + summary (Issues count + Uptime count)
  • [DOWN] Still down section (if any) — above Issues
  • Issues themes + focus list
  • [RECOVERED] In window section (if any) — after Issues

@github-actions

Copy link
Copy Markdown
Contributor

Greptile code review

This repo uses Greptile for automated review. Before merge, aim for Confidence Score: 5/5 with zero unresolved review threads — see CONTRIBUTING.md.

Run a review — add a PR comment with:

@greptile review

Give it ~5-10 minutes (sometimes longer) for results, then fix feedback and re-trigger until you reach Confidence Score: 5/5.

Optional: automate with the greploop skill.

@greptile-apps

greptile-apps Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR delivers slice 1 of #4070 by wiring a new get_sentry_uptime_digest tool into the existing sentry-summary skill so the morning digest can include a downtime/recovery section alongside Sentry issues.

  • Transition persistence in uptime.py: adds UptimeTransitionRecord, append_transition_records, prune_transition_records (7-day retention with founding-DOWN pinning for open incidents), and load_all_watch_states to merge history across watch tasks.
  • New agent tool (sentry_uptime_digest_tool): reads the local watch state file, merges transitions across tasks, classifies monitors as still-down or recovered-in-window, and returns a structured rollup payload consumed by the LLM during digest composition.
  • SKILL.md + prompt update: get_sentry_uptime_digest is added to the skill's tool list with ordering instructions (still-down before Issues, recovered after Issues); the digest base prompt now references uptime status.

Confidence Score: 5/5

Safe to merge; the new tool reads only the local state file and the skill integration is additive and quiet when no watch history exists.

The core transition-persistence logic in uptime.py is well-tested and handles the important edge cases (7-day retention, founding-DOWN pinning, atomic state saves). The two concerns are structural: the early-exit paths of get_sentry_uptime_digest return a narrower dict than the success path, and the availability check couples a local-disk read to Sentry API connectivity. Neither affects correctness under normal operation.

integrations/sentry/tools/sentry_uptime_digest_tool/init.py — early-return response shape and is_available check.

Important Files Changed

Filename Overview
integrations/sentry/tools/sentry_uptime_digest_tool/init.py New agent tool reading the local watch transition log; two P2 concerns: inconsistent response schema on early-exit paths and an overly strict availability check tied to Sentry API connectivity for a local-disk-only operation.
integrations/sentry/uptime.py Adds transition persistence (UptimeTransitionRecord, append_transition_records, prune_transition_records, load_all_watch_states); pinning, retention, and atomic save logic look correct.
integrations/sentry/morning_digest_runner.py Minimal change — prompt extended to include uptime context; _apply_digest_project_scope is still present and called correctly.
integrations/sentry/tools/skills/sentry-summary/SKILL.md Adds get_sentry_uptime_digest to the tool list and new steps for uptime section placement (still-down before Issues, recovered after Issues).
tests/integrations/sentry/test_morning_digest_scope.py File deleted; the _apply_digest_project_scope function it tested still exists and is called in morning_digest_runner.py — minor coverage gap.
tests/integrations/sentry/test_uptime_digest_tool.py New test file covering still-down, recovered, no-incidents, and no-history scenarios for get_sentry_uptime_digest.
tests/integrations/sentry/test_uptime.py Adds transition-record round-trip, pruning, and open-incident pinning tests; also tests transition_record_from metadata preservation.
tests/integrations/sentry/test_morning_digest_runner.py Adds test asserting uptime instruction present in the digest prompt.
tests/core/tool_framework/test_skill_guidance.py Updated to assert four sentry tools and that get_sentry_uptime_digest appears in skill content.
docs/sentry.mdx Documentation updated to describe uptime section, watch-schedule requirement, and gateway skill path.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Scheduler
    participant Runner as morning_digest_runner
    participant Harness as HeadlessAgent (gateway)
    participant Skill as sentry-summary skill (LLM)
    participant SentryAPI as Sentry API
    participant Disk as Local state file

    Scheduler->>Runner: run_sentry_morning_digest(payload)
    Runner->>Harness: dispatch(prompt)
    Harness->>Skill: invoke with tools
    Skill->>SentryAPI: search_sentry_issues
    SentryAPI-->>Skill: issue digest
    Skill->>Disk: get_sentry_uptime_digest → load_all_watch_states()
    Disk-->>Skill: "{still_down, recovered, ...}"
    Skill->>Skill: compose digest (DOWN → Issues → RECOVERED)
    Skill-->>Harness: formatted report
    Harness-->>Runner: ShellTurnResult
    Runner-->>Scheduler: report string (→ Slack/Telegram)

    note over Disk: Written by run_uptime_watch_tick on each poll tick (separate schedule)
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Scheduler
    participant Runner as morning_digest_runner
    participant Harness as HeadlessAgent (gateway)
    participant Skill as sentry-summary skill (LLM)
    participant SentryAPI as Sentry API
    participant Disk as Local state file

    Scheduler->>Runner: run_sentry_morning_digest(payload)
    Runner->>Harness: dispatch(prompt)
    Harness->>Skill: invoke with tools
    Skill->>SentryAPI: search_sentry_issues
    SentryAPI-->>Skill: issue digest
    Skill->>Disk: get_sentry_uptime_digest → load_all_watch_states()
    Disk-->>Skill: "{still_down, recovered, ...}"
    Skill->>Skill: compose digest (DOWN → Issues → RECOVERED)
    Skill-->>Harness: formatted report
    Harness-->>Runner: ShellTurnResult
    Runner-->>Scheduler: report string (→ Slack/Telegram)

    note over Disk: Written by run_uptime_watch_tick on each poll tick (separate schedule)
Loading

Reviews (4): Last reviewed commit: "refactor(sentry): update morning digest ..." | Re-trigger Greptile

Comment thread platform/scheduler/executor.py Outdated
Comment thread integrations/sentry/morning_digest.py Outdated
Comment thread integrations/sentry/morning_digest.py Outdated
Comment thread integrations/sentry/morning_digest.py Outdated
@Devesh36

Copy link
Copy Markdown
Collaborator Author

@greptile review

@Devesh36

Copy link
Copy Markdown
Collaborator Author

@greptile review

@Devesh36
Devesh36 requested a review from larsspinetta12 July 18, 2026 09:59
Comment thread integrations/sentry/morning_digest.py Outdated
Comment on lines +1 to +21
"""Deterministic Sentry morning digest: Issues + uptime rollup (#4070)."""

from __future__ import annotations

from dataclasses import dataclass
from datetime import UTC, datetime, timedelta
from pathlib import Path
from typing import Literal
from urllib.parse import urlparse

from integrations.sentry import SentryConfig, list_sentry_issues
from integrations.sentry.issue_digest import build_sentry_issue_digest
from integrations.sentry.project_scope import payload_project_slug
from integrations.sentry.uptime import (
UptimeTransitionRecord,
WatchState,
load_all_watch_states,
parse_transition_at,
resolve_sentry_config,
)
from platform.scheduler.agent_runner import AgentPayload

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should consider making this an AI skill that is stored in the memory and runs through the gateway.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on it

…try-summary skill and enhance uptime reporting

- Replaced the morning digest logic with the sentry-summary skill path for improved issue summarization.
- Updated documentation to reflect changes in uptime reporting and digest structure.
- Removed the now-obsolete morning_digest.py file and its associated tests.
- Added new tests to ensure the sentry-summary skill correctly references all required tools, including uptime digest functionality.
@Devesh36 Devesh36 changed the title feat(sentry): add deterministic uptime section to morning digest (#4070) feat(sentry): add uptime section to morning digest via sentry-summary skill (#4070) Jul 20, 2026
Comment thread tests/integrations/sentry/test_uptime_digest_tool.py Fixed
Comment thread tests/integrations/sentry/test_uptime_digest_tool.py Fixed
@Devesh36

Copy link
Copy Markdown
Collaborator Author

@greptile review again

…d add missing tool reference

- Changed the lambda parameter name in mock datetime setup for clarity.
- Added 'get_sentry_uptime_digest' to the set of tools without deliberate catch in telemetry tests.
@Devesh36

Copy link
Copy Markdown
Collaborator Author

dropped the deterministic morning_digest.py module and moved uptime into the sentry-summary skill + gateway path via a new get_sentry_uptime_digest tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Sentry uptime watch follow-ups: webhooks, remediation, morning digest section

3 participants