-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[APM] Fix query to mobile transactions main statistics #155895
[APM] Fix query to mobile transactions main statistics #155895
Conversation
Pinging @elastic/apm-ui (Team:APM) |
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
x-pack/plugins/apm/server/routes/mobile/get_mobile_main_statistics_by_field.ts
Show resolved
Hide resolved
}>; | ||
} | ||
|
||
type MainStatistics = Array<{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I think this is not used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type is used in line 194, needed to set which type we want the array returned by merge()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see! I don't fully understand the following if you could please elaborate a bit more
export interface MobileMainStatisticsResponse {
mainStatistics: Array<{
name: string | number;
latency: number | null;
throughput: number;
crashRate: number;
}>;
}
type MainStatistics = Array<{
name: string | number;
latency: number | null;
throughput: number;
sessions: number;
crashes?: number;
}>;
cause I would expect to be
export interface MobileMainStatisticsResponse {
mainStatistics: MainStatistics
}
why do you have to calculate the crashRate here ->https://github.com/elastic/kibana/blob/b09ec7a1197573441ea85a2da8673c10767a717f/x-pack/plugins/apm/server/routes/mobile/get_mobile_main_statistics_by_field.ts#L204
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The merge of the two query responses is different from the return we want, for instance, we need sessions to calculate the crashRate
, but we don't need them to be returned by getMobileMainStatisticsByField()
, the main statistics we need are name, latency, throughput, and crashRate.
We calculate the crashRate
here, same as we also calculate the throughput
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the naming is confusing, I can give it a thought and find a more clear name for the type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see the confusion, sessions shouldn’t be part of errors query, does it make sense now?
b09ec7a
to
c2a41e1
Compare
💚 Build Succeeded
Metrics [docs]Async chunks
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
@@ -55,7 +63,7 @@ export async function getMobileMainStatisticsByField({ | |||
}: Props) { | |||
async function getMobileTransactionEventStatistics() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getMobileMainStatisticsByField(){
async function getMobileTransactionEventStatistics() {}
async function getMobileErrorEventStatistics(){}
}
Nesting functions can be useful for encapsulating functionality and scoping variables but in this case, it seems it doesn't provide any value.
On the other hand, if there is a possibility of reusing ex getMobileErrorEventStatistics
in other parts of the codebase, defining it outside of getMobileMainStatisticsByField
could be a more practical approach.
What do you think about defining them outside of getMobileMainStatisticsByField
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it, but getMobileErrorEventStatistics
is getting crash errors by field, it's not generic enough to be reusable. But I will keep it in mind for when we start implementing more use cases for crashRate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but getMobileErrorEventStatistics is getting crash errors by field, it's not generic enough to be reusable.
tbh, I'm not sure what you meant with it 🤔 but I think something like the following will work
const commonPros = {
kuery,
apmEventClient,
serviceName,
environment,
start,
end,
field,
};
const [transactioEventStatistics, errorEventStatistics] = await Promise.all([
getMobileTransactionEventStatistics(commonPros),
getMobileErrorEventStatistics(commonPros),
]);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I only left a comment about the nesting functions
When splitting the query to mobile transactions main statistics, the sessions were left in the errors query and should have been retrieved in the transactions events. This PR fix this issue (cherry picked from commit 67b2110)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
#156152) # Backport This will backport the following commits from `main` to `8.8`: - [[APM] Fix query to mobile transactions main statistics (#155895)](#155895) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Miriam","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-04-28T09:35:45Z","message":"[APM] Fix query to mobile transactions main statistics (#155895)\n\nWhen splitting the query to mobile transactions main statistics, the\r\nsessions were left in the errors query and should have been retrieved in\r\nthe transactions events. This PR fix this issue","sha":"67b211001fe50d3d2f2430689402f1bab8224294","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","Team:APM","release_note:skip","v8.8.0","v8.9.0"],"number":155895,"url":"https://github.com/elastic/kibana/pull/155895","mergeCommit":{"message":"[APM] Fix query to mobile transactions main statistics (#155895)\n\nWhen splitting the query to mobile transactions main statistics, the\r\nsessions were left in the errors query and should have been retrieved in\r\nthe transactions events. This PR fix this issue","sha":"67b211001fe50d3d2f2430689402f1bab8224294"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/155895","number":155895,"mergeCommit":{"message":"[APM] Fix query to mobile transactions main statistics (#155895)\n\nWhen splitting the query to mobile transactions main statistics, the\r\nsessions were left in the errors query and should have been retrieved in\r\nthe transactions events. This PR fix this issue","sha":"67b211001fe50d3d2f2430689402f1bab8224294"}}]}] BACKPORT--> Co-authored-by: Miriam <[email protected]>
When splitting the query to mobile transactions main statistics, the sessions were left in the errors query and should have been retrieved in the transactions events. This PR fix this issue