{"id":21847541,"url":"https://github.com/scribd/github-action-datadog-reporting","last_synced_at":"2025-04-14T13:33:18.218Z","repository":{"id":43281771,"uuid":"331086972","full_name":"scribd/github-action-datadog-reporting","owner":"scribd","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-04T16:57:25.000Z","size":39,"stargazers_count":23,"open_issues_count":1,"forks_count":12,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-28T02:45:29.126Z","etag":null,"topics":["tools-team"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scribd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-01-19T19:28:39.000Z","updated_at":"2025-01-04T10:12:38.000Z","dependencies_parsed_at":"2023-09-29T02:39:33.867Z","dependency_job_id":"5f2cc42b-843b-41d3-92ec-089789d0c756","html_url":"https://github.com/scribd/github-action-datadog-reporting","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scribd%2Fgithub-action-datadog-reporting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scribd%2Fgithub-action-datadog-reporting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scribd%2Fgithub-action-datadog-reporting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scribd%2Fgithub-action-datadog-reporting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scribd","download_url":"https://codeload.github.com/scribd/github-action-datadog-reporting/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248888895,"owners_count":21178123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["tools-team"],"created_at":"2024-11-27T23:18:31.317Z","updated_at":"2025-04-14T13:33:18.173Z","avatar_url":"https://github.com/scribd.png","language":"Ruby","readme":"# Datadog Velocity Metrics for GitHub and GitHub Actions\n\nThis action integrates into pre-existing Datadog and GitHub Actions workflows, and reports metrics to Datadog based on job and workflow performance.\n\n## Features\n\n### Capture GitHub Action Job and Workflow metrics\n\nOne of the features of this action is to report metrics on job duration and workflow duration in GitHub Actions. The metrics tracked are:\n\n- Job duration, 1 metric submitted per job in a workflow that uses the action\n- Workflow duration, 1 metric submitted per workflow that uses the action.\n\nThe following represents example metrics submitted for job duration and workflow duration\n```\nMetric name: \u003cprefix\u003e.job_duration\nMetric value: 151.0\nTags: \n{\n  workflow: \"My workflow name\",\n  project: \"scribd/my_repository\",\n  status: \"success\",\n  name: \"My-job-name\",\n}\n```\n\n```\nMetric name: \u003cprefix\u003e.workflow_duration\nMetric value: 1223.0\nTags: \n{\n  workflow: \"My workflow name\",\n  project: \"scribd/my_repository\",\n  status: \"success\",\n}\n```\n\n### Capture Development Velocity Metrics\n\nThis action also provides the capability to establish a separate workflow that tracks useful developer velocity metrics. Currently the metrics tracked are \n\n- Time to merge per pull request (Time difference between PR open and merge), reported on PR merged.\n- Lines changed per pull request, reported on PR merged.\n- Time to open a pull request (Time difference between first commit and PR open), reported on PR open.\n\nThe following represents example metrics for time to merge, lines changed and time to open\n\n```\nMetric name: \u003cprefix\u003e.time_to_merge\nMetric value: 1624.0\nTags: {project: \"scribd/my_repository\", \"team:my_team\", \"team:my_team2\"}\n```\n\nNote that team tags are only added if the author of the merge request is part of the organization the repository belongs to. Multiple teams will be tagged if the user belongs to multiple teams in the organization.\n\n```\nMetric name: \u003cprefix\u003e.lines_changed\nMetric value: 173.0\nTags: {project: \"scribd/my_repository\"}\n```\n\n\n```\nMetric name: \u003cprefix\u003e.time_to_open\nMetric value: 389.0\nTags: {project: \"scribd/my_repository\"}\n```\n\n### Metric Counts\n\nIn addition to all of the above metrics, a metric is also submitted with the value 1 that is named `\u003cprefix\u003e.\u003cmetric-name\u003e.count` for each metric to allow for counting the number of each metric submitted.\n\n## Inputs\n\n### datadog-metric-prefix\n\nA prefix for all of the datadog metrics. If multiple projects in your organization have the same job names then using different metrics for different projects will allow easy separation of the metrics.\n\n### metrics-type\n\nInternal configuration for the action. `job_metrics` should be passed for capturing job_duration and workflow durations, while `velocity` should be passed when used in a `Velocity Workflow` as seen below.\n\n### tagged-branches (Optional)\n\nAn array of named branches to enable tagging of workflow and job metrics with `branch:{branch}` or `branch:other` depending on if the workflow is being run on a tagged branch or not. Only used if metrics-type is `job_metrics`. Example values: `'[\"main\"]'`, `'[\"main\", \"staging\", \"production\"]'`\n\n### custom-tags (Optional)\n\nAn array of custom tags to attach to any metrics sent to datadog. Example values: `'[\"tag:value\"]'`, `'[\"tag1:value1\", \"tag2:value2\"]'`\n\n### api-url (Optional)\n\nThe datadog api url. Defaults to `https://api.datadoghq.com`.  Can be used to override for datadog regional endpoints or a proxy.\n\n## Environment Variables\n\nThe following two secrets are required to be added to your GitHub settings for access to Datadog and GitHub during the workflow run.\n\n### OCTOKIT_TOKEN\n\nThis token allows the action to request information about the workflow run from GitHub and enables calculating the relevant metrics. You can learn how to generate a personal access token (PAT) here: https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token\n\nThe permission required for the PAT is `repo` and `read:org`\n\n### DATADOG_API_KEY\n\nThis token allows the action to submit the metrics to datadog. You can learn how to generate an API token from Datadog here: https://docs.datadoghq.com/account_management/api-app-keys/\n\n## Examples\n\n### Capture GitHub Action Job and Workflow metrics\n\nTo capture job performance of an existing workflow, this action *must* run after all jobs, otherwise it will not report performance for jobs that have not completed at the time of the action running. For example, if there were 3 jobs in a workflow, and job2 `needs` job1, then the below configuration will ensure that the workflow and all jobs are properly captured.\n\nThe metrics that are captured for GitHub Action jobs are:\n\n- `{datadog-metric-prefix}.job_duration`\n  - Tagged with job status, job name, workflow name and repository.\n- `{datadog-metric-prefix}.workflow_duration`\n  - Tagged with workflow status, workflow name, and repository.\n\n```\nname: My Workflow with Metrics\njobs:\n  job1:\n    ...\n  job2:\n    needs: [job1]\n    ...\n  job3:\n    ...\n  metrics:\n    needs: [job2, job3]\n    runs-on: ubuntu-latest\n    name: Datadog reports\n    if: ${{ always() }}\n    steps:\n      - uses: scribd/github-action-datadog-reporting@v2\n        with:\n          datadog-metric-prefix: 'github.action'\n          metrics-type: 'job_metrics'\n        env:\n          DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}\n          OCTOKIT_TOKEN: ${{ secrets.OCTOKIT_TOKEN }}\n```\n\n### Capture Development Velocity Metrics\n\nThe following example can be placed into a workflow file to report the Development Velocity metrics:\n\n- `{datadog-metric-prefix}.time_to_open`\n- `{datadog-metric-prefix}.time_to_merge`\n- `{datadog-metric-prefix}.lines_changed`\n\n```\nname: Velocity Workflow\non:\n  pull_request:\n    types: [opened, closed]\njobs:\n  metrics:\n    if: |\n      (github.event.action == 'closed' \u0026\u0026\n      github.event.pull_request.merged == true) ||\n      github.event.action == 'opened'\n    name: Track merge request activity\n    runs-on: ubuntu-latest\n    steps:\n      # Optional step that allows tagging time to merge with a team\n      - uses: tspascoal/get-user-teams-membership@v1\n        id: actorTeams\n        if: ${{ !endsWith(github.event.pull_request.user.login, '[bot]') }}\n        with:\n          username: ${{ github.event.pull_request.user.login }}\n          GITHUB_TOKEN: ${{ secrets.OCTOKIT_TOKEN }}\n\n      - id: datadog-metrics\n        uses: scribd/github-action-datadog-reporting@v2\n        with:\n          datadog-metric-prefix: 'github.action'\n          metrics-type: 'velocity'\n          teams: ${{ steps.actorTeams.outputs.teams }}\n        env:\n          DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}\n          OCTOKIT_TOKEN: ${{ secrets.OCTOKIT_TOKEN }}\n```\n\n## License\n\nThis project is released under the [MIT License](LICENSE)\n\n## Code of Conduct\n\nSee [our code of conduct](CODE_OF_CONDUCT.md)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscribd%2Fgithub-action-datadog-reporting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscribd%2Fgithub-action-datadog-reporting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscribd%2Fgithub-action-datadog-reporting/lists"}