Circonus metrics adapter#1737
Circonus metrics adapter#1737istio-merge-robot merged 11 commits intoistio:masterfrom redhotpenguin:circonus
Conversation
|
Hi @redhotpenguin. Thanks for your PR. I'm waiting for a istio member to verify that this patch is reasonable to test. If it is, they should reply with I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
|
/ok-to-test |
|
/retest |
|
Dropping a ping to @geeknoid for a review as suggested reviewer. Looks like the circleci tests that failed are an envoy issue - not sure if related. |
geeknoid
left a comment
There was a problem hiding this comment.
Thanks for the adapter.
mixer/adapter/circonus/circonus.go
Outdated
mixer/adapter/circonus/circonus.go
Outdated
There was a problem hiding this comment.
Initialize with struct init syntax instead?
There was a problem hiding this comment.
Done, and additional fmt/linter/doc changes have been pushed.
mixer/adapter/circonus/circonus.go
Outdated
There was a problem hiding this comment.
Please run "go fmt" on the file.
Our linter bot is currently broken, so you won't get dinged during the presubmit tests unfortunately. We're working on fixing that.
There was a problem hiding this comment.
Huh, surprised Goland didn't gofmt automatically, I thought it had been. Good to know.
Thanks for the feedback; I'll make these requested changes and run the tests again.
mixer/adapter/circonus/circonus.go
Outdated
There was a problem hiding this comment.
I think you need to have some logic here to validate your config. is submission_url a well-formed URL? Are metric names supplied, and other fields have valid values, etc.
There was a problem hiding this comment.
Probably should give an error if you've been giving a particular MetricType via SetMetricTypes, but your adapter config doesn't specify that particular metric.
mixer/adapter/circonus/circonus.go
Outdated
There was a problem hiding this comment.
Adapters don't need to check for this case as it would indicate a bug in the Mixer. So we just assume this works and expect a crash later on due to nil pointers if that's not the case.
mixer/adapter/circonus/circonus.go
Outdated
There was a problem hiding this comment.
Redundant map lookup, already did it right above.
mixer/adapter/circonus/circonus.go
Outdated
There was a problem hiding this comment.
This should be caught at config validation time (assuming you update the Validate method), so at runtime you can just assume it worked.
There was a problem hiding this comment.
Same comment applies to other validations here...
mixer/adapter/circonus/circonus.go
Outdated
There was a problem hiding this comment.
It would be better if the interaction with the backend were handled synchronously so that errors are reported up. As it is, errors in this flush code will be invisible to the rest of the Istio pipeline.
There was a problem hiding this comment.
I was able to tie the circonus-gometrics logger which uses the standard log package into the env.Logger() interface. Log entries are being reported with the async approach for flush events. Let me know if this handles the spirit of what you were after here.
|
Yeah, GoLand no longer seems to be running go fmt for me since the last
update. I've got it setup as a File Watching thingy, but it's not
triggering.
…On Fri, Nov 17, 2017 at 9:19 AM, Fred Moyer ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In mixer/adapter/circonus/circonus.go
<#1737 (comment)>:
> + cmc.CheckManager.Check.SubmissionURL = b.adpCfg.SubmissionUrl
+ cmc.Debug = true
+ cmc.Interval = "0"
+ cm, err := cgm.NewCirconusMetrics(cmc)
+ if err != nil {
+ err = env.Logger().Errorf("Could not create NewCirconusMetrics: %v", err)
+ return nil, err
+ }
+
+ metrics := make(map[string]config.Params_MetricInfo_Type)
+ ac := b.adpCfg
+ for _, metric := range ac.Metrics {
+
+ metrics[metric.Name] = metric.Type
+ }
+ return &handler{cm: *cm, metricTypes: b.metricTypes, env: env, metrics: metrics}, nil
Huh, surprised Goland didn't gofmt automatically, I thought it had been.
Good to know.
Thanks for the feedback; I'll make these requested changes and run the
tests again.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1737 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AVucHYN5mfufRXdq4sgowKgbOK4U4kR3ks5s3cAhgaJpZM4Qftx8>
.
|
mixer/adapter/circonus/circonus.go
Outdated
There was a problem hiding this comment.
use standard godoc style here?
// Build does x and yThere was a problem hiding this comment.
Noted - will make this change. Took this from the adapter developer's guide example.
mixer/adapter/circonus/circonus.go
Outdated
There was a problem hiding this comment.
style nit: we typically don't have large comment headers in our code
Codecov Report
@@ Coverage Diff @@
## master #1737 +/- ##
==========================================
- Coverage 82.08% 81.84% -0.25%
==========================================
Files 198 192 -6
Lines 16320 15919 -401
==========================================
- Hits 13397 13029 -368
+ Misses 2480 2428 -52
- Partials 443 462 +19
Continue to review full report at Codecov.
|
|
Sorry, I didn't realize you were ready for another review. Our custom is to
add a comment with PTAL in it so reviewers get a heads-up.
I'll look shortly.
Thanks.
…On Mon, Nov 27, 2017 at 10:26 AM, Fred Moyer ***@***.***> wrote:
@geeknoid <https://github.com/geeknoid> @ijsnellf
<https://github.com/ijsnellf> let me know if you can take a look at the
updates I pushed last week. Resolved all fmt/linting issues, and bridged to
the env logger so any scheduled events will report in the log (in addition
to synchronous events). Thanks.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1737 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AVucHd5FCG14c77HLrJFoaJb2_WvZGenks5s6v68gaJpZM4Qftx8>
.
|
mixer/adapter/circonus/circonus.go
Outdated
There was a problem hiding this comment.
Should the interval be in config?
There was a problem hiding this comment.
I'm manually flushing here, so this needs to be set to 0.
mixer/adapter/circonus/circonus.go
Outdated
There was a problem hiding this comment.
Would it make sense to complain about entries defined in your config, but for which there is no MetricType?
mixer/adapter/circonus/circonus.go
Outdated
There was a problem hiding this comment.
You probably should synchronously flush here, otherwise your buffered data would never make it out.
There was a problem hiding this comment.
Thanks for the spot, will make that update.
There was a problem hiding this comment.
I just realized you're flushing for every HandleMetric call, so there is no buffered state to flush in Close...
mixer/adapter/circonus/circonus.go
Outdated
There was a problem hiding this comment.
Is this just for debugging? This could be called at very high QPS, so flushing on every call seems unfortunate.
There was a problem hiding this comment.
It was intentional; I had the same concern also, but wanted to follow this approach as opposed to letting cgm autoflush and not have the async work wrapped by ScheduleWork as documented in the developer guide. Let me dig into the flush call again and see if there's a way to pass the autoflush call to ScheduleWork.
There was a problem hiding this comment.
The reason we use ScheduleWork is so that we can trap and recover from panics in the code, and not crash/deadlock Mixer as a whole for a local adapter failure. This is definitely not very composable with existing packages that spawn their own goroutines.
If you can't wrap their autoflush, then you should probably use env.ScheduleDaemon and start your own auto-flusher goroutine that calls the flush call on a configurable period.
There was a problem hiding this comment.
Ok I'll work on implementing that and push. Thanks for the feedback here; helps a lot.
|
@redhotpenguin PR needs rebase |
|
can you also sync with master, so that you run the right set of circleci unit tests? |
* Bridge cgm log to mixer glog implementation to set cgm logger * Cgm constructor using struct declaration, not field assignment * Rework function documentation * Add configuration validation * Remove testenv dep and update istio api dep * Linter fixes
* Initialize startup background tasks under ScheduleWork() * Flush on an interval under ScheduleWork() * Additional config and metrictype validation
* Initialize struct in block syntax * Remove Close() test which did not test anything meaningful
* Use a context WithCancel approach to shut down the flush goroutine * Add validation for FlushInterval less than 1 second * Add unit test for validation error cases
|
and the funky robot commands don't work with circleci :). They are meant only for prow.. |
|
@rshriram thanks - still learning the ropes here with the bot commands :) |
|
@rshriram all tests pass, thanks for the help getting through that. Looks like the only thing remaining is the lgtm label. |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: geeknoid The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
|
/test all [submit-queue is verifying that this PR is safe to merge] |
|
/test all [submit-queue is verifying that this PR is safe to merge] |
|
Automatic merge from submit-queue. |
What this PR does / why we need it:
This PR adds a metrics adapter for Circonus, similar to the Prometheus and Statsd adapters. It draws from my previous PR for the 0.1 based metrics implementation - this has been updated to use the new handler structure. It uses the
ScheduleWork()call per the adapter development guide to schedule flushes to Circonus.The tests are fashioned after the existing adapter tests. I implemented a version using
testenv, but I wasn't able to access the adapter. It looks like it is possible, but will require a bit more understanding on my part, and possible additional test methods.I've verified that the adapter works as advertised both in mixc client environment as well as with the BookInfo sample in GKE. I included a sample operator config - I didn't see that with the additional adapters, but think it will be useful to the end user.
Please let me know how this looks, any suggestions are welcome.
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close that issue when PR gets merged): fixes #Special notes for your reviewer:
Unit tests don't need an http trap submission url, a fake one is part of the testdata config.
Release note:
This change introduces a metrics adapter for Circonus metrics collection.