porting all github actions from bluesky-social/indigo to tangled CI

update bluepages metrics

Changed files
+28 -58
cmd
+16 -46
cmd/bluepages/metrics.go
··· 5 5 "github.com/prometheus/client_golang/prometheus/promauto" 6 6 ) 7 7 8 - var handleCacheHits = promauto.NewCounter(prometheus.CounterOpts{ 9 - Name: "bluepages_resolve_handle_cache_hits", 10 - Help: "Number of cache hits for ATProto handle resolutions", 11 - }) 12 - 13 - var handleCacheMisses = promauto.NewCounter(prometheus.CounterOpts{ 14 - Name: "bluepages_resolve_handle_cache_misses", 15 - Help: "Number of cache misses for ATProto handle resolutions", 16 - }) 8 + var handleResolution = promauto.NewCounterVec(prometheus.CounterOpts{ 9 + Name: "atproto_identity_resolve_handle", 10 + Help: "ATProto handle resolutions", 11 + }, []string{"directory", "status"}) 17 12 18 - var handleRequestsCoalesced = promauto.NewCounter(prometheus.CounterOpts{ 19 - Name: "bluepages_resolve_handle_requests_coalesced", 20 - Help: "Number of handle requests coalesced", 21 - }) 22 - 23 - var handleResolutionErrors = promauto.NewCounter(prometheus.CounterOpts{ 24 - Name: "bluepages_resolve_handle_resolution_errors", 25 - Help: "Number of non-cached handle resolution errors", 26 - }) 27 - 28 - var handleResolveDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{ 29 - Name: "bluepages_resolve_handle_duration", 30 - Help: "Time to resolve a handle from network (not cached)", 13 + var handleResolutionDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{ 14 + Name: "atproto_identity_resolve_handle_duration", 15 + Help: "Time to resolve a handle", 31 16 Buckets: prometheus.ExponentialBucketsRange(0.001, 2, 15), 32 - }, []string{"status"}) 33 - 34 - var didCacheHits = promauto.NewCounter(prometheus.CounterOpts{ 35 - Name: "bluepages_resolve_did_cache_hits", 36 - Help: "Number of cache hits for ATProto DID resolutions", 37 - }) 17 + }, []string{"directory", "status"}) 38 18 39 - var didCacheMisses = promauto.NewCounter(prometheus.CounterOpts{ 40 - Name: "bluepages_resolve_did_cache_misses", 41 - Help: "Number of cache misses for ATProto DID resolutions", 42 - }) 19 + var didResolution = promauto.NewCounterVec(prometheus.CounterOpts{ 20 + Name: "atproto_identity_resolve_did", 21 + Help: "ATProto DID resolutions", 22 + }, []string{"directory", "status"}) 43 23 44 - var didRequestsCoalesced = promauto.NewCounter(prometheus.CounterOpts{ 45 - Name: "bluepages_resolve_did_requests_coalesced", 46 - Help: "Number of DID requests coalesced", 47 - }) 48 - 49 - var didResolutionErrors = promauto.NewCounter(prometheus.CounterOpts{ 50 - Name: "bluepages_resolve_did_resolution_errors", 51 - Help: "Number of non-cached DID resolution errors", 52 - }) 53 - 54 - var didResolveDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{ 55 - Name: "bluepages_resolve_did_duration", 56 - Help: "Time to resolve a DID from network (not cached)", 24 + var didResolutionDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{ 25 + Name: "atproto_identity_resolve_did_duration", 26 + Help: "Time to resolve a DID", 57 27 Buckets: prometheus.ExponentialBucketsRange(0.001, 2, 15), 58 - }, []string{"status"}) 28 + }, []string{"directory", "status"})
+12 -12
cmd/bluepages/resolver.go
··· 106 106 107 107 if err != nil { 108 108 d.Logger.Info("handle resolution failed", "handle", h, "duration", duration, "err", err) 109 - handleResolutionErrors.Inc() 110 - handleResolveDuration.WithLabelValues("fail").Observe(time.Since(start).Seconds()) 109 + handleResolution.WithLabelValues("bluepages", "error").Inc() 110 + handleResolutionDuration.WithLabelValues("bluepages", "error").Observe(time.Since(start).Seconds()) 111 111 } else { 112 - handleResolveDuration.WithLabelValues("success").Observe(time.Since(start).Seconds()) 112 + handleResolution.WithLabelValues("bluepages", "success").Inc() 113 + handleResolutionDuration.WithLabelValues("bluepages", "success").Observe(time.Since(start).Seconds()) 113 114 } 114 115 if duration.Seconds() > 5.0 { 115 116 d.Logger.Info("slow handle resolution", "handle", h, "duration", duration) ··· 139 140 140 141 if err != nil { 141 142 d.Logger.Info("DID resolution failed", "did", did, "duration", duration, "err", err) 142 - didResolutionErrors.Inc() 143 - didResolveDuration.WithLabelValues("fail").Observe(time.Since(start).Seconds()) 143 + didResolution.WithLabelValues("bluepages", "error").Inc() 144 + didResolutionDuration.WithLabelValues("bluepages", "error").Observe(time.Since(start).Seconds()) 144 145 } else { 145 - didResolveDuration.WithLabelValues("success").Observe(time.Since(start).Seconds()) 146 + didResolution.WithLabelValues("bluepages", "success").Inc() 147 + didResolutionDuration.WithLabelValues("bluepages", "success").Observe(time.Since(start).Seconds()) 146 148 } 147 149 if duration.Seconds() > 5.0 { 148 150 d.Logger.Info("slow DID resolution", "did", did, "duration", duration) ··· 178 180 return "", fmt.Errorf("identity cache read failed: %w", err) 179 181 } 180 182 if err == nil && !d.isHandleStale(&entry) { // if no error... 181 - handleCacheHits.Inc() 183 + handleResolution.WithLabelValues("bluepages", "cached").Inc() 182 184 if entry.Err != nil { 183 185 return "", entry.Err 184 186 } else if entry.DID != nil { ··· 187 189 return "", errors.New("code flow error in redis identity directory") 188 190 } 189 191 } 190 - handleCacheMisses.Inc() 191 192 192 193 // Coalesce multiple requests for the same Handle 193 194 res := make(chan struct{}) 194 195 val, loaded := d.handleResolveChans.LoadOrStore(h.String(), res) 195 196 if loaded { 196 - handleRequestsCoalesced.Inc() 197 + handleResolution.WithLabelValues("bluepages", "coalesced").Inc() 197 198 // Wait for the result from the pending request 198 199 select { 199 200 case <-val.(chan struct{}): ··· 241 242 return nil, fmt.Errorf("DID cache read failed: %w", err) 242 243 } 243 244 if err == nil && !d.isDIDStale(&entry) { // if no error... 244 - didCacheHits.Inc() 245 + didResolution.WithLabelValues("bluepages", "cached").Inc() 245 246 return entry.RawDoc, entry.Err 246 247 } 247 - didCacheMisses.Inc() 248 248 249 249 // Coalesce multiple requests for the same DID 250 250 res := make(chan struct{}) 251 251 val, loaded := d.didResolveChans.LoadOrStore(did.String(), res) 252 252 if loaded { 253 - didRequestsCoalesced.Inc() 253 + didResolution.WithLabelValues("bluepages", "coalesced").Inc() 254 254 // Wait for the result from the pending request 255 255 select { 256 256 case <-val.(chan struct{}):