this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

repo_commits_received_counter for every way a commit finishes

authored by

Brian Olson and committed by
Brian Olson
911ab8c0 a3802a80

+21
+16
bgs/bgs.go
··· 892 892 userLookupDuration.Observe(time.Since(s).Seconds()) 893 893 if err != nil { 894 894 if !errors.Is(err, gorm.ErrRecordNotFound) { 895 + repoCommitsResultCounter.WithLabelValues(host.Host, "nou").Inc() 895 896 return fmt.Errorf("looking up event user: %w", err) 896 897 } 897 898 ··· 900 901 subj, err := bgs.createExternalUser(ctx, evt.Repo) 901 902 newUserDiscoveryDuration.Observe(time.Since(start).Seconds()) 902 903 if err != nil { 904 + repoCommitsResultCounter.WithLabelValues(host.Host, "uerr").Inc() 903 905 return fmt.Errorf("fed event create external user: %w", err) 904 906 } 905 907 ··· 914 916 if u.GetTakenDown() || ustatus == events.AccountStatusTakendown { 915 917 span.SetAttributes(attribute.Bool("taken_down_by_relay_admin", u.GetTakenDown())) 916 918 log.Debugw("dropping commit event from taken down user", "did", evt.Repo, "seq", evt.Seq, "pdsHost", host.Host) 919 + repoCommitsResultCounter.WithLabelValues(host.Host, "tdu").Inc() 917 920 return nil 918 921 } 919 922 920 923 if ustatus == events.AccountStatusSuspended { 921 924 log.Debugw("dropping commit event from suspended user", "did", evt.Repo, "seq", evt.Seq, "pdsHost", host.Host) 925 + repoCommitsResultCounter.WithLabelValues(host.Host, "susu").Inc() 922 926 return nil 923 927 } 924 928 925 929 if ustatus == events.AccountStatusDeactivated { 926 930 log.Debugw("dropping commit event from deactivated user", "did", evt.Repo, "seq", evt.Seq, "pdsHost", host.Host) 931 + repoCommitsResultCounter.WithLabelValues(host.Host, "du").Inc() 927 932 return nil 928 933 } 929 934 930 935 if evt.Rebase { 936 + repoCommitsResultCounter.WithLabelValues(host.Host, "rebase").Inc() 931 937 return fmt.Errorf("rebase was true in event seq:%d,host:%s", evt.Seq, host.Host) 932 938 } 933 939 ··· 938 944 939 945 subj, err := bgs.createExternalUser(ctx, evt.Repo) 940 946 if err != nil { 947 + repoCommitsResultCounter.WithLabelValues(host.Host, "uerr2").Inc() 941 948 return err 942 949 } 943 950 944 951 if subj.PDS != host.ID { 952 + repoCommitsResultCounter.WithLabelValues(host.Host, "noauth").Inc() 945 953 return fmt.Errorf("event from non-authoritative pds") 946 954 } 947 955 } ··· 950 958 span.SetAttributes(attribute.Bool("tombstoned", true)) 951 959 // we've checked the authority of the users PDS, so reinstate the account 952 960 if err := bgs.db.Model(&User{}).Where("id = ?", u.ID).UpdateColumn("tombstoned", false).Error; err != nil { 961 + repoCommitsResultCounter.WithLabelValues(host.Host, "tomb").Inc() 953 962 return fmt.Errorf("failed to un-tombstone a user: %w", err) 954 963 } 955 964 u.SetTombstoned(false) 956 965 957 966 ai, err := bgs.Index.LookupUser(ctx, u.ID) 958 967 if err != nil { 968 + repoCommitsResultCounter.WithLabelValues(host.Host, "nou2").Inc() 959 969 return fmt.Errorf("failed to look up user (tombstone recover): %w", err) 960 970 } 961 971 962 972 // Now a simple re-crawl should suffice to bring the user back online 973 + repoCommitsResultCounter.WithLabelValues(host.Host, "catchupt").Inc() 963 974 return bgs.Index.Crawler.AddToCatchupQueue(ctx, host, ai, evt) 964 975 } 965 976 ··· 968 979 rebasesCounter.WithLabelValues(host.Host).Add(1) 969 980 ai, err := bgs.Index.LookupUser(ctx, u.ID) 970 981 if err != nil { 982 + repoCommitsResultCounter.WithLabelValues(host.Host, "nou3").Inc() 971 983 return fmt.Errorf("failed to look up user (slow path): %w", err) 972 984 } 973 985 ··· 979 991 // processor coming off of the pds stream, we should investigate 980 992 // whether or not we even need this 'slow path' logic, as it makes 981 993 // accounting for which events have been processed much harder 994 + repoCommitsResultCounter.WithLabelValues(host.Host, "catchup").Inc() 982 995 return bgs.Index.Crawler.AddToCatchupQueue(ctx, host, ai, evt) 983 996 } 984 997 ··· 988 1001 ai, lerr := bgs.Index.LookupUser(ctx, u.ID) 989 1002 if lerr != nil { 990 1003 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()) 1004 + repoCommitsResultCounter.WithLabelValues(host.Host, "nou4").Inc() 991 1005 return fmt.Errorf("failed to look up user %s (%d) (err case: %s): %w", u.Did, u.ID, err, lerr) 992 1006 } 993 1007 994 1008 span.SetAttributes(attribute.Bool("catchup_queue", true)) 995 1009 996 1010 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()) 1011 + repoCommitsResultCounter.WithLabelValues(host.Host, "catchup2").Inc() 997 1012 return bgs.Index.Crawler.AddToCatchupQueue(ctx, host, ai, evt) 998 1013 } 999 1014 1000 1015 log.Warnw("failed handling event", "err", err, "pdsHost", host.Host, "seq", evt.Seq, "repo", u.Did, "prev", stringLink(evt.Prev), "commit", evt.Commit.String()) 1016 + repoCommitsResultCounter.WithLabelValues(host.Host, "err").Inc() 1001 1017 return fmt.Errorf("handle user event failed: %w", err) 1002 1018 } 1003 1019
+5
bgs/metrics.go
··· 27 27 Help: "The total number of events received", 28 28 }, []string{"pds"}) 29 29 30 + var repoCommitsResultCounter = promauto.NewCounterVec(prometheus.CounterOpts{ 31 + Name: "repo_commits_received_counter", 32 + Help: "The total number of events received", 33 + }, []string{"pds", "status"}) 34 + 30 35 var rebasesCounter = promauto.NewCounterVec(prometheus.CounterOpts{ 31 36 Name: "event_rebases", 32 37 Help: "The total number of rebase events received",