api

package
v0.40.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: Apache-2.0 Imports: 20 Imported by: 6

Documentation

Index

Constants

View Source
const (
	StatusSuccess status = "success"
	StatusError   status = "error"
)

Variables

View Source
var BuildInfo = &ThanosVersion{
	Version:   version.Version,
	Revision:  version.Revision,
	Branch:    version.Branch,
	BuildUser: version.BuildUser,
	BuildDate: version.BuildDate,
	GoVersion: version.GoVersion,
}

Functions

func Respond

func Respond(w http.ResponseWriter, data any, warnings []error, logger log.Logger)

func RespondError

func RespondError(w http.ResponseWriter, apiErr *ApiError, data any, logger log.Logger)

func SetCORS

func SetCORS(w http.ResponseWriter)

SetCORS enables cross-site script calls.

Types

type ApiError

type ApiError struct {
	Typ ErrorType
	Err error
}

func (*ApiError) Error

func (e *ApiError) Error() string

type ApiFunc

type ApiFunc func(r *http.Request) (any, []error, *ApiError, func())

type BaseAPI

type BaseAPI struct {
	Now func() time.Time
	// contains filtered or unexported fields
}

func NewBaseAPI

func NewBaseAPI(logger log.Logger, disableCORS bool, flagsMap map[string]string) *BaseAPI

NewBaseAPI returns a new initialized BaseAPI type.

func (*BaseAPI) Register

func (api *BaseAPI) Register(r *route.Router, tracer opentracing.Tracer, logger log.Logger, ins extpromhttp.InstrumentationMiddleware, logMiddleware *logging.HTTPServerMiddleware)

Register registers the common API endpoints.

type ErrorType

type ErrorType string
const (
	ErrorNone     ErrorType = ""
	ErrorTimeout  ErrorType = "timeout"
	ErrorCanceled ErrorType = "canceled"
	ErrorExec     ErrorType = "execution"
	ErrorBadData  ErrorType = "bad_data"
	ErrorInternal ErrorType = "internal"
)

type InstrFunc

type InstrFunc func(name string, f ApiFunc) http.HandlerFunc

func GetInstr

func GetInstr(
	tracer opentracing.Tracer,
	logger log.Logger,
	ins extpromhttp.InstrumentationMiddleware,
	logMiddleware *logging.HTTPServerMiddleware,
	disableCORS bool,
) InstrFunc

GetInstr returns a http HandlerFunc with the instrumentation middleware.

type RuntimeInfo

type RuntimeInfo struct {
	StartTime      time.Time `json:"startTime"`
	CWD            string    `json:"CWD"`
	GoroutineCount int       `json:"goroutineCount"`
	GOMAXPROCS     int       `json:"GOMAXPROCS"`
	GOGC           string    `json:"GOGC"`
	GODEBUG        string    `json:"GODEBUG"`
	GOMEMLIMIT     int64     `json:"GOMEMLIMIT"`
}

RuntimeInfo contains runtime information about Thanos.

type RuntimeInfoFn

type RuntimeInfoFn func() RuntimeInfo

RuntimeInfoFn returns updated runtime information about Thanos.

func GetRuntimeInfoFunc

func GetRuntimeInfoFunc(logger log.Logger) RuntimeInfoFn

type TSDBStatus added in v0.40.0

type TSDBStatus struct {
	Tenant        string `json:"tenant"`
	v1.TSDBStatus `json:","`
}

TSDBStatus has information of cardinality statistics from postings.

type TenantStats added in v0.40.0

type TenantStats struct {
	Tenant string
	Stats  *tsdb.Stats
}

type ThanosVersion

type ThanosVersion struct {
	Version   string `json:"version"`
	Revision  string `json:"revision"`
	Branch    string `json:"branch"`
	BuildUser string `json:"buildUser"`
	BuildDate string `json:"buildDate"`
	GoVersion string `json:"goVersion"`
}

ThanosVersion contains build information about Thanos.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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