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

Moved the logic for counting domain limits to a new class #749

Merged
merged 1 commit into from
Apr 19, 2024

Conversation

priettt
Copy link
Contributor

@priettt priettt commented Apr 17, 2024

Goal

Extracted the logic for counting domain limits to another class. This will allow us to test it more thoroughly in the future, as we detected some inconsistencies. It also keeps the NetworkLogging service cleaner.

Questions:

  • Shouldn't we ignore domains that can't be parsed for networkCapturedData too?
  • Shouldn't we also track limits for networkCapturedData?
  • Should we synchronize on another object now that we don't use callsStorageLastUpdate?
  • All of the IP address domains fall under the same limit? Is that correct?


override fun logNetworkRequest(networkRequest: EmbraceNetworkRequest) {
logNetworkCaptureData(networkRequest)
processNetworkRequest(networkRequest)
recordNetworkRequest(networkRequest)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We probably want to log the network request first before we send the data capture since that seems more important?

*/
private fun processNetworkRequest(networkRequest: EmbraceNetworkRequest) {
private fun recordNetworkRequest(networkRequest: EmbraceNetworkRequest) {
// TODO: Shouldn't we ignore domains that can't be parsed for networkCapturedData too?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Log a KTLO task and move on - not sure how these are related, so lets detangle this later

) : MemoryCleanerListener {

private val domainSetting = ConcurrentHashMap<String, DomainSettings>()
private val callsPerDomainSuffix = hashMapOf<String, NetworkSessionV2.DomainCount>()
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could be accessed concurrently so we need to use a threadsafe map

private var domainSuffixCallLimits = configService.networkBehavior.getNetworkCallLimitsPerDomainSuffix()

fun canLogNetworkRequest(domain: String): Boolean {
// TODO: Should we synchronize on another object now that we don't use callsStorageLastUpdate?
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we don't synchronize, we might get a few network requests above the absolute max. That might be fine...?

Copy link
Collaborator

@bidetofevil bidetofevil left a comment

Choose a reason for hiding this comment

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

Want to see this at least be threadsafe before approving

Copy link
Collaborator

bidetofevil commented Apr 18, 2024

Merge activity

  • Apr 18, 7:50 PM EDT: @bidetofevil started a stack merge that includes this pull request via Graphite.
  • Apr 18, 8:00 PM EDT: Graphite rebased this pull request as part of a merge.
  • Apr 18, 8:01 PM EDT: @bidetofevil merged this pull request with Graphite.

Base automatically changed from record-network-span to master April 18, 2024 23:59
@bidetofevil bidetofevil merged commit 9da6934 into master Apr 19, 2024
1 of 2 checks passed
@bidetofevil bidetofevil deleted the domain-count-limiter branch April 19, 2024 00:01
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.

None yet

2 participants