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: create issue fingerprint table in postgres #25690

Merged
merged 12 commits into from
Oct 24, 2024
2 changes: 1 addition & 1 deletion latest_migrations.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ contenttypes: 0002_remove_content_type_name
ee: 0016_rolemembership_organization_member
otp_static: 0002_throttling
otp_totp: 0002_auto_20190420_0723
posthog: 0493_insightvariable_values
posthog: 0494_errortrackingissuefingerprint_and_more
sessions: 0001_initial
social_django: 0010_uid_db_index
two_factor: 0007_auto_20201201_1019
33 changes: 33 additions & 0 deletions posthog/migrations/0494_errortrackingissuefingerprint_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 4.2.15 on 2024-10-18 15:56

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
dependencies = [
("posthog", "0493_insightvariable_values"),
]

operations = [
migrations.CreateModel(
name="ErrorTrackingIssueFingerprint",
fields=[
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("fingerprint", models.CharField(max_length=400)),
("version", models.BigIntegerField(blank=True, null=True)),
(
"issue",
models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.errortrackinggroup"),
),
(
"team",
models.ForeignKey(db_index=False, on_delete=django.db.models.deletion.CASCADE, to="posthog.team"),
),
],
),
migrations.AddConstraint(
model_name="errortrackingissuefingerprint",
constraint=models.UniqueConstraint(fields=("team", "fingerprint"), name="unique fingerprint for team"),
),
]
12 changes: 12 additions & 0 deletions posthog/models/error_tracking/error_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,15 @@ def convert_fingerprints_to_tuples(fps: list[list[str]]):
# converting back to list of lists before saving
self.merged_fingerprints = [list(f) for f in merged_fingerprints]
self.save()


class ErrorTrackingIssueFingerprint(models.Model):
team = models.ForeignKey("Team", on_delete=models.CASCADE, db_index=False)
issue = models.ForeignKey(ErrorTrackingGroup, on_delete=models.CASCADE)
fingerprint = models.CharField(max_length=400)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going with a string here. I know fingerprints are arrays of strings right now but I feel like the intention is to move towards a proper hash that will be stored as a string

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's correct, yeah.... although I don't know that setting a 400 character limit on it is a good idea. We want a postgres TEXT field here I think (unless this is a constraint coming from clickhouse?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

400 is a "magic number" dotted around our codebase whose significance I don't understand.


# current version of the id, used to sync with ClickHouse and collapse rows correctly for overrides ClickHouse table
version = models.BigIntegerField(null=True, blank=True)
daibhin marked this conversation as resolved.
Show resolved Hide resolved

class Meta:
constraints = [models.UniqueConstraint(fields=["team", "fingerprint"], name="unique fingerprint for team")]