-
Notifications
You must be signed in to change notification settings - Fork 780
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
Implements metrics using armon/go-metrics library #1616
base: main
Are you sure you want to change the base?
Conversation
7cce0dd
to
9fc25e6
Compare
Hello @eikenb ! |
Any update on this? Would love to see this merged. We're kind of in the dark now when consul-template fails to render a template. Except when a service using the rendered template eventually breaks, but I would like to know that before hand. |
Any updates on this? |
+1 for this please. this will go a long way in reliably monitoring consul-template |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 @Eclion Thank you so much for the thorough work that went into making this PR happen.
Happy to work with you and a few others to get this merged/released within the next couple of weeks.
✍🏾 I did a first pass review and i am leaving a few comments for consideration. Let me know if any of them don't make sense to you.
❓ Do you mind updating this PR to the main
branch, looks like it is quite behind now so it will be nice to get this updated before we work on merging it in
🔢 Happy to help/assist in anyway you want me to
Hello @roncodingenthusiast !
Sure! I will rebase my branch before working on your comments.
|
997b530
to
82c33c4
Compare
43166c3
to
80b5f0a
Compare
I would very much like for this PR to be merged - and released. Any update on this? |
I'm eagerly waiting on this to be merged as well. Can't wait for this to be merged |
750c214
to
011d417
Compare
011d417
to
ec189f9
Compare
fork rebased on current main branch |
Hoping this year will be the year of consul-template metrics. @nathancoleman @jmurret @jm96441n @DanStough I see you have recently done work on this repo, perhaps one of you can give a status update? |
implements the metric system following the implementation done in Consul and trying to implement the same metrics as done in the previous metric system (c.f. PR1378: https://github.com/hashicorp/consul-template/pull/1378/files )
following @roncodingenthusiast's suggestion
following @roncodingenthusiast's suggestion
ec189f9
to
4caed4f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall looks good, just a few additional changes and I'm happy to merge
// Merge combines all values in this configuration with the values in the other | ||
// configuration, with values in the other configuration taking precedence. | ||
// Maps and slices are merged, most other values are overwritten. | ||
func (c *TelemetryConfig) Merge(o *TelemetryConfig) *TelemetryConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add tests for this merge function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
I added some tests as requested
return fmt.Sprintf("&TelemetryConfig{"+ | ||
"Disable:%v, "+ | ||
"CirconusAPIApp:%s, "+ | ||
"CirconusAPIToken:%s, "+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we worried about leaking the API token in logs here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for spotting this issue. The output value has been replaced by <empty>
and <configured>
.
dependency/dependency.go
Outdated
@@ -49,6 +49,14 @@ const ( | |||
DefaultContextTimeout = 60 * time.Second | |||
) | |||
|
|||
func (t Type) String() string { | |||
if t > 2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: could we have a comment here indicating why 2
or use a named constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was used in the upstream PR to default to unknown
probably because Nomad
was not part of the Type
list at that time.
I replaced this section by a switch case, more explicit
manager/runner.go
Outdated
@@ -1478,3 +1511,30 @@ func newWatcher(c *config.Config, clients *dep.ClientSet) *watch.Watcher { | |||
RetryFuncNomad: watch.RetryFunc(c.Nomad.Retry.RetryFunc()), | |||
}) | |||
} | |||
|
|||
func recordDependencyCounts(deps map[string]dep.Dependency) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function doesn't return anything or modify the input in any way, what is it meant to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section of code from the PR #1378 was used to compute metrics for the histograms.
However, as histograms are yet to be implemented in go-metrics, this code is therefor unneeded.
I will remove it.
telemetry/telemetry_test.go
Outdated
for _, actualMetric := range actualMetrics { | ||
if strings.HasPrefix(actualMetric, "# HELP go_") || | ||
strings.HasPrefix(actualMetric, "# TYPE go_") || | ||
strings.HasPrefix(actualMetric, "go_") || | ||
strings.HasPrefix(actualMetric, "# HELP process_") || | ||
strings.HasPrefix(actualMetric, "# TYPE process_") || | ||
strings.HasPrefix(actualMetric, "process_") || | ||
actualMetric == "" { | ||
continue | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor but this might be a bit more readable
for _, actualMetric := range actualMetrics { | |
if strings.HasPrefix(actualMetric, "# HELP go_") || | |
strings.HasPrefix(actualMetric, "# TYPE go_") || | |
strings.HasPrefix(actualMetric, "go_") || | |
strings.HasPrefix(actualMetric, "# HELP process_") || | |
strings.HasPrefix(actualMetric, "# TYPE process_") || | |
strings.HasPrefix(actualMetric, "process_") || | |
actualMetric == "" { | |
continue | |
} | |
prefixes := []string{"# HELP go_", "#TYPE go", "go_", "# HELP process_", "# TYPE process_", "process_"} | |
for _, actualMetric := range actualMetrics { | |
if slices.ContainsFunc(prefixes, func(p string) bool { return strings.HasPrefix(actualMetric, p) }) || | |
actualMetric == "" { | |
continue | |
} | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion! I agree with it being more readable.
…regarding prefix check on array
Hello @jm96441n, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nomad embeds consul-template as a library rather than using it as a standalone binary. The HTTP server and telemetry sink should be configurable by passing in an existing server and sink.
Hello @tgross , If I am not wrong, there is no need to call So the only needed call, as far as I understand, would be However, such call is not implemented in the |
The |
As suggested in the issue #1395, this PR implements a metric system using the armon/go-metrics library along with few metrics.
To achieve such implementation, the metric system was based on the implementation done in Consul and the exposed metrics have been implemented based on the PR #1378.
However, this implementation only partially implements the mentioned metrics:
armon/go-metrics
library doesn't support yet histograms so these metrics are not implemented in this PR.dependency
,config
andtelemetry
packages, metrics related to the vault token were not implementedResolves #1395