feat: add workflow-level metric labels and queue duration#182
Open
nissan-itzhakov-cyera wants to merge 6 commits intopaper2:mainfrom
Open
feat: add workflow-level metric labels and queue duration#182nissan-itzhakov-cyera wants to merge 6 commits intopaper2:mainfrom
nissan-itzhakov-cyera wants to merge 6 commits intopaper2:mainfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add comprehensive metric labels to enable Grafana dashboard filtering
and analysis without time range limitations or legend naming issues.
Changes: