This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

counters: Implement the new counters package

A simple event counter can be an incredibly helpful debugging tool.
They're cheap enough to always be running, even in production.
They're unobtrusive to the average user.  Yet, they can convey a bunch
of information about the behavior of the system that would otherwise
be completely opaque.

This patch implements a new package, counters for Quilt.  It also
implements a new command, `quilt counters` which can query counters
from the daemon (querying from the minions is not yet implemented).
  • Loading branch information...
ejj committed Jun 25, 2017
1 parent 4be594e commit 86d5d6c17e8041e3f0208d31e3288b6942c302d3
View
@@ -14,6 +14,7 @@ boot times.
`myService.allowFrom(publicInternet, aPort)` now works.
- Only allocate one Google network per namespace, rather than one network for
each region within a namespace.
- Implement debugging counters accessible through `quilt counters`.
Release 0.1.0
-------------
View
@@ -48,6 +48,9 @@ type Client interface {
// QueryClusters retrieves cluster information tracked by the Quilt daemon.
QueryClusters() ([]db.Cluster, error)
// QueryCounters retrieves the debugging counters tracked with the Quilt daemon.
QueryCounters() ([]pb.Counter, error)
// Deploy makes a request to the Quilt daemon to deploy the given deployment.
Deploy(deployment string) error
@@ -207,6 +210,22 @@ func (c clientImpl) QueryClusters() ([]db.Cluster, error) {
return rows.([]db.Cluster), nil
}
// QueryCounters retrieves the debugging counters tracked with the Quilt daemon.
func (c clientImpl) QueryCounters() ([]pb.Counter, error) {
ctx, _ := context.WithTimeout(context.Background(), requestTimeout)
reply, err := c.pbClient.QueryCounters(ctx, &pb.CountersRequest{})
if err != nil {
return nil, err
}
var counters []pb.Counter
for _, c := range reply.Counters {
counters = append(counters, *c)
}
return counters, nil
}
// Deploy makes a request to the Quilt daemon to deploy the given deployment.
func (c clientImpl) Deploy(deployment string) error {
ctx, _ := context.WithTimeout(context.Background(), requestTimeout)
@@ -29,6 +29,12 @@ func (c mockAPIClient) Deploy(ctx context.Context, in *pb.DeployRequest,
return &pb.DeployReply{}, nil
}
func (c mockAPIClient) QueryCounters(ctx context.Context, in *pb.CountersRequest,
opts ...grpc.CallOption) (*pb.CountersReply, error) {
return &pb.CountersReply{}, nil
}
func (c mockAPIClient) Version(ctx context.Context, in *pb.VersionRequest,
opts ...grpc.CallOption) (*pb.VersionReply, error) {
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -4,6 +4,7 @@ service API {
rpc Query(DBQuery) returns(QueryReply) {}
rpc Deploy(DeployRequest) returns(DeployReply) {}
rpc Version(VersionRequest) returns(VersionReply) {}
rpc QueryCounters(CountersRequest) returns(CountersReply){}
}
message DBQuery {
@@ -18,11 +19,23 @@ message DeployRequest {
string Deployment = 1;
}
message DeployReply {
}
message DeployReply {}
message VersionRequest {}
message VersionReply {
string Version = 1;
}
message CountersRequest {}
message CountersReply {
repeated Counter counters = 1;
}
message Counter {
string Pkg = 1;
string Name = 2;
uint64 Value = 3;
uint64 PrevValue = 4;
}
View
@@ -14,6 +14,7 @@ import (
"github.com/quilt/quilt/api"
"github.com/quilt/quilt/api/client"
"github.com/quilt/quilt/api/pb"
"github.com/quilt/quilt/counter"
"github.com/quilt/quilt/db"
"github.com/quilt/quilt/stitch"
"github.com/quilt/quilt/version"
@@ -150,6 +151,11 @@ func queryFromDaemon(table db.TableType, conn db.Conn) (
}
}
func (s server) QueryCounters(ctx context.Context, in *pb.CountersRequest) (
*pb.CountersReply, error) {
return &pb.CountersReply{Counters: counter.Dump()}, nil
}
func (s server) Deploy(cts context.Context, deployReq *pb.DeployRequest) (
*pb.DeployReply, error) {
Oops, something went wrong.

0 comments on commit 86d5d6c

Please sign in to comment.