Skip to content

Commit

Permalink
[8.15] [Timeline] Events request end tracking (#191289) (#191302)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.15`:
- [[Timeline] Events request end tracking
(#191289)](#191289)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Sergi
Massaneda","email":"sergi.massaneda@elastic.co"},"sourceCommit":{"committedDate":"2024-08-26T17:23:54Z","message":"[Timeline]
Events request end tracking (#191289)\n\n## Summary\r\n\r\nBring APM
`endTracking` calls back in the timeline events request, since\r\nthey
were accidentally
removed\r\n[here](https://github.com/elastic/kibana/commit/f1dc15ae4b99791616295e4c6832ee8a10d9eab6#diff-982a0a7f37bfa4c40cc92dc21648118bb152723ad895d932da368341ddea1628L263)","sha":"a1e216b148a7821c0b7cee8b336939dfd75a4dfb","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-minor","v8.16.0"],"title":"[Timeline]
Events request end
tracking","number":191289,"url":"https://github.com/elastic/kibana/pull/191289","mergeCommit":{"message":"[Timeline]
Events request end tracking (#191289)\n\n## Summary\r\n\r\nBring APM
`endTracking` calls back in the timeline events request, since\r\nthey
were accidentally
removed\r\n[here](https://github.com/elastic/kibana/commit/f1dc15ae4b99791616295e4c6832ee8a10d9eab6#diff-982a0a7f37bfa4c40cc92dc21648118bb152723ad895d932da368341ddea1628L263)","sha":"a1e216b148a7821c0b7cee8b336939dfd75a4dfb"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/191289","number":191289,"mergeCommit":{"message":"[Timeline]
Events request end tracking (#191289)\n\n## Summary\r\n\r\nBring APM
`endTracking` calls back in the timeline events request, since\r\nthey
were accidentally
removed\r\n[here](https://github.com/elastic/kibana/commit/f1dc15ae4b99791616295e4c6832ee8a10d9eab6#diff-982a0a7f37bfa4c40cc92dc21648118bb152723ad895d932da368341ddea1628L263)","sha":"a1e216b148a7821c0b7cee8b336939dfd75a4dfb"}}]}]
BACKPORT-->

Co-authored-by: Sergi Massaneda <sergi.massaneda@elastic.co>
  • Loading branch information
kibanamachine and semd committed Aug 26, 2024
1 parent 6ae44e4 commit 257b122
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const useApmTracking = (tableId: string) => {
// The blocking span needs to be ended manually when the batched request finishes.
const span = transaction?.startSpan('batched search', 'http-request', { blocking: true });
return {
endTracking: (result: 'success' | 'error' | 'aborted' | 'invalid') => {
endTracking: (result: 'success' | 'error' | 'aborted') => {
transaction?.addLabels({ result });
span?.end();
},
Expand Down Expand Up @@ -230,7 +230,7 @@ export const useTimelineEventsHandler = ({
abortCtrl.current = new AbortController();
setLoading(true);
if (data && data.search) {
startTracking();
const { endTracking } = startTracking();
const abortSignal = abortCtrl.current.signal;
searchSubscription$.current = data.search
.search<TimelineRequest, TimelineResponse<typeof language>>(
Expand All @@ -249,6 +249,7 @@ export const useTimelineEventsHandler = ({
next: (response) => {
if (!isRunningResponse(response)) {
setTimelineResponse((prevResponse) => {
endTracking('success');
const newTimelineResponse = {
...prevResponse,
consumers: response.consumers,
Expand All @@ -271,6 +272,7 @@ export const useTimelineEventsHandler = ({
}
},
error: (msg) => {
endTracking(abortSignal.aborted ? 'aborted' : 'error');
setLoading(false);
data.search.showError(msg);
searchSubscription$.current.unsubscribe();
Expand Down

0 comments on commit 257b122

Please sign in to comment.