sentry-github-actions-app icon indicating copy to clipboard operation
sentry-github-actions-app copied to clipboard

Feat/hierarchical workflow tracing

Open serglom21 opened this issue 3 months ago • 2 comments

Summary

This PR transforms the GitHub Actions workflow tracing from individual job transactions to a single workflow transaction containing nested job and step spans, providing better visibility into workflow timing and structure.

Problem that I am attempting to solve

Before: Individual job transactions created a flat structure in Sentry, making it difficult to understand workflow timing and relationships. After: Single workflow transaction with proper hierarchical spans showing:

  • Workflow-level timing and status
  • Individual job spans as children
  • Step spans as children of their respective jobs

Key Changes

Core Implementation:

  • WorkflowTracer: New class for creating single workflow transactions with nested spans
  • WorkflowJobCollector: Collects jobs from workflow runs and sends workflow-level traces
  • Enhanced WebAppHandler: Integrates job collection and workflow tracing

Trace Structure:

workflow: Multi-Job Test (transaction)
├─ security-scan (job span)
│  ├─ Set up job (step span)
│  ├─ Checkout code (step span)
│  └─ Run security scan (step span)
├─ performance-tests (job span)
│  ├─ Set up job (step span)
│  ├─ Setup performance test environment (step span)
│  └─ Run performance tests (step span)
└─ backend-tests (job span)
   ├─ Set up job (step span)
   ├─ Setup Python (step span)
   └─ Run backend unit tests (step span)

Files Changed

  • src/workflow_tracer.py - New WorkflowTracer implementation
  • src/web_app_handler.py - Enhanced with WorkflowJobCollector
  • src/enhanced_web_app_handler.py - Alternative handler implementation

Before

Screenshot 2025-10-01 at 7 13 42 AM

After

Screenshot 2025-10-01 at 7 14 45 AM

serglom21 avatar Oct 01 '25 11:10 serglom21

bugbot run

armenzg avatar Oct 27 '25 13:10 armenzg

Skipping Bugbot: Bugbot is disabled for this repository

cursor[bot] avatar Oct 27 '25 13:10 cursor[bot]

Thanks @armenzg! I have implemented the changes above and added some tests for the new functionality and edge cases. More details:

  • Extracted WorkflowJobCollector into its own module (src/workflow_job_collector.py)
  • Replaced magic numbers with constants

I added some env variable handling to:

  • ENABLE_HIERARCHICAL_TRACING to toggle new vs legacy tracing

  • SENTRY_ORG_ONLY to restrict to Sentry org during testing

  • Legacy individual job tracing remains available as fallback

  • Implemented clean code principles. Could you please review again? Thanks

serglom21 avatar Nov 17 '25 19:11 serglom21