Documentation ¶
Index ¶
- Variables
- func Close()
- func DefaultLimitfactor(c *gin.Context, limit int64) (string, int64)
- func GenerateToken(username, password string) (string, error)
- func GetSpan(ctx *gin.Context) (span stdot.Span, exists bool)
- func Init(conf *setting.Configs) error
- func InjectToHeaders(abortOnErrors bool) gin.HandlerFunc
- func JWT() gin.HandlerFunc
- func Limiter(getLimitfactor GetLimitfactor, limit int64) gin.HandlerFunc
- func LivenessProbe() gin.HandlerFunc
- func MustGetSpan(ctx *gin.Context) stdot.Span
- func NewSpan(operationName string, opts ...stdot.StartSpanOption) gin.HandlerFunc
- func ReadinessProbe() gin.HandlerFunc
- func SpanFromContext(operationName string, abortOnErrors bool, ...) gin.HandlerFunc
- func SpanFromHeaders(operationName string, psr ParentSpanReferenceFunc, abortOnErrors bool, ...) gin.HandlerFunc
- func StartPrometheusProbes(engine *gin.Engine)
- type Claims
- type Closeble
- type GetLimitfactor
- type ParentSpanReferenceFunc
- type Register
Constants ¶
This section is empty.
Variables ¶
var ( ReadinessPath = "/readiness" LivenessPath = "/liveness" )
add Probe for readiness and liveness
var CPsrFunc = func(spancontext stdot.SpanContext) stdot.StartSpanOption { return stdot.ChildOf(spancontext) }
var Closelist []Closeble
var (
ErrSpanNotFound = errors.New("span was not found in context")
)
var FPsrFunc = func(spancontext stdot.SpanContext) stdot.StartSpanOption { return stdot.FollowsFrom(spancontext) }
var Initlist []Register
Functions ¶
func DefaultLimitfactor ¶
DefaultLimitfactor default func of GetLimitfactor
func GenerateToken ¶
func InjectToHeaders ¶
func InjectToHeaders(abortOnErrors bool) gin.HandlerFunc
InjectToHeaders injects span meta-information to request headers.
It may be useful when you want to trace chained request (client->service 1->service 2). In this case you have to save request headers (ctx.Request.Header) and pass it to next level request.
Behaviour on errors determined by abortOnErrors option. If it set to true request handling will be aborted with error.
func JWT ¶
func JWT() gin.HandlerFunc
func Limiter ¶
func Limiter(getLimitfactor GetLimitfactor, limit int64) gin.HandlerFunc
Limiter use getLimitfactor to get fctor and limit then to run
func LivenessProbe ¶
func LivenessProbe() gin.HandlerFunc
func MustGetSpan ¶
MustGetSpan extracts span from context. It panics if span was not set.
func NewSpan ¶
func NewSpan(operationName string, opts ...stdot.StartSpanOption) gin.HandlerFunc
NewSpan returns gin.HandlerFunc (middleware) that starts a new span and injects it to request context.
It calls ctx.Next() to measure execution time of all following handlers.
func ReadinessProbe ¶
func ReadinessProbe() gin.HandlerFunc
func SpanFromContext ¶
func SpanFromContext(operationName string, abortOnErrors bool, advancedOpts ...stdot.StartSpanOption) gin.HandlerFunc
SpanFromContext returns gin.HandlerFunc (middleware) that extracts parent span from request context and starts a new span as child of parent span.
It calls ctx.Next() to measure execution time of all following handlers.
Behaviour on errors determined by abortOnErrors option. If it set to true request handling will be aborted with error.
func SpanFromHeaders ¶
func SpanFromHeaders(operationName string, psr ParentSpanReferenceFunc, abortOnErrors bool, advancedOpts ...stdot.StartSpanOption) gin.HandlerFunc
SpanFromHeaders returns gin.HandlerFunc (middleware) that extracts parent span data from HTTP headers and starts a new span referenced to parent with ParentSpanReferenceFunc.
It calls ctx.Next() to measure execution time of all following handlers.
Behaviour on errors determined by abortOnErrors option. If it set to true request handling will be aborted with error.
func StartPrometheusProbes ¶
Types ¶
type Claims ¶
type Claims struct { Username string `json:"username"` Password string `json:"password"` jwt.StandardClaims }
func ParseToken ¶
type GetLimitfactor ¶
GetLimitfactor type define method to get factor used by limit
type ParentSpanReferenceFunc ¶
type ParentSpanReferenceFunc func(stdot.SpanContext) stdot.StartSpanOption
ParentSpanReferenceFunc determines how to reference parent span See opentracing.SpanReferenceType