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] Separate count/retainment telemetry requests #63225

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ export const tasks: TelemetryTask[] = [
return prevJob.then(async data => {
const { processorEvent, timeRange } = current;

const response = await search({
const totalHitsResponse = await search({
index: indicesByProcessorEvent[processorEvent],
body: {
size: 1,
size: 0,
query: {
bool: {
filter: [
Expand All @@ -83,25 +83,43 @@ export const tasks: TelemetryTask[] = [
]
}
},
sort: {
'@timestamp': 'asc'
},
_source: ['@timestamp'],
track_total_hits: true
}
});

const event = response.hits.hits[0]?._source as {
'@timestamp': number;
};
const retainmentResponse =
timeRange === 'all'
? await search({
index: indicesByProcessorEvent[processorEvent],
body: {
query: {
bool: {
filter: [
{ term: { [PROCESSOR_EVENT]: processorEvent } }
]
}
},
sort: {
'@timestamp': 'asc'
},
_source: ['@timestamp']
}
})
: null;

const event = retainmentResponse?.hits.hits[0]?._source as
| {
'@timestamp': number;
}
| undefined;

return merge({}, data, {
counts: {
[processorEvent]: {
[timeRange]: response.hits.total.value
[timeRange]: totalHitsResponse.hits.total.value
}
},
...(timeRange === 'all' && event
...(event
? {
retainment: {
[processorEvent]: {
Expand Down