statistics

package
v2.0.0-...-8b94259 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CurrentTPSTimeRange = 12 * time.Second
)

Variables

View Source
var File_statistics_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type AttackReport

type AttackReport struct {
	Name           string                   `json:"name"`                      // 事务名称
	Requests       uint64                   `json:"requests"`                  // 成功请求总数
	Failures       uint64                   `json:"failures"`                  // 失败请求总数
	Min            time.Duration            `json:"min"`                       // 最小延迟
	Max            time.Duration            `json:"max"`                       // 最大延迟
	Median         time.Duration            `json:"median"`                    // 中位数
	Average        time.Duration            `json:"average"`                   // 平均数
	TPS            float64                  `json:"tps"`                       // 每秒事务数
	Distributions  map[string]time.Duration `json:"distributions,omitempty"`   // 百分位分布
	FailureRatio   float64                  `json:"failure_ratio"`             // 错误率
	FailureDetails map[string]uint64        `json:"failure_details,omitempty"` // 错误详情分布
	FullHistory    bool                     `json:"full_history"`              // 是否是该阶段完整的报告
	FirstAttack    time.Time                `json:"first_attack"`              // 第一请求发生时间
	LastAttack     time.Time                `json:"last_attack"`               // 最后一次请求结束时间
}

AttackReport 聚合报告

type AttackResult

type AttackResult struct {
	Name     string
	Duration time.Duration
	Error    error
}

AttackResult 事务执行结果

func (*AttackResult) IsFailure

func (ar *AttackResult) IsFailure() bool

IsFailure 事务是否执行失败

type AttackStatistician

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

func NewAttackStatistician

func NewAttackStatistician(name string) *AttackStatistician

func NewAttackStatisticianFromDTO

func NewAttackStatisticianFromDTO(dto *AttackStatisticsDTO) (*AttackStatistician, error)

func (*AttackStatistician) BatchMerge

func (ara *AttackStatistician) BatchMerge(others ...*AttackStatistician) error

BatchMerge 合并多个AttackStatistician对象

func (*AttackStatistician) Record

func (ara *AttackStatistician) Record(ret AttackResult)

func (*AttackStatistician) Report

func (ara *AttackStatistician) Report(full bool) AttackReport

type AttackStatisticsDTO

