-
Notifications
You must be signed in to change notification settings - Fork 66
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
Enable to define push config for InitPush #53
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #53 +/- ##
==========================================
+ Coverage 85.89% 89.35% +3.45%
==========================================
Files 11 12 +1
Lines 936 958 +22
==========================================
+ Hits 804 856 +52
+ Misses 109 72 -37
- Partials 23 30 +7 ☔ View full report in Codecov by Sentry. |
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.
@dmitryk-dk please take a look at changes here f0c370a
Let me know if there are any questions
PushConfig represents a struct package uses for pushing metrics to remote destination. Having a structure helps to extend functionality in the future, without touching signature of existing functions. For example, `PushConfig` supports custom HTTP headers via `Headers` param. Updates #52
Header structure contains a list of header values. Using `.Set` will override previously written value.
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.
I'm going to revert this pull request, since it provides dubious public API to users of the github.com/VictoriaMetrics/metrics
package. It would be better to re-think API in order to make it more usable instead of supporting the broken API forever.
// URL and Interval are required fields | ||
type PushConfig struct { | ||
// URL defines URL where metrics would be pushed. | ||
URL string |
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 would be better from usability perspective to remove the required URL
and Interval
options from the PushConfig
. These options must be passed explicitly into InitPushWithConfig()
. This prevents from passing invalid PushConfig
to InitPushWithConfig()
without the required URL
and Interval
options.
It would be better also renaming the PushConfig
to PushOptions
in order to reflect that all the options inside PushOptions
are optional.
// Interval determines the frequency of pushing metrics. | ||
Interval time.Duration | ||
|
||
// Headers contain optional http request Headers |
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 is unclear the purpose of the request header from this description
ExtraLabels string | ||
// WriteMetricsFn is a callback to write metrics to w in Prometheus text exposition format without timestamps and trailing comments. | ||
// See https://github.com/prometheus/docs/blob/main/content/docs/instrumenting/exposition_formats.md#text-based-format | ||
WriteMetricsFn func(w io.Writer) |
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 is completely unclear the purpose of WriteMetricsFn
and how to use it properly. I don't think this function must be exposed to users. It looks like this function must be an internal implementation detail.
// It is OK calling InitPushWithConfig multiple times with different PushConfig.WriteMetricsFn - | ||
// in this case all the metrics generated by PushConfig.WriteMetricsFn callbacks are written to PushConfig.URL. | ||
// | ||
// If |
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.
What is If
?
This reverts commit 42c28a8. Reason for revert: the provided additional public API looks not very good for future support. See #53 (review) for details.
reverted the pull request at cd448dd . Let's make the public API better, so it serves the following purposes:
|
FYI, the commit a9e3faa implements the desired API according to #53 (comment) . This commit has been included in the tag v1.26.0. Update: the API is extended a bit in the commit bd3cd7b , which adds an ability to stop started metric pushes via canceling the provided |
Enable to define push config and use it in the push functions. This improvement helps to set different parameters for the requests such as HTTP headers. The
PushConfig
config can be improved in the future if necessary.