Skip to content
Draft
Show file tree
Hide file tree
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 @@ -2,16 +2,23 @@
import { Logger } from '@nestjs/common';
import { RdiUrlV2 } from 'src/modules/rdi/constants';
import {
parseErrorMessage,
RdiPipelineInternalServerErrorException,
wrapRdiPipelineError,
} from 'src/modules/rdi/exceptions';
import { RdiInfo } from 'src/modules/rdi/models';
import {
RdiInfo,
RdiStatisticsResult,
RdiStatisticsStatus,
} from 'src/modules/rdi/models';

import { ApiRdiClient } from 'src/modules/rdi/client/api/v1/api.rdi.client';
import {
GetInfoResponse,
GetMetricsCollectionResponse,
GetPipelinesResponse,
} from 'src/modules/rdi/client/api/v2/responses';
import { transformMetricsCollectionResponse } from 'src/modules/rdi/client/api/v2/transformers';

export class ApiV2RdiClient extends ApiRdiClient {
protected readonly logger = new Logger('ApiV2RdiClient');
Expand Down Expand Up @@ -75,4 +82,35 @@
throw wrapRdiPipelineError(e);
}
}

/**
* Retrieves statistics for the selected pipeline.
*
* This method fetches statistics for the currently selected pipeline. The statistics
* include detailed information about the pipeline's performance, data processing,
* and other relevant metrics.
*
* @returns {Promise<RdiStatisticsResult>} A promise that resolves to an RdiStatisticsResult
* object containing the pipeline statistics
*
* @example
* const stats = await client.getStatistics();
*/
async getStatistics(): Promise<RdiStatisticsResult> {

Check warning on line 99 in redisinsight/api/src/modules/rdi/client/api/v2/api.v2.rdi.client.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
try {
const { data } = await this.client.get<GetMetricsCollectionResponse>(
RdiUrlV2.GetMetricsCollections(this.selectedPipeline),

Check warning on line 102 in redisinsight/api/src/modules/rdi/client/api/v2/api.v2.rdi.client.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
);

return plainToInstance(RdiStatisticsResult, {
status: RdiStatisticsStatus.Success,
data: {
sections: transformMetricsCollectionResponse(data),
},
});

Check warning on line 110 in redisinsight/api/src/modules/rdi/client/api/v2/api.v2.rdi.client.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
} catch (e) {
const message: string = parseErrorMessage(e);

Check warning on line 112 in redisinsight/api/src/modules/rdi/client/api/v2/api.v2.rdi.client.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
return { status: RdiStatisticsStatus.Fail, error: message };

Check warning on line 113 in redisinsight/api/src/modules/rdi/client/api/v2/api.v2.rdi.client.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

Check warning on line 114 in redisinsight/api/src/modules/rdi/client/api/v2/api.v2.rdi.client.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './info.responses';
export * from './pipeline.responses';
export * from './metrics-collections.response';
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
export enum ComponentMetricsCollections {
processorMetrics = 'processor-metrics',
collectorMetrics = 'collector-metrics',
}
export interface ComponentMetricsResponse {
name: ComponentMetricsCollections;
component: string;
metrics: object;
}

export interface ProcessorMetricsResponse extends ComponentMetricsResponse {
name: ComponentMetricsCollections.processorMetrics;
metrics: {
processing_performance: {
total_batches: number;
batch_size_avg: number;
read_time_avg: number;
transform_time_avg: number;
write_time_avg: number;
process_time_avg: number;
ack_time_avg: number;
total_time_avg: number;
rec_per_sec_avg: number;
};
data_streams: {
streams: Record<
string,
{
total: number;
pending: number;
inserted: number;
updated: number;
deleted: number;
filtered: number;
rejected: number;
deduplicated: number;
last_arrival: string;
}
>;
totals: {
total: number;
pending: number;
inserted: number;
updated: number;
deleted: number;
filtered: number;
rejected: number;
deduplicated: number;
};
};
rdi_pipeline_status: {
rdi_version: string;
address: string;
run_status: string;
sync_mode: string;
};
connections: Record<
string,
{
type: string;
host: string;
port: number;
database: string;
user: string;
password: string;
status: string;
}
>;
clients: Record<
string,
{
id: string;
addr: string;
user: string;
age_sec: string;
idle_sec: string;
}
>;
};
}

export interface CollectorMetricsResponse extends ComponentMetricsResponse {
name: ComponentMetricsCollections.collectorMetrics;
metrics: object;
}

export type GetMetricsCollectionResponse = (
| ProcessorMetricsResponse
| CollectorMetricsResponse
)[];
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './metrics-collections.transformer';
Loading
Loading