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

Network metrics #8390

Merged
merged 6 commits into from
Dec 17, 2024
Merged

Network metrics #8390

merged 6 commits into from
Dec 17, 2024

Conversation

enahum
Copy link
Contributor

@enahum enahum commented Dec 3, 2024

Summary

This PR allows us to collect network metrics for analysis.

Ticket Link

https://mattermost.atlassian.net/browse/MM-61878

Release Note

NONE

@enahum enahum added the 2: Dev Review Requires review by a core commiter label Dec 3, 2024
@rahimrahman
Copy link
Contributor

Hi @enahum -- sorry for the delay on this.

I was able to see the label showing up in the log:

 DEBUG  Group "entry" completed.
 LOG  Telemetry event on ios for server https://community.mattermost.com
            Group "entry"
            requesting 35 urls
            total Compressed size of: 0 B
            total size of: 0 B
            ellapsed time: 4.697 seconds
            average latency: 0 ms
 DEBUG  Group "entry-additional" completed.
 LOG  Telemetry event on ios for server https://community.mattermost.com
            Group "entry-additional"
            requesting 16 urls
            total Compressed size of: 0 B
            total size of: 0 B
            ellapsed time: 0.607 seconds
            average latency: 0 ms

-----

 LOG  Telemetry event on ios for server https://community.mattermost.com
            Group "reconnection"
            requesting 32 urls
            total Compressed size of: 0 B
            total size of: 0 B
            ellapsed time: 0.972 seconds
            average latency: 0 ms
 DEBUG  Group "reconnection-additional" completed.
 LOG  Telemetry event on ios for server https://community.mattermost.com
            Group "reconnection-additional"
            requesting 16 urls
            total Compressed size of: 0 B
            total size of: 0 B
            ellapsed time: 0.505 seconds
            average latency: 0 ms

Is the total size suppose to be 0B and latency at 0ms? I am using "github:mattermost/react-native-network-client#ad7b88412f41c5a1024420a4f4c7461883cd0e63" as in package.json. This is my way to test react-native-network-client changes as well. Did I miss anything?

My reluctant is the amount of changes involved to make this work. Is it because groupLabel can change at anytime (similar to serverUrl)? (as portrayed here where you can have "entry" and "entry-additional" all within one single lifecycle).

Copy link
Member

@isacikgoz isacikgoz left a comment

Choose a reason for hiding this comment

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

Can't tell anything specific to implementation but the metrics seems okay to me. Looking forward to analyse these.

@enahum
Copy link
Contributor Author

enahum commented Dec 9, 2024

Hi @enahum -- sorry for the delay on this.

I was able to see the label showing up in the log:


 DEBUG  Group "entry" completed.

 LOG  Telemetry event on ios for server https://community.mattermost.com

            Group "entry"

            requesting 35 urls

            total Compressed size of: 0 B

            total size of: 0 B

            ellapsed time: 4.697 seconds

            average latency: 0 ms

 DEBUG  Group "entry-additional" completed.

 LOG  Telemetry event on ios for server https://community.mattermost.com

            Group "entry-additional"

            requesting 16 urls

            total Compressed size of: 0 B

            total size of: 0 B

            ellapsed time: 0.607 seconds

            average latency: 0 ms



-----



 LOG  Telemetry event on ios for server https://community.mattermost.com

            Group "reconnection"

            requesting 32 urls

            total Compressed size of: 0 B

            total size of: 0 B

            ellapsed time: 0.972 seconds

            average latency: 0 ms

 DEBUG  Group "reconnection-additional" completed.

 LOG  Telemetry event on ios for server https://community.mattermost.com

            Group "reconnection-additional"

            requesting 16 urls

            total Compressed size of: 0 B

            total size of: 0 B

            ellapsed time: 0.505 seconds

            average latency: 0 ms



Is the total size suppose to be 0B and latency at 0ms? I am using "github:mattermost/react-native-network-client#ad7b88412f41c5a1024420a4f4c7461883cd0e63" as in package.json. This is my way to test react-native-network-client changes as well. Did I miss anything?

My reluctant is the amount of changes involved to make this work. Is it because groupLabel can change at anytime (similar to serverUrl)? (as portrayed here where you can have "entry" and "entry-additional" all within one single lifecycle).

@rahimrahman you seem to not have set the collectMetrics config setting to true, not sure how you missed that.

