Skip to content

feat: add workflow-level metric labels and queue duration#182

Open
nissan-itzhakov-cyera wants to merge 6 commits intopaper2:mainfrom
cyeragit:extend-metrics
Open

feat: add workflow-level metric labels and queue duration#182
nissan-itzhakov-cyera wants to merge 6 commits intopaper2:mainfrom
cyeragit:extend-metrics

Conversation

@nissan-itzhakov-cyera
Copy link

Add comprehensive metric labels to enable Grafana dashboard filtering
and analysis without time range limitations or legend naming issues.

Changes:

  • Add workflow.conclusion label (success/failure/cancelled/skipped)
  • Add workflow.actor label (GitHub username who triggered workflow)
  • Add workflow.event label (push/pull_request/workflow_dispatch/etc)
  • Add github.workflow.queued_duration metric (time to first runner)
  • Add runner.name and runner.group_name labels to job metrics
  • Add getEarliestStartedAt helper function for queue calculation

  Add comprehensive metric labels to enable Grafana dashboard filtering
  and analysis without time range limitations or legend naming issues.

  Changes:
  - Add workflow.conclusion label (success/failure/cancelled/skipped)
  - Add workflow.actor label (GitHub username who triggered workflow)
  - Add workflow.event label (push/pull_request/workflow_dispatch/etc)
  - Add github.workflow.queued_duration metric (time to first runner)
  - Add runner.name and runner.group_name labels to job metrics
  - Add getEarliestStartedAt helper function for queue calculation
Add workflow.head_branch and workflow.base_branch labels to enable
branch-level filtering and analysis in Grafana dashboards.

Labels added:
- workflow.head_branch: Source branch that triggered the workflow
  (e.g., 'develop', 'feature/new-api', 'mq-bot-pr-123')
- workflow.base_branch: Target branch for PRs (null for direct pushes)
  (e.g., 'develop', 'main')

Enables queries:
- Filter by specific branches (develop, merge queue, feature branches)
- Compare PR success rates by target branch
- Identify problematic feature branches
- Separate merge queue metrics from direct pushes
- Branch activity heatmaps

Example metric:
github_workflow_duration_seconds{
  workflow_name="Main/Develop CI",
  workflow_head_branch="feature-new-api",
  workflow_base_branch="develop",
  workflow_conclusion="success"
}

Files changed:
- src/github/types.ts: Add head_branch/base_branch to Workflow type
- src/metrics/constants.ts: Add WORKFLOW_HEAD_BRANCH/BASE_BRANCH keys
- src/metrics/create-gauges.ts: Export new labels in metrics
Log the attributes being passed to gauge.record() to help diagnose
why workflow.actor, workflow.event, etc. labels aren't appearing in
Grafana Prometheus metrics.
Add actor, event, head_branch, base_branch fields to test mocks
to fix TypeScript compilation errors after adding these fields
to the Workflow type.
… export

- Move workflow attributes (actor, event, head_branch, base_branch) to resource attributes
- Resource attributes automatically become Prometheus labels when exported via OTLP
- Fetch workflow data before initializing SDK to pass attributes to Resource
- Fix import to use resourceFromAttributes instead of Resource constructor
- This fixes the issue where metric attributes were not appearing as Prometheus labels
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.

1 participant