type AttackStatisticsDTO struct {
	Name                string                 `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Requests            uint64                 `protobuf:"varint,2,opt,name=requests,proto3" json:"requests,omitempty"`
	Failures            uint64                 `protobuf:"varint,3,opt,name=failures,proto3" json:"failures,omitempty"`
	TotalResponseTime   *durationpb.Duration   `protobuf:"bytes,4,opt,name=total_response_time,json=totalResponseTime,proto3" json:"total_response_time,omitempty"`
	MinResponseTime     *durationpb.Duration   `protobuf:"bytes,5,opt,name=min_response_time,json=minResponseTime,proto3" json:"min_response_time,omitempty"`
	MaxResponseTime     *durationpb.Duration   `protobuf:"bytes,6,opt,name=max_response_time,json=maxResponseTime,proto3" json:"max_response_time,omitempty"`
	RecentSuccessBucket map[int64]int64        `` /* 210-byte string literal not displayed */
	RecentFailureBucket map[int64]int64        `` /* 210-byte string literal not displayed */
	ResponseBucket      map[int64]uint64       `` /* 193-byte string literal not displayed */
	FailureBucket       map[string]uint64      `` /* 190-byte string literal not displayed */
	FirstAttack         *timestamppb.Timestamp `protobuf:"bytes,11,opt,name=first_attack,json=firstAttack,proto3" json:"first_attack,omitempty"`
	LastAttack          *timestamppb.Timestamp `protobuf:"bytes,12,opt,name=last_attack,json=lastAttack,proto3" json:"last_attack,omitempty"`
	Interval            *durationpb.Duration   `protobuf:"bytes,13,opt,name=interval,proto3" json:"interval,omitempty"`
	// contains filtered or unexported fields
}

func ConvertAttackStatistician

func ConvertAttackStatistician(as *AttackStatistician) (*AttackStatisticsDTO, error)

func (*AttackStatisticsDTO) Descriptor deprecated

func (*AttackStatisticsDTO) Descriptor() ([]byte, []int)

Deprecated: Use AttackStatisticsDTO.ProtoReflect.Descriptor instead.

func (*AttackStatisticsDTO) GetFailureBucket

func (x *AttackStatisticsDTO) GetFailureBucket() map[string]uint64

func (*AttackStatisticsDTO) GetFailures

func (x *AttackStatisticsDTO) GetFailures() uint64

func (*AttackStatisticsDTO) GetFirstAttack

func (x *AttackStatisticsDTO) GetFirstAttack() *timestamppb.Timestamp

func (*AttackStatisticsDTO) GetInterval

func (x *AttackStatisticsDTO) GetInterval() *durationpb.Duration

func (*AttackStatisticsDTO) GetLastAttack

func (x *AttackStatisticsDTO) GetLastAttack() *timestamppb.Timestamp

func (*AttackStatisticsDTO) GetMaxResponseTime

func (x *AttackStatisticsDTO) GetMaxResponseTime() *durationpb.Duration

func (*AttackStatisticsDTO) GetMinResponseTime

func (x *AttackStatisticsDTO) GetMinResponseTime() *durationpb.Duration

func (*AttackStatisticsDTO) GetName

func (x *AttackStatisticsDTO) GetName() string

func (*AttackStatisticsDTO) GetRecentFailureBucket

func (x *AttackStatisticsDTO) GetRecentFailureBucket() map[int64]int64

func (*AttackStatisticsDTO) GetRecentSuccessBucket

func (x *AttackStatisticsDTO) GetRecentSuccessBucket() map[int64]int64

func (*AttackStatisticsDTO) GetRequests

func (x *AttackStatisticsDTO) GetRequests() uint64

func (*AttackStatisticsDTO) GetResponseBucket

func (x *AttackStatisticsDTO) GetResponseBucket() map[int64]uint64

func (*AttackStatisticsDTO) GetTotalResponseTime

func (x *AttackStatisticsDTO) GetTotalResponseTime() *durationpb.Duration

func (*AttackStatisticsDTO) ProtoMessage

func (*AttackStatisticsDTO) ProtoMessage()

func (*AttackStatisticsDTO) ProtoReflect

func (x *AttackStatisticsDTO) ProtoReflect() protoreflect.Message

func (*AttackStatisticsDTO) Reset

func (x *AttackStatisticsDTO) Reset()

func (*AttackStatisticsDTO) String

func (x *AttackStatisticsDTO) String() string

type StatisticianGroup

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

func NewStatisticianGroup

func NewStatisticianGroup() *StatisticianGroup

func NewStatisticianGroupFromDTO

func NewStatisticianGroupFromDTO(dto *StatisticianGroupDTO) (*StatisticianGroup, error)

func (*StatisticianGroup) Attach

func (s *StatisticianGroup) Attach(tag Tag)

Attach 附加tag

func (*StatisticianGroup) Merge

func (s *StatisticianGroup) Merge(other *StatisticianGroup)

func (*StatisticianGroup) Record

func (s *StatisticianGroup) Record(result AttackResult)

Record 记录一次请求结果

func (*StatisticianGroup) ReplaceStatistician

func (s *StatisticianGroup) ReplaceStatistician(agg *AttackStatistician) error

ReplaceStatistician 替换某个事务的Statistician

func (*StatisticianGroup) Report

func (s *StatisticianGroup) Report(full bool) SummaryReport

Report 输出统计报表

func (*StatisticianGroup) Reset

func (s *StatisticianGroup) Reset()

Reset 重置统计组状态

func (*StatisticianGroup) SetTag

func (s *StatisticianGroup) SetTag(key, value string)

func (*StatisticianGroup) Tags

func (s *StatisticianGroup) Tags() Tags

Tags 返回当前统计组的所有tag

type StatisticianGroupDTO

type StatisticianGroupDTO struct {
	Container map[string]*AttackStatisticsDTO `` /* 159-byte string literal not displayed */
	Tags      []*TagDTO                       `protobuf:"bytes,2,rep,name=tags,proto3" json:"tags,omitempty"`
	// contains filtered or unexported fields
}

func ConvertStatisticianGroup

func ConvertStatisticianGroup(entity *StatisticianGroup) (*StatisticianGroupDTO, error)

func (*StatisticianGroupDTO) Descriptor deprecated

func (*StatisticianGroupDTO) Descriptor() ([]byte, []int)

Deprecated: Use StatisticianGroupDTO.ProtoReflect.Descriptor instead.

func (*StatisticianGroupDTO) GetContainer

func (x *StatisticianGroupDTO) GetContainer() map[string]*AttackStatisticsDTO

func (*StatisticianGroupDTO) GetTags

func (x *StatisticianGroupDTO) GetTags() []*TagDTO

func (*StatisticianGroupDTO) ProtoMessage

func (*StatisticianGroupDTO) ProtoMessage()

func (*StatisticianGroupDTO) ProtoReflect

func (x *StatisticianGroupDTO) ProtoReflect() protoreflect.Message

func (*StatisticianGroupDTO) Reset

func (x *StatisticianGroupDTO) Reset()

func (*StatisticianGroupDTO) String

func (x *StatisticianGroupDTO) String() string

type SummaryReport

type SummaryReport struct {
	FirstAttack   time.Time               `json:"first_attack"`
	LastAttack    time.Time               `json:"last_attack"`
	TotalRequests uint64                  `json:"total_requests"`
	TotalFailures uint64                  `json:"total_failures"`
	TotalTPS      float64                 `json:"total_tps"`
	FullHistory   bool                    `json:"full_history"`
	Reports       map[string]AttackReport `json:"reports,omitempty"`
	Extras        map[string]string       `json:"extras,omitempty"`
}

type Tag

type Tag struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type TagDTO

type TagDTO struct {
	Key   string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

func (*TagDTO) Descriptor deprecated

func (*TagDTO) Descriptor() ([]byte, []int)

Deprecated: Use TagDTO.ProtoReflect.Descriptor instead.

func (*TagDTO) GetKey

func (x *TagDTO) GetKey() string

func (*TagDTO) GetValue

func (x *TagDTO) GetValue() string

func (*TagDTO) ProtoMessage

func (*TagDTO) ProtoMessage()

func (*TagDTO) ProtoReflect

func (x *TagDTO) ProtoReflect() protoreflect.Message

func (*TagDTO) Reset

func (x *TagDTO) Reset()

func (*TagDTO) String

func (x *TagDTO) String() string

type Tags

type Tags map[string]Tag

Jump to

Keyboard shortcuts

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