mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-19 17:52:45 +02:00
chore: add some debug statements controlled by a flag (#10532)
## About the changes Add some **info** logs prefixed with `[etag]` so que can control them and with this investigate the increase in traffic after the new etag implementation.
This commit is contained in:
parent
0cd64780fa
commit
ac11af8c05
@ -147,15 +147,13 @@ export default class FeatureController extends Controller {
|
||||
|
||||
if (clientFeatureCaching.enabled) {
|
||||
this.featuresAndSegments = memoizee(
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
(query: IFeatureToggleQuery, etag: string) =>
|
||||
(query: IFeatureToggleQuery, _etag: string) =>
|
||||
this.resolveFeaturesAndSegments(query),
|
||||
{
|
||||
promise: true,
|
||||
maxAge: clientFeatureCaching.maxAge,
|
||||
normalizer(args) {
|
||||
// args is arguments object as accessible in memoized function
|
||||
return args[1];
|
||||
normalizer([_query, etag]) {
|
||||
return etag;
|
||||
},
|
||||
},
|
||||
);
|
||||
@ -167,6 +165,11 @@ export default class FeatureController extends Controller {
|
||||
private async resolveFeaturesAndSegments(
|
||||
query?: IFeatureToggleQuery,
|
||||
): Promise<[FeatureConfigurationClient[], IClientSegment[]]> {
|
||||
if (this.flagResolver.isEnabled('debugEtag')) {
|
||||
this.logger.info(
|
||||
`[etag] Flags and segments cache miss for ${JSON.stringify(query)}`,
|
||||
);
|
||||
}
|
||||
if (this.flagResolver.isEnabled('deltaApi')) {
|
||||
const features =
|
||||
await this.clientFeatureToggleService.getClientFeatures(query);
|
||||
@ -324,9 +327,11 @@ export default class FeatureController extends Controller {
|
||||
res.end();
|
||||
return;
|
||||
} else {
|
||||
this.logger.debug(
|
||||
`Provided revision: ${userVersion}, calculated revision: ${etag}`,
|
||||
);
|
||||
if (this.flagResolver.isEnabled('debugEtag')) {
|
||||
this.logger.info(
|
||||
`[etag] Provided revision: ${userVersion}, calculated revision: ${etag}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const [features, segments] = await this.featuresAndSegments(
|
||||
@ -364,6 +369,13 @@ export default class FeatureController extends Controller {
|
||||
);
|
||||
|
||||
const queryHash = hashSum(query);
|
||||
if (this.flagResolver.isEnabled('debugEtag')) {
|
||||
this.logger.info(
|
||||
`[etag] for query ${JSON.stringify(
|
||||
query,
|
||||
)} is "${queryHash}:${revisionId}" (revision id query with env ${etagByEnvEnabled ? query.environment : undefined})`,
|
||||
);
|
||||
}
|
||||
const etagVariant = this.flagResolver.getVariant('etagVariant');
|
||||
if (etagVariant.feature_enabled && etagVariant.enabled) {
|
||||
const etag = `"${queryHash}:${revisionId}:${etagVariant.name}"`;
|
||||
|
@ -80,6 +80,12 @@ export default class ConfigurationRevisionService extends EventEmitter {
|
||||
this.maxRevisionId[environment] = envRevisionId;
|
||||
}
|
||||
|
||||
if (this.flagResolver.isEnabled('debugEtag')) {
|
||||
this.logger.info(
|
||||
`[etag] Computed ETag for environment ${environment}: ${envRevisionId} stored as "${this.maxRevisionId[environment]}"`,
|
||||
);
|
||||
}
|
||||
|
||||
return this.maxRevisionId[environment];
|
||||
}
|
||||
|
||||
@ -92,9 +98,15 @@ export default class ConfigurationRevisionService extends EventEmitter {
|
||||
this.revisionId,
|
||||
);
|
||||
if (this.revisionId !== revisionId) {
|
||||
this.logger.debug(
|
||||
`Updating feature configuration with new revision Id ${revisionId} and all envs: ${Object.keys(this.maxRevisionId).join(', ')}`,
|
||||
);
|
||||
if (this.flagResolver.isEnabled('debugEtag')) {
|
||||
this.logger.info(
|
||||
`[etag] Updating feature configuration with new revision Id ${revisionId} and all envs: ${Object.keys(this.maxRevisionId).join(', ')}`,
|
||||
);
|
||||
} else {
|
||||
this.logger.debug(
|
||||
`Updating feature configuration with new revision Id ${revisionId} and all envs: ${Object.keys(this.maxRevisionId).join(', ')}`,
|
||||
);
|
||||
}
|
||||
await Promise.allSettled(
|
||||
Object.keys(this.maxRevisionId).map((environment) =>
|
||||
this.updateMaxEnvironmentRevisionId(environment),
|
||||
|
@ -61,7 +61,8 @@ export type IFlagKey =
|
||||
| 'addConfiguration'
|
||||
| 'filterFlagsToArchive'
|
||||
| 'fetchMode'
|
||||
| 'etagByEnv';
|
||||
| 'etagByEnv'
|
||||
| 'debugEtag';
|
||||
|
||||
export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user