Skip to content

Commit

Permalink
Adds logger.info messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Oct 3, 2022
1 parent bf0ac44 commit 19ce5ef
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions x-pack/plugins/aiops/common/api/stream_reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function streamReducer(
return action.reduce(streamReducer, state);
}

// eslint-disable-next-line no-console
console.log('action', action);

switch (action.type) {
Expand Down
18 changes: 18 additions & 0 deletions x-pack/plugins/aiops/server/routes/explain_log_rate_spikes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export const defineExplainLogRateSpikesRoute = (
return response.forbidden();
}

logger.info('Explain Log Rate Spikes: Starting analysis.');

const groupingEnabled = !!request.body.grouping;

const client = (await context.core).elasticsearch.client.asCurrentUser;
Expand All @@ -84,10 +86,12 @@ export const defineExplainLogRateSpikesRoute = (
let loaded = 0;
let shouldStop = false;
request.events.aborted$.subscribe(() => {
logger.info('Explain Log Rate Spikes: aborted$ subscription trigger.');
shouldStop = true;
controller.abort();
});
request.events.completed$.subscribe(() => {
logger.info('Explain Log Rate Spikes: completed$ subscription trigger.');
shouldStop = true;
controller.abort();
});
Expand All @@ -105,6 +109,7 @@ export const defineExplainLogRateSpikesRoute = (
const pingInterval = setInterval(pushPing, 1000);

function end() {
logger.info('Explain Log Rate Spikes: Ending analysis.');
clearInterval(pingInterval);
streamEnd();
}
Expand All @@ -127,12 +132,15 @@ export const defineExplainLogRateSpikesRoute = (
}

function pushError(m: string) {
logger.info('Explain Log Rate Spikes: Push error.');
push(addErrorAction(m));
}

// Async IIFE to run the analysis while not blocking returning `responseWithHeaders`.
(async () => {
logger.info('Explain Log Rate Spikes: Reset.');
push(resetAction());
logger.info('Explain Log Rate Spikes: Load field candidates.');
push(
updateLoadingStateAction({
ccsWarning: false,
Expand Down Expand Up @@ -188,6 +196,8 @@ export const defineExplainLogRateSpikesRoute = (

const fieldCandidatesChunks = chunk(fieldCandidates, chunkSize);

logger.info('Explain Log Rate Spikes: Fetch p-values.');

for (const fieldCandidatesChunk of fieldCandidatesChunks) {
let pValues: Awaited<ReturnType<typeof fetchChangePointPValues>>;
try {
Expand Down Expand Up @@ -252,6 +262,8 @@ export const defineExplainLogRateSpikesRoute = (
{ fieldName: request.body.timeFieldName, type: KBN_FIELD_TYPES.DATE },
];

logger.info('Explain Log Rate Spikes: Fetch overall histogram.');

let overallTimeSeries: NumericChartData | undefined;
try {
overallTimeSeries = (
Expand Down Expand Up @@ -288,6 +300,8 @@ export const defineExplainLogRateSpikesRoute = (
}

if (groupingEnabled) {
logger.info('Explain Log Rate Spikes: Group results.');

push(
updateLoadingStateAction({
ccsWarning: false,
Expand Down Expand Up @@ -471,6 +485,8 @@ export const defineExplainLogRateSpikesRoute = (

pushHistogramDataLoadingState();

logger.info('Explain Log Rate Spikes: Fetch group histograms.');

await asyncForEach(changePointGroups, async (cpg) => {
if (overallTimeSeries !== undefined) {
const histogramQuery = {
Expand Down Expand Up @@ -548,6 +564,8 @@ export const defineExplainLogRateSpikesRoute = (

loaded += PROGRESS_STEP_HISTOGRAMS_GROUPS;

logger.info('Explain Log Rate Spikes: Fetch field/value histograms.');

// time series filtered by fields
if (changePoints && overallTimeSeries !== undefined) {
await asyncForEach(changePoints, async (cp) => {
Expand Down

0 comments on commit 19ce5ef

Please sign in to comment.