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

[APM] Adds support for metrics for latency distribution histogram #136083

Merged
merged 4 commits into from
Jul 13, 2022

Conversation

ogupte
Copy link
Contributor

@ogupte ogupte commented Jul 11, 2022

Closes #132394

xpack.apm.searchAggregatedTransactions: never:
Screen Shot 2022-07-11 at 2 19 40 AM

xpack.apm.searchAggregatedTransactions: auto:
Screen Shot 2022-07-11 at 2 20 36 AM

@ogupte ogupte requested a review from a team as a code owner July 11, 2022 06:36
@botelastic botelastic bot added the Team:APM - DEPRECATED Use Team:obs-ux-infra_services. label Jul 11, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)

@ogupte
Copy link
Contributor Author

ogupte commented Jul 11, 2022

@elasticmachine merge upstream

Copy link
Contributor

@cauemarcondes cauemarcondes left a comment

Choose a reason for hiding this comment

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

LGTM. Just a nit and a suggestion.

}
},
};
console.log(JSON.stringify(params));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can delete this.

Comment on lines 16 to 22
if (eventType === ProcessorEvent.metric) {
return TRANSACTION_DURATION_HISTOGRAM;
}
if (eventType === ProcessorEvent.span) {
return SPAN_DURATION;
}
return TRANSACTION_DURATION;
Copy link
Contributor

Choose a reason for hiding this comment

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

You could have used a switch here, couldn't you? Up to you to do this change though!

Suggested change
if (eventType === ProcessorEvent.metric) {
return TRANSACTION_DURATION_HISTOGRAM;
}
if (eventType === ProcessorEvent.span) {
return SPAN_DURATION;
}
return TRANSACTION_DURATION;
switch(eventType){
case ProcessorEvent.metric:
return TRANSACTION_DURATION_HISTOGRAM;
case ProcessorEvent.span:
return SPAN_DURATION;
default:
return TRANSACTION_DURATION;
}

return getOverallLatencyDistribution({
setup,
eventType: ProcessorEvent.transaction,
eventType: searchAggregatedTransactions
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if this is enough. I think you also need a filter for { exists: { field: 'transaction.duration.histogram' } }. We have a helper function for that purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The call to getSearchAggregatedTransactions on line 65 does call the helper getHasAggregatedTransactions which filters for this field.

Copy link
Member

Choose a reason for hiding this comment

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

It only checks for the existence. The actual search itself needs a filter on { exists: { field: 'transaction.duration.histogram' } } otherwise it will run over all metric documents.


export function getDurationField(eventType: ProcessorEvent) {
if (eventType === ProcessorEvent.metric) {
return TRANSACTION_DURATION_HISTOGRAM;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think ProcessorEvent is the right abstraction here anymore. We should be more specific, e.g.:

  • transaction_events
  • span_events
  • transaction_metrics
  • service_destination_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.

This new util function was just some code cleanup since we had repeated switching logic to for the duration field between the latency distribution chart and the correlations distribution charts. If the abstractions were to change, we would want to tease apart the correlations from the regular latency distribution chart (1st tab vs 2nd & 3rd tabs) into distinct functions for their own use cases. We could consider this tech debt and out of scope for this bug fix.

Copy link
Member

Choose a reason for hiding this comment

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

The issue is that eventType in this case signals what data we want to show, not what documents we should use to display it. Transaction latency data can be based on both ProcessorEvent.transaction and ProcessorEvent.metric, and similarly, exit span latency data can be based on both ProcessorEvent.span and ProcessorEvent.metric. I don't think we should conflate those concepts.

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@ogupte ogupte merged commit e337b58 into elastic:main Jul 13, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jul 13, 2022
Copy link
Member

@dgieselaar dgieselaar left a comment

Choose a reason for hiding this comment

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

@ogupte IMHO this wasn't ready to merge, I think there's some issues that need to be addressed as you can see from my feedback. Do you mind reverting and re-submitting? I'd prefer that over a PR on top of this because that makes it harder to review the changes as a whole.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:fix Team:APM - DEPRECATED Use Team:obs-ux-infra_services. v8.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[APM] Transaction latency distribution should use transaction metrics instead of transaction events
6 participants