(registry prometheus.Registerer)
| 82 | } |
| 83 | |
| 84 | func NewFactory(registry prometheus.Registerer) *Factory { |
| 85 | factory := promauto.With(registry) |
| 86 | |
| 87 | return &Factory{ |
| 88 | metrics: &metrics{ |
| 89 | externalRequestCount: factory.NewCounterVec(prometheus.CounterOpts{ |
| 90 | Namespace: "coderd", |
| 91 | Subsystem: "oauth2", |
| 92 | Name: "external_requests_total", |
| 93 | Help: "The total number of api calls made to external oauth2 providers. 'status_code' will be 0 if the request failed with no response.", |
| 94 | }, []string{ |
| 95 | "name", |
| 96 | "source", |
| 97 | "status_code", |
| 98 | }), |
| 99 | rateLimit: factory.NewGaugeVec(prometheus.GaugeOpts{ |
| 100 | Namespace: "coderd", |
| 101 | Subsystem: "oauth2", |
| 102 | Name: "external_requests_rate_limit", |
| 103 | Help: "The total number of allowed requests per interval.", |
| 104 | }, []string{ |
| 105 | "name", |
| 106 | // Resource allows different rate limits for the same oauth2 provider. |
| 107 | // Some IDPs have different buckets for different rate limits. |
| 108 | "resource", |
| 109 | }), |
| 110 | rateLimitRemaining: factory.NewGaugeVec(prometheus.GaugeOpts{ |
| 111 | Namespace: "coderd", |
| 112 | Subsystem: "oauth2", |
| 113 | Name: "external_requests_rate_limit_remaining", |
| 114 | Help: "The remaining number of allowed requests in this interval.", |
| 115 | }, []string{ |
| 116 | "name", |
| 117 | "resource", |
| 118 | }), |
| 119 | rateLimitUsed: factory.NewGaugeVec(prometheus.GaugeOpts{ |
| 120 | Namespace: "coderd", |
| 121 | Subsystem: "oauth2", |
| 122 | Name: "external_requests_rate_limit_used", |
| 123 | Help: "The number of requests made in this interval.", |
| 124 | }, []string{ |
| 125 | "name", |
| 126 | "resource", |
| 127 | }), |
| 128 | rateLimitReset: factory.NewGaugeVec(prometheus.GaugeOpts{ |
| 129 | Namespace: "coderd", |
| 130 | Subsystem: "oauth2", |
| 131 | Name: "external_requests_rate_limit_next_reset_unix", |
| 132 | Help: "Unix timestamp for when the next interval starts", |
| 133 | }, []string{ |
| 134 | "name", |
| 135 | "resource", |
| 136 | }), |
| 137 | rateLimitResetIn: factory.NewGaugeVec(prometheus.GaugeOpts{ |
| 138 | Namespace: "coderd", |
| 139 | Subsystem: "oauth2", |
| 140 | Name: "external_requests_rate_limit_reset_in_seconds", |
| 141 | Help: "Seconds until the next interval", |
no outgoing calls