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

Log request times for partners API and other HTTP fetch #978

Merged
merged 4 commits into from
Dec 23, 2022

Conversation

amcaplan
Copy link
Contributor

@amcaplan amcaplan commented Dec 23, 2022

WHY are these changes introduced?

Tracing performance of HTTP requests gives us visibility into what's taking the most time. Let's make the CLI faster.

WHAT is this pull request doing?

Using the JS performance API, grab timestamps before and after the request, and print the total request time.

How to test your changes?

Run dev with --verbose and see the extra log lines! (search for completed)

2022-12-23T13:11:08.294Z: Reading the content of file at package.json...
2022-12-23T13:11:08.294Z:
Sending "Partners" GraphQL request:

  {
    organizations(first: 200) {
      nodes {
        id
        businessName
        website
        appsNext
      }
    }
  }


With variables:


And headers:
 - User-Agent: Shopify CLI; v=3.30.0
 - Sec-CH-UA-PLATFORM: darwin
 - X-Request-Id: 70929890-3feb-4e11-b8a7-98dd49f063e1
 - Content-Type: application/json

2022-12-23T13:11:08.759Z: Request to https://partners.shopify.com/api/cli/graphql completed in 464 ms

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've made sure that any changes to dev or deploy have been reflected in the internal flowchart.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 23, 2022

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
67.48% (-0.14% 🔻)
3477/5153
🟡 Branches
62.35% (+0.01% 🔼)
1136/1822
🟡 Functions
65.77% (-0.12% 🔻)
880/1338
🟡 Lines
67.69% (-0.14% 🔻)
3312/4893
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🔴
... / fetch.ts
22.22% (-11.11% 🔻)
0% 50%
22.22% (-11.11% 🔻)
🟡
... / exchange.ts
63.64% (-15.21% 🔻)
72.73% (-9.09% 🔻)
63.64% (-16.36% 🔻)
62.96% (-15.47% 🔻)

Test suite run success

867 tests passing in 439 suites.

Report generated by 🧪jest coverage report action from 23b1cc8

@gonzaloriestra
Copy link
Contributor

I've added explicit imports for the performance object because tests were failing for Node 14 (it was made a global in v16).

Also, I've added the time to each debug message.

@gonzaloriestra gonzaloriestra merged commit 913f67e into main Dec 23, 2022
@gonzaloriestra gonzaloriestra deleted the log-request-time branch December 23, 2022 13:55
@shopify-shipit shopify-shipit bot temporarily deployed to production January 3, 2023 18:45 Inactive
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.

3 participants