Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented the sender worker for metrics #676

Merged
merged 6 commits into from Sep 17, 2014

Conversation

mattyw
Copy link
Contributor

@mattyw mattyw commented Sep 4, 2014

Implemented a sender worker that will send metrics to a given service

@@ -39,3 +39,15 @@ func (c *Client) CleanupOldMetrics() error {
}
return results.OneError()
}

func (c *Client) SendMetrics() error {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need comments on exported functions

@mattyw mattyw changed the title WIP: implemented the sender worker for metrics Implemented the sender worker for metrics Sep 4, 2014
if err != nil {
return err
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err = iter.Close()
if err != nil {
  return err
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cmars fixed

@mattyw
Copy link
Contributor Author

mattyw commented Sep 8, 2014

@cmars @fwereade PTAL

if iter.Next(&doc) {
batch[i] = &MetricBatch{st: st, doc: doc}
} else {
if iter.Err() != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a guard against inconsistency, how about:

if err := iter.Err(); err != nil {
  return err
}

@cmars
Copy link
Contributor

cmars commented Sep 9, 2014

LGTM with one minor change commented above. I'd be ok landing this and following it up with more implementation in subsequent PRs.

}
}
for _, m := range batch {
err := m.SetSent()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nicer to set them all to sent in one go here, I think?

@fwereade
Copy link
Contributor

fwereade commented Sep 9, 2014

Mostly looking good, but needs a bit more work

@@ -78,7 +80,7 @@ func (s *metricsManagerSuite) TestNewMetricsManagerAPIRefusesNonClient(c *gc.C)
c.Assert(err, gc.ErrorMatches, "permission denied")
}

func (s *metricsManagerSuite) TestCleanupArgsIndependant(c *gc.C) {
func (s *metricsManagerSuite) TestCleanupArgsIndependent(c *gc.C) {
args := params.Entities{Entities: []params.Entity{
params.Entity{"invalid"},
params.Entity{s.State.EnvironTag().String()},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        {"invalid"},
        {s.State.EnvironTag().String()},

Running gofmt -s -w will automagically change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@waigani Thank you very much. Didn't know about -s

@mattyw
Copy link
Contributor Author

mattyw commented Sep 11, 2014

@waigani @fwereade @cmars PTAL

@@ -23,6 +23,10 @@ type metricsManagerSuite struct {

var _ = gc.Suite(&metricsManagerSuite{})

func TestAll(t *stdtesting.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would you put this in a package_test.go please? it's the easiest way to make sure there's only one of them

@fwereade
Copy link
Contributor

essentially LGTM with a bunch of trivials


// SendMetrics will send any unsent metrics
// over the MetricSender interface in batches
// of no more than 1k.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the size of 1k depends on batchSize

@tasdomas
Copy link
Contributor

LGTM with a few minor nitpicks

@mattyw
Copy link
Contributor Author

mattyw commented Sep 17, 2014

$$merge$$

@jujubot
Copy link
Collaborator

jujubot commented Sep 17, 2014

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

jujubot added a commit that referenced this pull request Sep 17, 2014
Implemented the sender worker for metrics

Implemented a sender worker that will send metrics to a given service
@jujubot jujubot merged commit 87d2332 into juju:master Sep 17, 2014
@mattyw mattyw deleted the add-metric-sender-worker branch September 17, 2014 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants