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

Issue #151: Add support for Circonus metrics #150

Closed
wants to merge 6 commits into from
Closed

Issue #151: Add support for Circonus metrics #150

wants to merge 6 commits into from

Conversation

maier
Copy link
Contributor

@maier maier commented Aug 30, 2016

Adding support for sending metrics to Circonus.

#
# The default is
#
# metrics.circonus.apiapp = "fabio"
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't use double quotes unless you want to send them. Also, if this is the default then you need to set this in config/default.go. Same for metrics.circonus.apiurl

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a default for CirconusAPIApp to defaults. I reworded the description of the API URL parameter, I'd prefer to keep that default localized in the library so that if it changes there isn't a waterfall of PRs to update.

@magiconair
Copy link
Contributor

Could you also update the comment for the 2nd commit to Issue #147: Add support to send metrics to Circonus. I think if you force push the branch to your repo git push -f then this won't create additional commits in the PR. GH should just replace the current PR.

@@ -512,16 +512,18 @@
#
# The default is
#
# metrics.circonus.apiapp = "fabio"
# metrics.circonus.apiapp =
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, if you set a default in config/default.go then this needs to be reflected here. Why did you remove it?

should be metrics.circonus.apiapp = fabio

@magiconair
Copy link
Contributor

I thinks this looks ok enough. I'll merge this manually since the config/load_test.go needs updating and there are one or two typos. Thanks for your patience with the code review.

@magiconair
Copy link
Contributor

@maier you seem to have forgotten to add metrics.circonus.apikey to the fabio.properties. Could you provide me with the snippet and then I'll add it. Thx

@magiconair
Copy link
Contributor

@maier or is this ok?

# metrics.circonus.apikey configures the API key to use when
# submitting metrics to Circonus. See: https://login.circonus.com/user/tokens
# This is optional when ${metrics.target} is set to "circonus".
#
# The default is
#
# metrics.circonus.apikey =

@maier
Copy link
Contributor Author

maier commented Aug 30, 2016

# metrics.circonus.apikey configures the API token key to use when
# submitting metrics to Circonus. See: https://login.circonus.com/user/tokens
# This is required when ${metrics.target} is set to "circonus".
#
# The default is
#
# metrics.circonus.apikey =

@maier
Copy link
Contributor Author

maier commented Aug 30, 2016

that's the one setting which is required, the rest are optional.

@magiconair
Copy link
Contributor

Got it. I'm still curious what TestAll is testing and how you determine that the test has passed. Could you explain, please?

@maier
Copy link
Contributor Author

maier commented Aug 30, 2016

testAll actually does the job, it connects to the api and performs all of the steps. verification is two-fold, if the code fails and then checking manually in the UI for the metric coming through. the code will fail in finding/creating the check, then i go over to the ui and verify that a) the fake metric was created and b) a submission came through for it. it's gated by the env vars so that it doesn't thrash the checks.

@magiconair
Copy link
Contributor

ok, that's what I thought. This is an integration test which requires manual inspection. I'll leave it in for now but need to think about whether I would want to mock the API or check this another way. I don't want to test the driver.

As a side note: I would also like to merge the change from #125 which adds a counter to the metrics registry.

 // Counter defines a metric for counting events.
 type Counter interface {
     // Inc increases the counter value by 'n'.
     Inc(n int64)
 }

How would I add this to the circonus registry?

@maier
Copy link
Contributor Author

maier commented Aug 30, 2016

type cgmCounter struct {
    metrics *cgm.CirconusMetrics
    name    string
}

func (m *cgmRegistry) GetCounter(name string) Counter {
    metricName := fmt.Sprintf("%s`%s", m.prefix, name)
    return &cgmCounter{m.metrics, metricName}
}

func (c cgmCounter) Inc(n int64) {
    c.metrics.IncrementByValue(c.name, uint64(n))
}

@magiconair
Copy link
Contributor

OK, I just noticed that the registry methods return pointers (&cgmTimer) but the methods on the structs have value receivers. How does this even work? I guess in the current implementation it doesn't make a difference whether it is either/or but I think it should be consistent. I'll change the timer/counter methods to have pointer receivers as well (e.g. func (t *cgmTimer) UpdateSince(...)) unless you know a good reason why I shouldn't.

magiconair pushed a commit that referenced this pull request Aug 30, 2016
This patch adds support for sending metrics
to Circonus (http://circonus.com).

The code is squashed from PR #150 with minor
edits and was written by @maier.
@magiconair magiconair changed the title Issue 147 support multiple metrics libraries Issue 151: Add support for Circonus metrics Aug 30, 2016
@magiconair magiconair changed the title Issue 151: Add support for Circonus metrics Issue #151: Add support for Circonus metrics Aug 30, 2016
@magiconair
Copy link
Contributor

Did a manual merge of this PR to master.

@magiconair magiconair closed this Aug 30, 2016
@magiconair magiconair added this to the 1.3 milestone Oct 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants