1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-20 00:08:02 +01:00

feat: count frontend api requests (#6495)

Now frontend API requests will be counted separately under
getAllByfrontend. We are already tracking new FE db calls, so we can
build grafana dashboard.
This commit is contained in:
Jaanus Sellin 2024-03-11 14:54:14 +02:00 committed by GitHub
parent 184e0e5190
commit a544a8a4ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 3 deletions

View File

@ -25,7 +25,7 @@ import Raw = Knex.Raw;
export interface IGetAllFeatures { export interface IGetAllFeatures {
featureQuery?: IFeatureToggleQuery; featureQuery?: IFeatureToggleQuery;
archived: boolean; archived: boolean;
requestType: 'client' | 'admin' | 'playground'; requestType: 'client' | 'admin' | 'playground' | 'frontend';
userId?: number; userId?: number;
} }
@ -71,7 +71,7 @@ export default class FeatureToggleClientStore
const isAdmin = requestType === 'admin'; const isAdmin = requestType === 'admin';
const isPlayground = requestType === 'playground'; const isPlayground = requestType === 'playground';
const environment = featureQuery?.environment || DEFAULT_ENV; const environment = featureQuery?.environment || DEFAULT_ENV;
const stopTimer = this.timer(`getFeatureAdmin${requestType}`); const stopTimer = this.timer(`getAllBy${requestType}`);
let selectColumns = [ let selectColumns = [
'features.name as name', 'features.name as name',
@ -354,6 +354,16 @@ export default class FeatureToggleClientStore
}); });
} }
async getFrontendApiClient(
featureQuery?: IFeatureToggleQuery,
): Promise<IFeatureToggleClient[]> {
return this.getAll({
featureQuery,
archived: false,
requestType: 'frontend',
});
}
async getPlayground( async getPlayground(
featureQuery?: IFeatureToggleQuery, featureQuery?: IFeatureToggleQuery,
): Promise<IFeatureToggleClient[]> { ): Promise<IFeatureToggleClient[]> {

View File

@ -54,6 +54,12 @@ export default class FakeClientFeatureToggleStore
return this.getFeatures(query); return this.getFeatures(query);
} }
async getFrontendApiClient(
query?: IFeatureToggleQuery,
): Promise<IFeatureToggleClient[]> {
return this.getFeatures(query);
}
async getPlayground( async getPlayground(
query?: IFeatureToggleQuery, query?: IFeatureToggleQuery,
): Promise<IFeatureToggleClient[]> { ): Promise<IFeatureToggleClient[]> {

View File

@ -9,6 +9,10 @@ export interface IFeatureToggleClientStore {
featureQuery: Partial<IFeatureToggleQuery>, featureQuery: Partial<IFeatureToggleQuery>,
): Promise<IFeatureToggleClient[]>; ): Promise<IFeatureToggleClient[]>;
getFrontendApiClient(
featureQuery: Partial<IFeatureToggleQuery>,
): Promise<IFeatureToggleClient[]>;
getPlayground( getPlayground(
featureQuery: Partial<IFeatureToggleQuery>, featureQuery: Partial<IFeatureToggleQuery>,
): Promise<IFeatureToggleClient[]>; ): Promise<IFeatureToggleClient[]>;

View File

@ -1064,7 +1064,7 @@ class FeatureToggleService {
async getClientFeatures( async getClientFeatures(
query?: IFeatureToggleQuery, query?: IFeatureToggleQuery,
): Promise<FeatureConfigurationClient[]> { ): Promise<FeatureConfigurationClient[]> {
const result = await this.clientFeatureToggleStore.getClient( const result = await this.clientFeatureToggleStore.getFrontendApiClient(
query || {}, query || {},
); );
return result.map( return result.map(