Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a Debug Parameter? #533

Open
benjaminu opened this issue Dec 1, 2022 · 3 comments
Open

Is there a Debug Parameter? #533

benjaminu opened this issue Dec 1, 2022 · 3 comments

Comments

@benjaminu
Copy link

Hi, @int128, I've set this up to send data from my GHA workflow to DataDog; however, I've encountered a number of issues.

  1. When trying to filter, not all my workflows show up as options in DataDog.
  2. Some filter options show up then disappear. So not sure what consistent param to filter by.
  3. github.actions.pull_request_closed.since_first_authored_seconds and github.actions.pull_request_closed.since_first_committed_seconds do not show up in DataDog. I only see github.actions.pull_request_closed.since_opened_seconds.

I'd like to figure out why. Any ideas or is there a param I can use to debug the library and/or payload being sent to DataDog please?

Could it be because I'm using this in my config? collect-job-metrics: ${{ github.event.workflow_run.head_branch == github.event.repository.default_branch }}

@benjaminu
Copy link
Author

Hi @int128, if there is no debug param, can you shed some light on how I can get the following to show up in datadog please?

  1. github.actions.pull_request_closed.since_first_authored_seconds
  2. github.actions.pull_request_closed.since_first_committed_seconds
  3. Workflow names to use as filters

This is what my config file looks like.

name: Track DORA Metrics via Datadog

permissions:
  actions: read

on:
  workflow_run:
    workflows:
      - name-of-workflow-which-merges-into-main
    types:
      - completed
  pull_request:
    types:
      - opened
      - closed

jobs:
  send_metrics:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: int128/datadog-actions-metrics@v1
        with:
          datadog-api-key: ${{ secrets.DATADOG_API_KEY }}
          datadog-site: datadoghq.eu
          collect-job-metrics: ${{ github.event.workflow_run.head_branch == github.event.repository.default_branch }}
          github-token: ${{ secrets.GITHUB_TOKEN }}
          send-pull-request-labels: true

@int128
Copy link
Owner

int128 commented Feb 4, 2023

This action shows a payload here:

core.startGroup(`Metrics payload (${description})`)
core.info(JSON.stringify(series, undefined, 2))
core.endGroup()
core.info(`Sending ${series.length} metrics to Datadog`)
const accepted = await metrics.submitMetrics({ body: { series } })
core.info(`Sent ${JSON.stringify(accepted)}`)

Here is an example in the e2e test:
https://github.com/int128/datadog-actions-metrics/actions/runs/4090948703/jobs/7054711331

image

@int128
Copy link
Owner

int128 commented Feb 4, 2023

Both metrics are sent here:

if (pr !== undefined) {
series.push(
{
host: 'github.com',
tags,
metric: 'github.actions.pull_request_closed.since_first_authored_seconds',
type: 'gauge',
points: [[t, t - unixTime(pr.firstCommit.authoredDate)]],
},
{
host: 'github.com',
tags,
metric: 'github.actions.pull_request_closed.since_first_committed_seconds',
type: 'gauge',
points: [[t, t - unixTime(pr.firstCommit.committedDate)]],
}
)
}

If this action cannot get the details of pull request, both metrics may not be sent.
Can you check if there is some warning log?

let closedPullRequest
try {
closedPullRequest = await queryClosedPullRequest(octokit, {
owner: context.repo.owner,
name: context.repo.repo,
number: e.pull_request.number,
})
} catch (error) {
core.warning(`Could not get the pull request: ${String(error)}`)
}
return await submitMetrics(computePullRequestClosedMetrics(e, closedPullRequest, inputs), 'pull request')

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

No branches or pull requests

2 participants