dbs

package
v0.0.0-...-4f83324 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InvalidFrom  = NewQueryError(errors.New("invalid from"), http.StatusBadRequest, "")
	InvalidUntil = NewQueryError(errors.New("invalid until"), http.StatusBadRequest, "")
)

Functions

func HttpErrosPcnt

func HttpErrosPcnt(status map[string]float64) (total, errorsPcnt float64)

func SortByValues

func SortByValues() []string

func SortByValuesString

func SortByValuesString() string

func SortSamplesDurations

func SortSamplesDurations(durations []SampleDurations, sortBy SortBy)

func SortSamplesDurationsByDiff

func SortSamplesDurationsByDiff(durations []SampleDurationsDiff, sortBy SortBy)

func SortSamplesDurationsDiff

func SortSamplesDurationsDiff(durations []SampleDurationsDiff, sortBy SortBy)

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

func New

func New(db *sql.DB, tableTests, tableSamples string) *DB

func (*DB) Close

func (d *DB) Close() error

func (*DB) GetHttpSamplesDurations

func (d *DB) GetHttpSamplesDurations(f SampleFilter) ([]SampleQuantiles, *QueryError)

func (*DB) GetHttpSamplesStatus

func (d *DB) GetHttpSamplesStatus(f SampleFilter) ([]SampleStatus, *QueryError)

func (*DB) GetTestById

func (d *DB) GetTestById(f TestIdFilter) (Test, *QueryError)

func (*DB) GetTests

func (d *DB) GetTests(f TestFilter) ([]Test, *QueryError)

type ErrorInvalidSortBy

type ErrorInvalidSortBy struct {
	Value string
}

ErrorInvalidSortBy represents an sortBy wrapped error

func (ErrorInvalidSortBy) Error

func (e ErrorInvalidSortBy) Error() string

type QueryError

type QueryError struct {
	// contains filtered or unexported fields
}

func NewQueryError

func NewQueryError(wrapErr error, code int, query string) *QueryError

func (*QueryError) Code

func (e *QueryError) Code() int

func (*QueryError) Error

func (e *QueryError) Error() string

func (*QueryError) Query

func (e *QueryError) Query() string

func (*QueryError) Wrapped

func (e *QueryError) Wrapped() error

type Sample

type Sample struct {
	Id     uint64
	Start  time.Time // ts from tests
	Ts     time.Time
	Metric string
	Label  string
	Url    string
	Status string
	Name   string
	Tags   map[string]string
	Value  float64
}

type SampleDurations

type SampleDurations struct {
	Url string `json:"url"`

	// query durations
	P50 float64 `json:"p50"`
	P90 float64 `json:"p90"`
	P95 float64 `json:"p95"`
	P99 float64 `json:"p99"`
	Max float64 `json:"max"`

	// status count map
	Status     map[string]float64 `json:"status"`
	Count      float64            `json:"count"`
	ErrorsPcnt float64            `json:"errors"`
}

type SampleDurationsDiff

type SampleDurationsDiff struct {
	Url string `json:"url"`

	// query durations
	P50 float64 `json:"p50"`
	P90 float64 `json:"p90"`
	P95 float64 `json:"p95"`
	P99 float64 `json:"p99"`
	Max float64 `json:"max"`

	P50Diff float64 `json:"p50-diff"`
	P90Diff float64 `json:"p90-diff"`
	P95Diff float64 `json:"p95-diff"`
	P99Diff float64 `json:"p99-diff"`
	MaxDiff float64 `json:"max-diff"`

	// status count map
	Status     map[string]float64 `json:"status"`
	Count      float64            `json:"count"`
	ErrorsPcnt float64            `json:"errors"`

	StatusDiff     map[string]float64 `json:"status-diff"`
	CountDiff      float64            `json:"count-diff"`
	ErrorsPcntDiff float64            `json:"errors-diff"`
}

type SampleFilter

type SampleFilter struct {
	Id      uint64   `json:"id"`
	Start   int64    `json:"start"`
	Label   string   `json:"label,omitempty"`
	Url     string   `json:"url,omitempty"`
	SkipUrl []string `json:"no-url,omitempty"`
}

type SampleQuantiles

type SampleQuantiles struct {
	Id    uint64    `json:"id"`
	Start time.Time `json:"start"` // ts from tests
	Label string    `json:"label,omitempty"`
	Url   string    `json:"url"`

	// query durations
	P50 float64 `json:"p50"`
	P90 float64 `json:"p90"`
	P95 float64 `json:"p95"`
	P99 float64 `json:"p99"`
	Max float64 `json:"max"`
}

type SampleStatus

type SampleStatus struct {
	Id     uint64    `json:"id"`
	Start  time.Time `json:"start"` // ts from tests
	Label  string    `json:"label,omitempty"`
	Url    string    `json:"url"`
	Status string    `json:"status"`
	Count  float64   `json:"count"`
}

type SortBy

type SortBy uint8
const (
	SortByMax SortBy = iota
	SortByP99
	SortByP95
	SortByP90
	SortByP50
	SortByErrors
	SortByCount
)

func SortByFromString

func SortByFromString(value string) (SortBy, error)

func (*SortBy) String

func (u *SortBy) String() string

type SortByValue

type SortByValue SortBy

func NewSortByValue

func NewSortByValue(val SortBy, p *SortBy) *SortByValue

func NewSortByValueFromString

func NewSortByValueFromString(val string, p *SortBy) *SortByValue

func (*SortByValue) Get

func (u *SortByValue) Get() interface{}

func (*SortByValue) GetSortBy

func (u *SortByValue) GetSortBy() SortBy

func (*SortByValue) Reset

func (u *SortByValue) Reset(i interface{})

func (*SortByValue) Set

func (u *SortByValue) Set(val string, _ bool) error

func (*SortByValue) String

func (u *SortByValue) String() string

func (*SortByValue) Type

func (*SortByValue) Type() string

type Test

type Test struct {
	Id     uint64
	Ts     time.Time
	Name   string
	Params string
}

type TestFilter

type TestFilter struct {
	From  int64  `json:"from"`  // epoch seconds
	Until int64  `json:"until"` // epoch seconds
	Name  string `json:"name_prefix,omitempty"`
}

type TestIdFilter

type TestIdFilter struct {
	Id   uint64 `json:"id"`   // epoch seconds
	Time int64  `json:"time"` // epoch nanoseconds
}

type TestSamples

type TestSamples struct {
	Test    Test                         `json:"test"`
	Samples map[string][]SampleDurations `json:"samples"`
}

func MergeSamples

func MergeSamples(test Test, quantiles []SampleQuantiles, statuses []SampleStatus) *TestSamples

type TestSamplesDiff

type TestSamplesDiff struct {
	Test      Test                             `json:"test"`
	Reference Test                             `json:"ref"`
	Samples   map[string][]SampleDurationsDiff `json:"samples"`
}

func DiffSamples

func DiffSamples(test *TestSamples, ref *TestSamples) *TestSamplesDiff

Jump to

Keyboard shortcuts

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