improve(buffer): don't add profile if its from an event and already created

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-02-24 22:55:30 +01:00
parent bc3b9ae7bf
commit 5863dd8c2b
3 changed files with 33 additions and 22 deletions

View File

@@ -53,7 +53,7 @@ export class ProfileBuffer extends BaseBuffer {
return `${this.redisProfilePrefix}${projectId}:${profileId}`;
}
async add(profile: IClickhouseProfile) {
async add(profile: IClickhouseProfile, isFromEvent = false) {
const logger = this.logger.child({
projectId: profile.project_id,
profileId: profile.id,
@@ -64,6 +64,11 @@ export class ProfileBuffer extends BaseBuffer {
const existingProfile = await this.fetchFromCache(profile, logger);
if (isFromEvent && existingProfile) {
logger.debug('Profile already created, skipping');
return;
}
const mergedProfile: IClickhouseProfile = existingProfile
? deepMergeObjects(existingProfile, profile)
: profile;