As for the changes, the groupLabel is applied in multiple places as we need to know what endpoints to group. For example you'll see entry and entry-additional in this PR but in a future PR I have almost ready to go it will change to the following labels (this labels will be well defined in a type definition):

  • Login & Login Deferred
  • Cold Start & Cold Start Deferred
  • Notification & Notification Deferred
  • DeepLink & DeepLink Deferred
  • WebSocket reconnect & WebSocket reconnect Deferred

Why the Deferred? Simply because I thought is better to group them in a way that we can clearly identify the requests that are done for TTI and those that happen after like fetching posts for unread channels threads and in case of this PR also channels for other teams, etc.. but are still part of the initial load.

Then we can use the groupLabel to group all the requests that are involved in a particular action like channel switch or post a message or whatever

@rahimrahman
Copy link
Contributor

Oh shoot, I changed the DEFAULT_CONFIG, and didn't change my LocalConfig.

Silly me, thanks!

Copy link
Contributor

@rahimrahman rahimrahman left a comment

Choose a reason for hiding this comment

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

Again, sorry for the tardiness. Here's a few thoughts.

completionTimer?: NodeJS.Timeout;
}

export default class ClientTraking {
Copy link
Contributor

Choose a reason for hiding this comment

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

Spelling error

Suggested change
export default class ClientTraking {
export default class ClientTracking {

requesting ${urls.length} urls
total Compressed size of: ${getFormattedFileSize(groupData.totalCompressedSize)}
total size of: ${getFormattedFileSize(groupData.totalSize)}
ellapsed time: ${duration / 1000} seconds
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ellapsed time: ${duration / 1000} seconds
elapsed time: ${duration / 1000} seconds

count: number;
metrics?: ClientResponseMetrics;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add:

export enum GroupLabel {
  Entry = 'Entry',
  ColdStart = 'ColdStart',
  Login = 'Login',
  ...
}

So we can use it in methods

WebsocketManager.openAll(GroupLabel.Entry);
export const fetchGroupsForChannel = async (serverUrl: string, channelId: string, fetchOnly = false, groupLabel?: GroupLabel) => {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is done in a future PR as I mentioned in my previous comment, so for this PR it will remain as is

Copy link
Contributor

Choose a reason for hiding this comment

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

For example you'll see entry and entry-additional in this PR but in a future PR I have almost ready to go it will change to the following labels (this labels will be well defined in a type definition):

Thanks, I missed it.

Comment on lines +84 to +91
if (group.urls[url]) {
group.urls[url].count += 1;
} else {
group.urls[url] = {
count: 1,
metrics,
};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about using just the path instead of the entire url?

Maybe it will give us more duplicates if any?

 LOG  {"path": "/api/v4/users/me/preferences", "query": undefined}
 LOG  {"path": "/api/v4/users/me/teams", "query": undefined}
 LOG  {"path": "/api/v4/users/me/teams/members", "query": undefined}
 LOG  {"path": "/api/v4/users/me", "query": undefined}
 LOG  {"path": "/api/v4/users/me/status", "query": undefined}
 LOG  {"path": "/api/v4/users/me/teams/rcgiyftm7jyrxnma1osd8zswby/channels/members", "query": undefined}
 LOG  {"path": "/api/v4/users/me/teams/rcgiyftm7jyrxnma1osd8zswby/channels", "query": "include_deleted=true&last_delete_at=1733860858455"}
 LOG  {"path": "/api/v4/users/me/teams/rcgiyftm7jyrxnma1osd8zswby/channels/categories", "query": undefined}
Suggested change
if (group.urls[url]) {
group.urls[url].count += 1;
} else {
group.urls[url] = {
count: 1,
metrics,
};
}
const [path] = url.split('?');
if (group.urls[path]) {
group.urls[path].count += 1;
} else {
group.urls[path] = {
count: 1,
metrics,
};
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They would not be really duplicates though.. I think at this time we can keep the url and if we want to try and refine more then we can do soemething like this

@enahum enahum requested a review from rahimrahman December 10, 2024 21:56
@enahum enahum merged commit fb57c42 into main Dec 17, 2024
6 checks passed
@enahum enahum deleted the request-metrics branch December 17, 2024 11:51
@amyblais amyblais added this to the v2.25.0 milestone Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Dev Review Requires review by a core commiter release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants