diff options
Diffstat (limited to 'vendor/github.com/prometheus/client_golang/prometheus/push/examples_test.go')
-rw-r--r-- | vendor/github.com/prometheus/client_golang/prometheus/push/examples_test.go | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/push/examples_test.go b/vendor/github.com/prometheus/client_golang/prometheus/push/examples_test.go index 7e0ac66a5..7f17ca291 100644 --- a/vendor/github.com/prometheus/client_golang/prometheus/push/examples_test.go +++ b/vendor/github.com/prometheus/client_golang/prometheus/push/examples_test.go @@ -15,6 +15,7 @@ package push_test import ( "fmt" + "time" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/push" @@ -23,9 +24,9 @@ import ( func ExampleCollectors() { completionTime := prometheus.NewGauge(prometheus.GaugeOpts{ Name: "db_backup_last_completion_timestamp_seconds", - Help: "The timestamp of the last successful completion of a DB backup.", + Help: "The timestamp of the last succesful completion of a DB backup.", }) - completionTime.SetToCurrentTime() + completionTime.Set(float64(time.Now().Unix())) if err := push.Collectors( "db_backup", push.HostnameGroupingKey(), "http://pushgateway:9091", @@ -34,3 +35,22 @@ func ExampleCollectors() { fmt.Println("Could not push completion time to Pushgateway:", err) } } + +func ExampleRegistry() { + registry := prometheus.NewRegistry() + + completionTime := prometheus.NewGauge(prometheus.GaugeOpts{ + Name: "db_backup_last_completion_timestamp_seconds", + Help: "The timestamp of the last succesful completion of a DB backup.", + }) + registry.MustRegister(completionTime) + + completionTime.Set(float64(time.Now().Unix())) + if err := push.FromGatherer( + "db_backup", push.HostnameGroupingKey(), + "http://pushgateway:9091", + registry, + ); err != nil { + fmt.Println("Could not push completion time to Pushgateway:", err) + } +} |