metrics

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NAMESPACE = "lauth"
)

Variables

View Source
var (
	Authz = NewEndpointMetrics(
		"authz",
		[]string{"method", "response_type", "client_id", "username", "scope", "prompt", "authn_by"},
		[]string{"method", "response_type", "authn_by"},
	)
)
View Source
var (
	HTTPLatency = prometheus.NewSummaryVec(
		prometheus.SummaryOpts{
			Namespace: NAMESPACE,
			Subsystem: "http",
			Name:      "latency_seconds",
			Help:      "The whole latency of each endpoint. It is includes non-core process like minifying or compression.",
		},
		[]string{"method", "path", "status"},
	)
)
View Source
var (
	Logout = NewEndpointMetrics(
		"logout",
		[]string{"client_id", "username", "redirect_uri"},
		[]string{"client_id"},
	)
)
View Source
var (
	Token = NewEndpointMetrics(
		"token",
		[]string{"grant_type", "client_id", "username", "scope"},
		[]string{"grant_type"},
	)
)
View Source
var (
	Userinfo = NewEndpointMetrics(
		"userinfo",
		[]string{"client_id", "username", "scope"},
		[]string{"client_id"},
	)
)

Functions

func Handler

func Handler(username, password string) http.Handler

func Middleware

func Middleware(handler http.Handler) http.Handler

Types

type Context

type Context struct {
	Error   error
	Metrics *EndpointMetrics
	Labels  prometheus.Labels
	Method  string
	Path    string
	Remote  string
	// contains filtered or unexported fields
}

func StartAuthz

func StartAuthz(ctx *gin.Context) *Context

func StartLogout added in v0.1.0

func StartLogout(c *gin.Context) *Context

func StartToken

func StartToken(c *gin.Context) *Context

func StartUserinfo

func StartUserinfo(c *gin.Context) *Context

func (*Context) ClientError added in v0.1.0

func (c *Context) ClientError()

ClientError is client side error except UserError.

func (*Context) Close

func (c *Context) Close() error

func (*Context) Continue added in v0.1.0

func (c *Context) Continue()

Continue is succeed process but not done.

func (*Context) Observe

func (c *Context) Observe(v float64)

func (*Context) ServerError added in v0.1.0

func (c *Context) ServerError()

ServerError is internal server error.

func (*Context) Set

func (c *Context) Set(key, value string)

func (*Context) SetError

func (c *Context) SetError(err error, reason, description string)

func (*Context) Success added in v0.1.0

func (c *Context) Success()

Success is succeed process and done.

func (*Context) UserError added in v0.1.0

func (c *Context) UserError()

UserError is invalid username or password or something.

type EndpointMetrics

type EndpointMetrics struct {
	Name        string
	Labels      []string
	TimerLabels []string
	Latency     *prometheus.SummaryVec
	Count       *prometheus.CounterVec
}

func NewEndpointMetrics

func NewEndpointMetrics(name string, labels []string, timerLabels []string) *EndpointMetrics

func (*EndpointMetrics) MustRegister

func (em *EndpointMetrics) MustRegister()

func (*EndpointMetrics) Start

func (em *EndpointMetrics) Start(ctx *gin.Context) *Context

type ErrorReporter

type ErrorReporter interface {
	SetError(err error, reason, description string)
}

type LogContext

type LogContext struct {
	Method      string
	Path        string
	Remote      string
	Err         error
	Error       string
	Description string
	Latency     float64
	// contains filtered or unexported fields
}

func StartLogging

func StartLogging(ctx *gin.Context) *LogContext

func (*LogContext) Close

func (c *LogContext) Close() error

func (*LogContext) Observe

func (c *LogContext) Observe(v float64)

func (*LogContext) SetError

func (c *LogContext) SetError(err error, reason, description string)

type ResponseCollcetor

type ResponseCollcetor struct {
	Upstream http.ResponseWriter
	Code     int
}

func (*ResponseCollcetor) Header

func (w *ResponseCollcetor) Header() http.Header

func (*ResponseCollcetor) StatusClass

func (w *ResponseCollcetor) StatusClass() string

func (*ResponseCollcetor) Write

func (w *ResponseCollcetor) Write(data []byte) (int, error)

func (*ResponseCollcetor) WriteHeader

func (w *ResponseCollcetor) WriteHeader(statusCode int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL