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

refactor: Extract "HttpStats" utility class #27944

Merged
merged 10 commits into from Mar 15, 2024

Conversation

zharinov
Copy link
Collaborator

Changes

  • Wrap HTTP statistics into the helper class
  • Add median and max data

Context

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise LGTM

lib/util/http/index.ts Outdated Show resolved Hide resolved
@rarkins
Copy link
Collaborator

rarkins commented Mar 15, 2024

Is the output structure identical? Adding @nabeelsaabna because he parses some of these stats in our backend

@viceice viceice changed the title refactor: Extract "HttpStats" utulity class refactor: Extract "HttpStats" utility class Mar 15, 2024
viceice
viceice previously approved these changes Mar 15, 2024
@rarkins
Copy link
Collaborator

rarkins commented Mar 15, 2024

@zharinov do you have a before/after example?

@zharinov
Copy link
Collaborator Author

No, it's not identical

@zharinov
Copy link
Collaborator Author

And previous ones are different too, BTW

@zharinov
Copy link
Collaborator Author

DEBUG: Package cache statistics (repository=renovate-testing/26315-extract-rust-versions-for-releases)
       "get": {"count": 2, "avgMs": 2, "medianMs": 2, "maxMs": 2, "totalMs": 3},
       "set": {"count": 2, "avgMs": 3, "medianMs": 4, "maxMs": 4, "totalMs": 6}
DEBUG: HTTP stats (repository=renovate-testing/26315-extract-rust-versions-for-releases)
       "urlCounts": {
         "https://api.github.com/graphql (POST, 200)": 1,
         "https://api.github.com/repos/renovate-testing/26315-extract-rust-versions-for-releases/branches/main/protection (GET, 404)": 1,
         "https://api.github.com/repos/renovate-testing/26315-extract-rust-versions-for-releases/contents/renovate.json (GET, 304)": 1,
         "https://api.github.com/repos/renovate-testing/26315-extract-rust-versions-for-releases/issues/3 (GET, 304)": 1,
         "https://api.github.com/repos/renovate-testing/26315-extract-rust-versions-for-releases/pulls (GET, 304)": 1,
         "https://crates.io/api/v1/crates/log (GET, 200)": 1,
         "https://raw.githubusercontent.com/rust-lang/crates.io-index/master/3/l/log (GET, 200)": 1
       },
       "statsByHost": {
         "api.github.com": {
           "count": 5,
           "reqAvgMs": 278,
           "reqMedianMs": 269,
           "reqMaxMs": 373,
           "queueAvgMs": 0,
           "queueMedianMs": 0,
           "queueMaxMs": 1
         },
         "crates.io": {
           "count": 1,
           "reqAvgMs": 657,
           "reqMedianMs": 657,
           "reqMaxMs": 657,
           "queueAvgMs": 1,
           "queueMedianMs": 1,
           "queueMaxMs": 1
         },
         "raw.githubusercontent.com": {
           "count": 1,
           "reqAvgMs": 301,
           "reqMedianMs": 301,
           "reqMaxMs": 301,
           "queueAvgMs": 0,
           "queueMedianMs": 0,
           "queueMaxMs": 0
         }
       },
       "totalRequests": 7
DEBUG: Lookup statistics (repository=renovate-testing/26315-extract-rust-versions-for-releases)
       "crate": {"count": 1, "avgMs": 1010, "medianMs": 1010, "maxMs": 1010, "totalMs": 1010}

@rarkins
Copy link
Collaborator

rarkins commented Mar 15, 2024

Looks ok, I will wait for @nabeelsaabna to confirm we can use it or adapt to it

@nabeelsaabna
Copy link
Contributor

I see mainly name changes that we can update easily 👍

urls -> urlCounts
hostStats -> statsByHost

old log example

