Closed ClemChou000 closed 11 months ago
Hey @KoyomiKun!
Have you tried using InitPushExt function and add hook to the writeMetrics func(w io.Writer)
function?
Closing this pull request, since the extra actions can be performed inside writeMetrics
callback, which is passed to InitPushExt and InitPushExtWithOptions, as @hagen1778 pointed out above. For example:
customMetricsSet := metrics.NewSet()
// add the needed metrics to customMetricsSet ...
// ...
writeMetrics := func(w io.Writer) {
pushHook() // call pushHook before sending the customMetricsSet metrics to pushURL
customMetricsSet.WritePrometheus(w)
}
if err := metrics.InitPushExt(pushURL, pushInterval, extraLabels, writeMetrics); err != nil {
panic(err)
}
If you still feel that the pushHook
is needed as a separate callback, then try adding it to the PushOptions in a new pull request.
add push hook in order to execute some extra actions like reset registry or update metrics synchronously