Documentation ¶
Overview ¶
Package status contains code for implementing status related commands like "weaver multi status" and "weaver single dashboard".
Index ¶
- Variables
- func DashboardCommand(spec *DashboardSpec) *dtool.Command
- func MetricsCommand(tool string, registry func(context.Context) (*Registry, error)) *dtool.Command
- func ProfileCommand(toolName string, registry func(context.Context) (*Registry, error)) *tool.Command
- func RegisterServer(mux *http.ServeMux, server Server, logger *slog.Logger)
- func StatusCommand(tool string, registry func(context.Context) (*Registry, error)) *dtool.Command
- type Client
- type Command
- type Component
- func (*Component) Descriptor() ([]byte, []int)deprecated
- func (x *Component) GetMethods() []*Method
- func (x *Component) GetName() string
- func (x *Component) GetPids() []int64
- func (*Component) ProtoMessage()
- func (x *Component) ProtoReflect() protoreflect.Message
- func (x *Component) Reset()
- func (x *Component) String() string
- type DashboardSpec
- type Listener
- type Method
- func (*Method) Descriptor() ([]byte, []int)deprecated
- func (x *Method) GetHour() *MethodStats
- func (x *Method) GetMinute() *MethodStats
- func (x *Method) GetName() string
- func (x *Method) GetTotal() *MethodStats
- func (*Method) ProtoMessage()
- func (x *Method) ProtoReflect() protoreflect.Message
- func (x *Method) Reset()
- func (x *Method) String() string
- type MethodStats
- func (*MethodStats) Descriptor() ([]byte, []int)deprecated
- func (x *MethodStats) GetAvgLatencyMs() float64
- func (x *MethodStats) GetNumCalls() float64
- func (x *MethodStats) GetRecvKbPerSec() float64
- func (x *MethodStats) GetSentKbPerSec() float64
- func (*MethodStats) ProtoMessage()
- func (x *MethodStats) ProtoReflect() protoreflect.Message
- func (x *MethodStats) Reset()
- func (x *MethodStats) String() string
- type Metrics
- type Registration
- type Registry
- func (r *Registry) Get(ctx context.Context, deploymentId string) (Registration, error)
- func (r *Registry) List(ctx context.Context) ([]Registration, error)
- func (r *Registry) Register(ctx context.Context, reg Registration) error
- func (r *Registry) Unregister(_ context.Context, deploymentId string) error
- type Server
- type Status
- func (*Status) Descriptor() ([]byte, []int)deprecated
- func (x *Status) GetApp() string
- func (x *Status) GetComponents() []*Component
- func (x *Status) GetConfig() *protos.AppConfig
- func (x *Status) GetDeploymentId() string
- func (x *Status) GetListeners() []*Listener
- func (x *Status) GetStatusAddr() string
- func (x *Status) GetSubmissionTime() *timestamppb.Timestamp
- func (*Status) ProtoMessage()
- func (x *Status) ProtoReflect() protoreflect.Message
- func (x *Status) Reset()
- func (x *Status) String() string
Constants ¶
This section is empty.
Variables ¶
var File_internal_status_status_proto protoreflect.FileDescriptor
Functions ¶
func DashboardCommand ¶
func DashboardCommand(spec *DashboardSpec) *dtool.Command
DashboardCommand returns a "dashboard" subcommand that serves a dashboard with information about the active applications.
func MetricsCommand ¶
MetricsCommand returns a "metrics" subcommand that pretty prints the metrics of all active applications registered with the provided registry. tool is the name of the command-line tool the returned subcommand runs as (e.g., "weaver single").
func ProfileCommand ¶
func ProfileCommand(toolName string, registry func(context.Context) (*Registry, error)) *tool.Command
ProfileCommand returns a "profile" subcommand that gathers pprof profiles.
func RegisterServer ¶
RegisterServer registers a Server's methods with the provided mux under the /debug/serviceweaver/ prefix. You can use a Client to interact with a Status server.
func StatusCommand ¶
StatusCommand returns a "status" subcommand that pretty prints the status of all active applications registered with the provided registry. tool is the name of the command-line tool the returned subcommand runs as (e.g., "weaver single").
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an HTTP client to a status server. It's assumed the status server registered itself with RegisterServer.
func (*Client) Profile ¶
func (c *Client) Profile(ctx context.Context, req *protos.GetProfileRequest) (*protos.GetProfileReply, error)
Profile implements the Server interface.
type Command ¶
type Command struct { Label string // e.g., cat logs Command string // e.g., weaver single logs '--version=="12345678"' }
A Command is a labeled terminal command that a user can run. We show these commands on the dashboard so that users can copy and run them.
type Component ¶
type Component struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // component name (e.g., Cache) Pids []int64 `protobuf:"varint,3,rep,packed,name=pids,proto3" json:"pids,omitempty"` // PIDs of component replicas Methods []*Method `protobuf:"bytes,4,rep,name=methods,proto3" json:"methods,omitempty"` // methods // contains filtered or unexported fields }
Component describes a Service Weaver component.
func (*Component) Descriptor
deprecated
func (*Component) GetMethods ¶
func (*Component) ProtoMessage ¶
func (*Component) ProtoMessage()
func (*Component) ProtoReflect ¶
func (x *Component) ProtoReflect() protoreflect.Message
type DashboardSpec ¶
type DashboardSpec struct { Tool string // tool name (e.g., "weaver single") PerfettoFile string // perfetto database file Registry func(context.Context) (*Registry, error) // registry of deployments Commands func(deploymentId string) []Command // commands for a deployment }
DashboardSpec configures the command returned by DashboardCommand.
type Listener ¶
type Listener struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // exported listener name Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"` // dialable listener address // contains filtered or unexported fields }
Listener describes a Service Weaver listener.
func (*Listener) Descriptor
deprecated
func (*Listener) ProtoMessage ¶
func (*Listener) ProtoMessage()
func (*Listener) ProtoReflect ¶
func (x *Listener) ProtoReflect() protoreflect.Message
type Method ¶
type Method struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // method name Minute *MethodStats `protobuf:"bytes,2,opt,name=minute,proto3" json:"minute,omitempty"` // stats from the last minute Hour *MethodStats `protobuf:"bytes,3,opt,name=hour,proto3" json:"hour,omitempty"` // stats from the last hour Total *MethodStats `protobuf:"bytes,4,opt,name=total,proto3" json:"total,omitempty"` // lifetime stats // contains filtered or unexported fields }
Method describes a Component method.
func (*Method) Descriptor
deprecated
func (*Method) GetHour ¶
func (x *Method) GetHour() *MethodStats
func (*Method) GetMinute ¶
func (x *Method) GetMinute() *MethodStats
func (*Method) GetTotal ¶
func (x *Method) GetTotal() *MethodStats
func (*Method) ProtoMessage ¶
func (*Method) ProtoMessage()
func (*Method) ProtoReflect ¶
func (x *Method) ProtoReflect() protoreflect.Message
type MethodStats ¶
type MethodStats struct { NumCalls float64 `protobuf:"fixed64,1,opt,name=num_calls,json=numCalls,proto3" json:"num_calls,omitempty"` // number of times the method was called AvgLatencyMs float64 `protobuf:"fixed64,2,opt,name=avg_latency_ms,json=avgLatencyMs,proto3" json:"avg_latency_ms,omitempty"` // average latency, in ms, of method execution RecvKbPerSec float64 `protobuf:"fixed64,3,opt,name=recv_kb_per_sec,json=recvKbPerSec,proto3" json:"recv_kb_per_sec,omitempty"` // KB/s received by method SentKbPerSec float64 `protobuf:"fixed64,4,opt,name=sent_kb_per_sec,json=sentKbPerSec,proto3" json:"sent_kb_per_sec,omitempty"` // KB/s returned by method // contains filtered or unexported fields }
MethodStats summarizes a method's metrics.
func (*MethodStats) Descriptor
deprecated
func (*MethodStats) Descriptor() ([]byte, []int)
Deprecated: Use MethodStats.ProtoReflect.Descriptor instead.
func (*MethodStats) GetAvgLatencyMs ¶
func (x *MethodStats) GetAvgLatencyMs() float64
func (*MethodStats) GetNumCalls ¶
func (x *MethodStats) GetNumCalls() float64
func (*MethodStats) GetRecvKbPerSec ¶
func (x *MethodStats) GetRecvKbPerSec() float64
func (*MethodStats) GetSentKbPerSec ¶
func (x *MethodStats) GetSentKbPerSec() float64
func (*MethodStats) ProtoMessage ¶
func (*MethodStats) ProtoMessage()
func (*MethodStats) ProtoReflect ¶
func (x *MethodStats) ProtoReflect() protoreflect.Message
func (*MethodStats) Reset ¶
func (x *MethodStats) Reset()
func (*MethodStats) String ¶
func (x *MethodStats) String() string
type Metrics ¶
type Metrics struct { Metrics []*protos.MetricSnapshot `protobuf:"bytes,1,rep,name=metrics,proto3" json:"metrics,omitempty"` // contains filtered or unexported fields }
Metrics is a snapshot of a deployment's metrics.
func (*Metrics) Descriptor
deprecated
func (*Metrics) GetMetrics ¶
func (x *Metrics) GetMetrics() []*protos.MetricSnapshot
func (*Metrics) ProtoMessage ¶
func (*Metrics) ProtoMessage()
func (*Metrics) ProtoReflect ¶
func (x *Metrics) ProtoReflect() protoreflect.Message
type Registration ¶
type Registration struct { DeploymentId string // deployment id (e.g, "eba18295") App string // app name (e.g., "todo") Addr string // status server (e.g., "localhost:12345") }
A Registration contains basic metadata about a Service Weaver application.
func (Registration) Rolodex ¶
func (r Registration) Rolodex() string
Rolodex returns a pretty-printed rolodex displaying the registration.
╭───────────────────────────────────────────────────╮ │ app : collatz │ │ deployment : fdeeb059-825b-4606-9e99-e22e63e10552 │ ╰───────────────────────────────────────────────────╯
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
A Registry is a persistent collection of Service Weaver application metadata.
Tools like "weaver multi status" and "weaver multi dashboard" use the registry to know which applications are running and to fetch the status of the running applications.
func NewRegistry ¶
NewRegistry returns a registry that persists data to the provided directory.
func (*Registry) Get ¶
Get returns the Registration for the provided deployment. If the deployment doesn't exist or is not active, a non-nil error is returned.
func (*Registry) List ¶
func (r *Registry) List(ctx context.Context) ([]Registration, error)
List returns all active Registrations.
type Server ¶
type Server interface { // Status returns the status of the deployment. Status(context.Context) (*Status, error) // Metrics returns a snapshot of the deployment's metrics. Metrics(context.Context) (*Metrics, error) // Profile returns a profile of the deployment. Profile(context.Context, *protos.GetProfileRequest) (*protos.GetProfileReply, error) }
A Server returns information about a Service Weaver deployment.
type Status ¶
type Status struct { App string `protobuf:"bytes,1,opt,name=app,proto3" json:"app,omitempty"` // application name DeploymentId string `protobuf:"bytes,2,opt,name=deployment_id,json=deploymentId,proto3" json:"deployment_id,omitempty"` // deployment id SubmissionTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=submission_time,json=submissionTime,proto3" json:"submission_time,omitempty"` // when the app was submitted StatusAddr string `protobuf:"bytes,4,opt,name=status_addr,json=statusAddr,proto3" json:"status_addr,omitempty"` // status server address Components []*Component `protobuf:"bytes,5,rep,name=components,proto3" json:"components,omitempty"` // active components Listeners []*Listener `protobuf:"bytes,6,rep,name=listeners,proto3" json:"listeners,omitempty"` // exported listeners Config *protos.AppConfig `protobuf:"bytes,7,opt,name=config,proto3" json:"config,omitempty"` // application config // contains filtered or unexported fields }
Status describes the status of a Service Weaver application deployment.
func (*Status) Descriptor
deprecated
func (*Status) GetComponents ¶
func (*Status) GetDeploymentId ¶
func (*Status) GetListeners ¶
func (*Status) GetStatusAddr ¶
func (*Status) GetSubmissionTime ¶
func (x *Status) GetSubmissionTime() *timestamppb.Timestamp
func (*Status) ProtoMessage ¶
func (*Status) ProtoMessage()
func (*Status) ProtoReflect ¶
func (x *Status) ProtoReflect() protoreflect.Message