Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(plugin-server): add labels to merge txn metrics #17934

Merged
merged 1 commit into from
Oct 12, 2023
Merged
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
24 changes: 21 additions & 3 deletions plugin-server/src/worker/ingestion/person-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ export const mergeFinalFailuresCounter = new Counter({
export const mergeTxnAttemptCounter = new Counter({
name: 'person_merge_txn_attempt_total',
help: 'Number of person merge attempts.',
labelNames: ['call', 'oldPersonIdentified', 'newPersonIdentified', 'poEEmbraceJoin'],
xvello marked this conversation as resolved.
Show resolved Hide resolved
})

export const mergeTxnSuccessCounter = new Counter({
name: 'person_merge_txn_success_total',
help: 'Number of person merges that succeeded.',
labelNames: ['call', 'oldPersonIdentified', 'newPersonIdentified', 'poEEmbraceJoin'],
})

// used to prevent identify from being used with generic IDs
Expand Down Expand Up @@ -152,8 +154,10 @@ export class PersonState {
return await this.updatePersonProperties(person)
}

/**
* @returns [Person, boolean that indicates if properties were already handled or not]
*/
private async createOrGetPerson(): Promise<[Person, boolean]> {
// returns: person, properties were already handled or not
let person = await this.db.fetchPerson(this.teamId, this.distinctId)
if (person) {
return [person, false]
Expand Down Expand Up @@ -477,7 +481,14 @@ export class PersonState {
createdAt: DateTime,
properties: Properties
): Promise<[ProducerRecord[], Person]> {
mergeTxnAttemptCounter.inc()
mergeTxnAttemptCounter
.labels({
call: this.event.event, // $identify, $create_alias or $merge_dangerously
oldPersonIdentified: String(otherPerson.is_identified),
newPersonIdentified: String(mergeInto.is_identified),
poEEmbraceJoin: String(this.poEEmbraceJoin),
})
.inc()

const result: [ProducerRecord[], Person] = await this.db.postgres.transaction(
PostgresUse.COMMON_WRITE,
Expand Down Expand Up @@ -518,7 +529,14 @@ export class PersonState {
}
)

mergeTxnSuccessCounter.inc()
mergeTxnSuccessCounter
.labels({
call: this.event.event, // $identify, $create_alias or $merge_dangerously
oldPersonIdentified: String(otherPerson.is_identified),
newPersonIdentified: String(mergeInto.is_identified),
poEEmbraceJoin: String(this.poEEmbraceJoin),
})
.inc()
return result
}

Expand Down
Loading