MCPcopy Index your code
hub / github.com/coder/coder / NewFactory

Function NewFactory

coderd/promoauth/oauth2.go:84–148  ·  view source on GitHub ↗
(registry prometheus.Registerer)

Source from the content-addressed store, hash-verified

82}
83
84func 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",

Callers 10

TestUserOAuth2GithubFunction · 0.92
ExternalAuthConfigMethod · 0.92
TestInstrumentFunction · 0.92
TestGithubRateLimitsFunction · 0.92
TestValidateTokenFunction · 0.92
TestConvertYAMLFunction · 0.92
setupOauth2TestFunction · 0.92
ServerMethod · 0.92

Calls

no outgoing calls

Tested by 8

TestUserOAuth2GithubFunction · 0.74
TestInstrumentFunction · 0.74
TestGithubRateLimitsFunction · 0.74
TestValidateTokenFunction · 0.74
TestConvertYAMLFunction · 0.74
setupOauth2TestFunction · 0.74