···892892 userLookupDuration.Observe(time.Since(s).Seconds())
893893 if err != nil {
894894 if !errors.Is(err, gorm.ErrRecordNotFound) {
895895+ repoCommitsResultCounter.WithLabelValues(host.Host, "nou").Inc()
895896 return fmt.Errorf("looking up event user: %w", err)
896897 }
897898···900901 subj, err := bgs.createExternalUser(ctx, evt.Repo)
901902 newUserDiscoveryDuration.Observe(time.Since(start).Seconds())
902903 if err != nil {
904904+ repoCommitsResultCounter.WithLabelValues(host.Host, "uerr").Inc()
903905 return fmt.Errorf("fed event create external user: %w", err)
904906 }
905907···914916 if u.GetTakenDown() || ustatus == events.AccountStatusTakendown {
915917 span.SetAttributes(attribute.Bool("taken_down_by_relay_admin", u.GetTakenDown()))
916918 log.Debugw("dropping commit event from taken down user", "did", evt.Repo, "seq", evt.Seq, "pdsHost", host.Host)
919919+ repoCommitsResultCounter.WithLabelValues(host.Host, "tdu").Inc()
917920 return nil
918921 }
919922920923 if ustatus == events.AccountStatusSuspended {
921924 log.Debugw("dropping commit event from suspended user", "did", evt.Repo, "seq", evt.Seq, "pdsHost", host.Host)
925925+ repoCommitsResultCounter.WithLabelValues(host.Host, "susu").Inc()
922926 return nil
923927 }
924928925929 if ustatus == events.AccountStatusDeactivated {
926930 log.Debugw("dropping commit event from deactivated user", "did", evt.Repo, "seq", evt.Seq, "pdsHost", host.Host)
931931+ repoCommitsResultCounter.WithLabelValues(host.Host, "du").Inc()
927932 return nil
928933 }
929934930935 if evt.Rebase {
936936+ repoCommitsResultCounter.WithLabelValues(host.Host, "rebase").Inc()
931937 return fmt.Errorf("rebase was true in event seq:%d,host:%s", evt.Seq, host.Host)
932938 }
933939···938944939945 subj, err := bgs.createExternalUser(ctx, evt.Repo)
940946 if err != nil {
947947+ repoCommitsResultCounter.WithLabelValues(host.Host, "uerr2").Inc()
941948 return err
942949 }
943950944951 if subj.PDS != host.ID {
952952+ repoCommitsResultCounter.WithLabelValues(host.Host, "noauth").Inc()
945953 return fmt.Errorf("event from non-authoritative pds")
946954 }
947955 }
···950958 span.SetAttributes(attribute.Bool("tombstoned", true))
951959 // we've checked the authority of the users PDS, so reinstate the account
952960 if err := bgs.db.Model(&User{}).Where("id = ?", u.ID).UpdateColumn("tombstoned", false).Error; err != nil {
961961+ repoCommitsResultCounter.WithLabelValues(host.Host, "tomb").Inc()
953962 return fmt.Errorf("failed to un-tombstone a user: %w", err)
954963 }
955964 u.SetTombstoned(false)
956965957966 ai, err := bgs.Index.LookupUser(ctx, u.ID)
958967 if err != nil {
968968+ repoCommitsResultCounter.WithLabelValues(host.Host, "nou2").Inc()
959969 return fmt.Errorf("failed to look up user (tombstone recover): %w", err)
960970 }
961971962972 // Now a simple re-crawl should suffice to bring the user back online
973973+ repoCommitsResultCounter.WithLabelValues(host.Host, "catchupt").Inc()
963974 return bgs.Index.Crawler.AddToCatchupQueue(ctx, host, ai, evt)
964975 }
965976···968979 rebasesCounter.WithLabelValues(host.Host).Add(1)
969980 ai, err := bgs.Index.LookupUser(ctx, u.ID)
970981 if err != nil {
982982+ repoCommitsResultCounter.WithLabelValues(host.Host, "nou3").Inc()
971983 return fmt.Errorf("failed to look up user (slow path): %w", err)
972984 }
973985···979991 // processor coming off of the pds stream, we should investigate
980992 // whether or not we even need this 'slow path' logic, as it makes
981993 // accounting for which events have been processed much harder
994994+ repoCommitsResultCounter.WithLabelValues(host.Host, "catchup").Inc()
982995 return bgs.Index.Crawler.AddToCatchupQueue(ctx, host, ai, evt)
983996 }
984997···9881001 ai, lerr := bgs.Index.LookupUser(ctx, u.ID)
9891002 if lerr != nil {
9901003 log.Warnw("failed handling event, no user", "err", err, "pdsHost", host.Host, "seq", evt.Seq, "repo", u.Did, "prev", stringLink(evt.Prev), "commit", evt.Commit.String())
10041004+ repoCommitsResultCounter.WithLabelValues(host.Host, "nou4").Inc()
9911005 return fmt.Errorf("failed to look up user %s (%d) (err case: %s): %w", u.Did, u.ID, err, lerr)
9921006 }
99310079941008 span.SetAttributes(attribute.Bool("catchup_queue", true))
99510099961010 log.Infow("failed handling event, catchup", "err", err, "pdsHost", host.Host, "seq", evt.Seq, "repo", u.Did, "prev", stringLink(evt.Prev), "commit", evt.Commit.String())
10111011+ repoCommitsResultCounter.WithLabelValues(host.Host, "catchup2").Inc()
9971012 return bgs.Index.Crawler.AddToCatchupQueue(ctx, host, ai, evt)
9981013 }
999101410001015 log.Warnw("failed handling event", "err", err, "pdsHost", host.Host, "seq", evt.Seq, "repo", u.Did, "prev", stringLink(evt.Prev), "commit", evt.Commit.String())
10161016+ repoCommitsResultCounter.WithLabelValues(host.Host, "err").Inc()
10011017 return fmt.Errorf("handle user event failed: %w", err)
10021018 }
10031019
+5
bgs/metrics.go
···2727 Help: "The total number of events received",
2828}, []string{"pds"})
29293030+var repoCommitsResultCounter = promauto.NewCounterVec(prometheus.CounterOpts{
3131+ Name: "repo_commits_received_counter",
3232+ Help: "The total number of events received",
3333+}, []string{"pds", "status"})
3434+3035var rebasesCounter = promauto.NewCounterVec(prometheus.CounterOpts{
3136 Name: "event_rebases",
3237 Help: "The total number of rebase events received",