{
	"level": 20,
	"urls": {
		"https://api.github.com/graphql (POST,200)": 1
	},
	"hostStats": {
		"api.github.com": {
			"requestCount": 1,
			"requestAvgMs": 93,
			"queueAvgMs": 0
		}
	},
	"totalRequests": 3,
	"msg": "http statistics"
}

@nabeelsaabna
Copy link
Contributor

Side note: for using this message in graphs/gathering metrics and trends it would be more useful to extract the (POST,200) from the URL key
e.g.

{
	"urls": {
		"https://api.github.com/graphql": {
			"POST": {
				"200": 1
				"404": 3
			}
		},
		"https://crates.io/api/v1/crates/log": {
			"GET": {
				"200": 1
			}
		}
	}
}

@zharinov
Copy link
Collaborator Author

Please decide what changes to make, I'll do it later today. Now I have to go and pass Spanish exam, see you.

nabeelsaabna
nabeelsaabna previously approved these changes Mar 15, 2024
Copy link
Contributor

@nabeelsaabna nabeelsaabna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving naming/structure changes

@nabeelsaabna
Copy link
Contributor

Please decide what changes to make, I'll do it later today. Now I have to go and pass Spanish exam, see you.

no changes need in this PR

@zharinov
Copy link
Collaborator Author

Almost done adjusting the structure:

"urls": {
         "https://api.github.com/graphql": {"POST": {"200": 1}},
         "https://api.github.com/repos/renovate-testing/26315-extract-rust-versions-for-releases/branches/main/protection": {
           "GET": {"404": 1}
         },
         "https://api.github.com/repos/renovate-testing/26315-extract-rust-versions-for-releases/contents/renovate.json": {
           "GET": {"304": 1}
         },
         "https://api.github.com/repos/renovate-testing/26315-extract-rust-versions-for-releases/issues/3": {
           "GET": {"304": 1}
         },
         "https://api.github.com/repos/renovate-testing/26315-extract-rust-versions-for-releases/pulls": {
           "GET": {"304": 1}
         }
       }

Would you like to have it like this? Or never mind?

@zharinov
Copy link
Collaborator Author

zharinov commented Mar 15, 2024

The final variant:

DEBUG: HTTP statistics (repository=renovate-testing/26315-extract-rust-versions-for-releases)
       "urls": {
         "https://api.github.com/graphql": {"POST": {"200": 1}},
         "https://api.github.com/repos/renovate-testing/26315-extract-rust-versions-for-releases/branches/main/protection": {
           "GET": {"404": 1}
         },
         "https://api.github.com/repos/renovate-testing/26315-extract-rust-versions-for-releases/contents/renovate.json": {
           "GET": {"304": 1}
         },
         "https://api.github.com/repos/renovate-testing/26315-extract-rust-versions-for-releases/issues/3": {
           "GET": {"304": 1}
         },
         "https://api.github.com/repos/renovate-testing/26315-extract-rust-versions-for-releases/pulls": {
           "GET": {"304": 1}
         }
       },
       "hosts": {
         "api.github.com": {
           "count": 5,
           "reqAvgMs": 259,
           "reqMedianMs": 248,
           "reqMaxMs": 308,
           "queueAvgMs": 0,
           "queueMedianMs": 0,
           "queueMaxMs": 0
         }
       },
       "requests": 5
  • Message is HTTP statistics
  • Field names are urls, hosts, requests

@zharinov zharinov dismissed stale reviews from nabeelsaabna and viceice via 6a015bd March 15, 2024 11:21
@rarkins
Copy link
Collaborator

rarkins commented Mar 15, 2024

I think the get/post improvement is useful!

Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs prettier fix

@zharinov zharinov requested a review from viceice March 15, 2024 11:54
@rarkins rarkins added this pull request to the merge queue Mar 15, 2024
Merged via the queue into renovatebot:main with commit fd8684b Mar 15, 2024
35 checks passed
@rarkins rarkins deleted the refactor/http-stats-class branch March 15, 2024 12:47
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 37.249.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants