Documentation
¶
Index ¶
- Variables
- func Caller(ctx context.Context) string
- func GetResponseBody(resp *http.Response) ([]byte, error)
- func Handler(w http.ResponseWriter, r *http.Request, user, pass string)
- func IncAuthFailure(integration string)
- func IncInternalResponse(integration string, status int, reason string)
- func IncRateLimit(integration string)
- func IncRequest(integration string)
- func OnRequest(integration string, r *http.Request)
- func OnResponse(integration, caller string, r *http.Request, resp *http.Response)
- func RecordEndToEndDuration(integration string, d time.Duration)
- func RecordPreProxyDuration(integration string, d time.Duration)
- func RecordResponseProcessingDuration(integration string, d time.Duration)
- func RecordStatus(integration string, status int)
- func RecordUpstreamRoundtripDuration(integration string, d time.Duration)
- func Register(p Plugin)
- func Reset()
- func UpstreamRoundtripStart(ctx context.Context) (time.Time, bool)
- func WithCaller(ctx context.Context, caller string) context.Context
- func WithUpstreamRoundtripStart(ctx context.Context, start time.Time) context.Context
- func WriteProm(w http.ResponseWriter)
- type Plugin
Constants ¶
This section is empty.
Variables ¶
var (
LastReloadTime = expvar.NewString("authtranslator_last_reload")
)
Functions ¶
func GetResponseBody ¶ added in v0.2.0
GetResponseBody returns the response body bytes and resets resp.Body so it can be read again. It closes the original body to allow connection reuse.
func Handler ¶
func Handler(w http.ResponseWriter, r *http.Request, user, pass string)
Handler writes Prometheus metrics to w enforcing optional basic auth.
func IncAuthFailure ¶
func IncAuthFailure(integration string)
IncAuthFailure increments the auth failure counter for the integration.
func IncInternalResponse ¶ added in v0.2.9
IncInternalResponse increments the counter for proxy-generated responses with a coarse reason label to keep cardinality bounded.
func IncRateLimit ¶
func IncRateLimit(integration string)
IncRateLimit increments the rate limit counter for the integration.
func IncRequest ¶
func IncRequest(integration string)
IncRequest increments the request counter for the integration.
func OnResponse ¶
OnResponse triggers all registered plugins for a completed response.
func RecordEndToEndDuration ¶ added in v0.3.0
RecordEndToEndDuration records full request latency as observed by the AuthTranslator handler.
func RecordPreProxyDuration ¶ added in v0.3.0
RecordPreProxyDuration records request-side processing time before AuthTranslator proxies upstream or returns a local response.
func RecordResponseProcessingDuration ¶ added in v0.3.0
RecordResponseProcessingDuration records response-side processing time inside AuthTranslator after an upstream response is received and before streaming the body to the client begins.
func RecordStatus ¶
RecordStatus records the upstream status code for the integration.
func RecordUpstreamRoundtripDuration ¶ added in v0.3.0
RecordUpstreamRoundtripDuration records the duration from proxy handoff until AuthTranslator receives the upstream response.
func UpstreamRoundtripStart ¶ added in v0.3.0
UpstreamRoundtripStart retrieves the upstream handoff start time from the context if present.
func WithCaller ¶
WithCaller returns a new context with the caller ID stored.
func WithUpstreamRoundtripStart ¶ added in v0.3.0
WithUpstreamRoundtripStart stores the upstream handoff start time in the request context.
func WriteProm ¶
func WriteProm(w http.ResponseWriter)
WriteProm emits all Prometheus metrics to w in text format.