MetricManage

package
v0.0.0-...-d15be54 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

README

服务模块

根据所有服务名获取指标

指定服务名查询指标

指标上报

Documentation

Index

Constants

View Source
const (
	AppName = "MetricManager"
)
View Source
const (
	MetricsService_ReportMetrics_FullMethodName = "/MetricsService/ReportMetrics"
)

Variables

View Source
var File_Metric_proto protoreflect.FileDescriptor
View Source
var MetricsService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "MetricsService",
	HandlerType: (*MetricsServiceServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "ReportMetrics",
			Handler:       _MetricsService_ReportMetrics_Handler,
			ClientStreams: true,
		},
	},
	Metadata: "Metric.proto",
}

MetricsService_ServiceDesc is the grpc.ServiceDesc for MetricsService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterMetricsServiceServer

func RegisterMetricsServiceServer(s grpc.ServiceRegistrar, srv MetricsServiceServer)

Types

type MetricService

type MetricService interface {
	//TODO 获取指定服务2小时的指标
	FetchMetricsForServiceLastTwoHour(ctx context.Context, service *ServiceManage.Service) (*ServiceInstanceMetrics, error)
	//TODO 取指定服务的6小时内的指标
	FetchMetricsForServiceLastSixHour(ctx context.Context, service *ServiceManage.Service) (*ServiceInstanceMetrics, error)
	//TODO  获取指定服务12小时内的指标
	FetchMetricsForServiceRecent(ctx context.Context, service *ServiceManage.Service) (*ServiceInstanceMetrics, error)
	//TODO 获取指定服务24小时内的指标
	FetchServiceMetricsForLastDay(ctx context.Context, service *ServiceManage.Service) (*ServiceInstanceMetrics, error)
	//GRPC server,上报各种指标
	MetricsServiceServer
}

type MetricsData

type MetricsData struct {
	CpuUsage    []float64 `protobuf:"fixed64,1,rep,packed,name=cpuUsage,proto3" json:"cpuUsage,omitempty"` // CPU使用率,百分比
	MemoryUsage float64   `protobuf:"fixed64,2,opt,name=memoryUsage,proto3" json:"memoryUsage,omitempty"`  // 内存使用率,百分比
	IcmpDelay   int64     `protobuf:"varint,3,opt,name=icmpDelay,proto3" json:"icmpDelay,omitempty"`       // ICMP延迟,毫秒
	TimeStamp   int64     `protobuf:"varint,4,opt,name=timeStamp,proto3" json:"timeStamp,omitempty"`       //时间戳
	ServiceName string    `protobuf:"bytes,5,opt,name=ServiceName,proto3" json:"ServiceName,omitempty"`    //服务前缀
	ServiceHost string    `protobuf:"bytes,6,opt,name=ServiceHost,proto3" json:"ServiceHost,omitempty"`    //服务地址和端口
	IsPriority  string    `protobuf:"bytes,7,opt,name=IsPriority,proto3" json:"IsPriority,omitempty"`      //是否优先
	ProjectName string    `protobuf:"bytes,8,opt,name=ProjectName,proto3" json:"ProjectName,omitempty"`    //项目名
	LeaseId     int64     `protobuf:"varint,9,opt,name=LeaseId,proto3" json:"LeaseId,omitempty"`           // etcd租约id
	// contains filtered or unexported fields
}

定义传输的性能数据结构

func (*MetricsData) Descriptor deprecated

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

Deprecated: Use MetricsData.ProtoReflect.Descriptor instead.

func (*MetricsData) GetCpuUsage

func (x *MetricsData) GetCpuUsage() []float64

func (*MetricsData) GetIcmpDelay

func (x *MetricsData) GetIcmpDelay() int64

func (*MetricsData) GetIsPriority

func (x *MetricsData) GetIsPriority() string

func (*MetricsData) GetLeaseId

func (x *MetricsData) GetLeaseId() int64

func (*MetricsData) GetMemoryUsage

func (x *MetricsData) GetMemoryUsage() float64

func (*MetricsData) GetProjectName

func (x *MetricsData) GetProjectName() string

func (*MetricsData) GetServiceHost

func (x *MetricsData) GetServiceHost() string

func (*MetricsData) GetServiceName

func (x *MetricsData) GetServiceName() string

func (*MetricsData) GetTimeStamp

func (x *MetricsData) GetTimeStamp() int64

func (*MetricsData) ProtoMessage

func (*MetricsData) ProtoMessage()

func (*MetricsData) ProtoReflect

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

func (*MetricsData) Reset

func (x *MetricsData) Reset()

func (*MetricsData) String

func (x *MetricsData) String() string

type MetricsServiceClient

type MetricsServiceClient interface {
	// 客户端流模式的RPC方法
	ReportMetrics(ctx context.Context, opts ...grpc.CallOption) (MetricsService_ReportMetricsClient, error)
}

MetricsServiceClient is the client API for MetricsService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

type MetricsServiceServer

type MetricsServiceServer interface {
	// 客户端流模式的RPC方法
	ReportMetrics(MetricsService_ReportMetricsServer) error
	// contains filtered or unexported methods
}

MetricsServiceServer is the server API for MetricsService service. All implementations must embed UnimplementedMetricsServiceServer for forward compatibility

type MetricsService_ReportMetricsClient

type MetricsService_ReportMetricsClient interface {
	Send(*MetricsData) error
	CloseAndRecv() (*ReportResponse, error)
	grpc.ClientStream
}

type MetricsService_ReportMetricsServer

type MetricsService_ReportMetricsServer interface {
	SendAndClose(*ReportResponse) error
	Recv() (*MetricsData, error)
	grpc.ServerStream
}

type ReportResponse

type ReportResponse struct {
	Success bool   `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` // 上报是否成功
	Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`  // 服务端返回的消息,例如错误信息
	// contains filtered or unexported fields
}

定义响应结构

func (*ReportResponse) Descriptor deprecated

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

Deprecated: Use ReportResponse.ProtoReflect.Descriptor instead.

func (*ReportResponse) GetMessage

func (x *ReportResponse) GetMessage() string

func (*ReportResponse) GetSuccess

func (x *ReportResponse) GetSuccess() bool

func (*ReportResponse) ProtoMessage

func (*ReportResponse) ProtoMessage()

func (*ReportResponse) ProtoReflect

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

func (*ReportResponse) Reset

func (x *ReportResponse) Reset()

func (*ReportResponse) String

func (x *ReportResponse) String() string

type ServiceInstance

type ServiceInstance struct {
	ServiceHost string       `json:"service_host"`
	MetricsData *MetricsData `json:"metrics_data"`
}

func (*ServiceInstance) String

func (s *ServiceInstance) String() string

type ServiceInstanceMetrics

type ServiceInstanceMetrics struct {
	ServiceHost string         `json:"service_host"`
	MetricsData []*MetricsData `json:"metrics_data"`
}

func (*ServiceInstanceMetrics) String

func (s *ServiceInstanceMetrics) String() string

type UnimplementedMetricsServiceServer

type UnimplementedMetricsServiceServer struct {
}

UnimplementedMetricsServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedMetricsServiceServer) ReportMetrics

type UnsafeMetricsServiceServer

type UnsafeMetricsServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeMetricsServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to MetricsServiceServer will result in compilation errors.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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