title: How to update metric values in prometheus exporter (golang)
body: <p>I'm starting to write an own prometheus exporter using golang.
  I think I got the basics but I don't know what to do exactly to get the value of the metric up to date. Using Set only does it once.
  It is not changing on runtime.</p>
  
  <p>What I have so far:</p>
  
  <pre><code>package main
  
  import (
    "log"
    "net/http"
  
    "github.com/prometheus/client_golang/prometheus"
    "github.com/prometheus/client_golang/prometheus/promhttp"
  
    "time"
    "io/ioutil"
    "github.com/tidwall/gjson"
    "strconv"
  )
  
  var (
    sidekiqProcessed = setGaugeMetric("sidekiq_processed", "Sidekiq Processed", "lable", "lablevalue")
  )
  
  func setGaugeMetric(name string, help string, label string, labelvalue string) (prometheusGauge prometheus.Gauge) {
    var (
      gaugeMetric = prometheus.NewGauge(prometheus.GaugeOpts{
        Name: name,
        Help: help,
        ConstLabels: prometheus.Labels{label: labelvalue},
      })
    )
  
    return gaugeMetric
  }
  
  func getSidekiqProcessed() (sidekiq float64) {
    body := getContent("http://example.com/sidekiq/stats")
    processed := gjson.Get(body, "sidekiq.processed")
    conv, err := strconv.ParseFloat(processed.String(), 64)
    if err != nil {
      log.Fatal(err)
    }
    return conv
  }
  
  func getContent(url string) (body string) {
    httpClient := &amp;http.Client{Timeout: 10 * time.Second}
    res, err := httpClient.Get(url)
  
    if err != nil {
      log.Fatal(err)
    }
  
    content, err := ioutil.ReadAll(res.Body)
    res.Body.Close()
  
    if err != nil {
      log.Fatal(err)
    }
  
    return string(content)
  }
  
  func init() {
    prometheus.MustRegister(sidekiqProcessed)
  }
  
  func main() {
    sidekiqProcessed.Set(getSidekiqProcessed())
  
    // The Handler function provides a default handler to expose metrics
    // via an HTTP server. "/metrics" is the usual endpoint for that.
    http.Handle("/metrics", promhttp.Handler())
    log.Fatal(http.ListenAndServe(":8080", nil))
  }
  </code></pre>
  
  <p>Read something about Collector but have no clue how to implement it.
  Can somebody help me to complete/correct my code so that the value of the metric also updates at runtime?</p>