MCPcopy
hub / github.com/prometheus/client_golang / Push

Method Push

prometheus/graphite/bridge.go:166–188  ·  view source on GitHub ↗

Push pushes Prometheus metrics to the configured Graphite server.

()

Source from the content-addressed store, hash-verified

164
165// Push pushes Prometheus metrics to the configured Graphite server.
166func (b *Bridge) Push() error {
167 mfs, err := b.g.Gather()
168 if err != nil || len(mfs) == 0 {
169 switch b.errorHandling {
170 case AbortOnError:
171 return err
172 case ContinueOnError:
173 if b.logger != nil {
174 b.logger.Println("continue on error:", err)
175 }
176 default:
177 panic("unrecognized error handling value")
178 }
179 }
180
181 conn, err := net.DialTimeout("tcp", b.url, b.timeout)
182 if err != nil {
183 return err
184 }
185 defer conn.Close()
186
187 return writeMetrics(conn, mfs, b.useTags, b.prefix, model.Now())
188}
189
190func writeMetrics(w io.Writer, mfs []*dto.MetricFamily, useTags bool, prefix string, now model.Time) error {
191 vec, err := expfmt.ExtractSamples(&expfmt.DecodeOptions{

Callers 3

RunMethod · 0.95
TestPushFunction · 0.95
ExampleBridgeFunction · 0.95

Calls 3

writeMetricsFunction · 0.85
GatherMethod · 0.65
PrintlnMethod · 0.65

Tested by 2

TestPushFunction · 0.76
ExampleBridgeFunction · 0.76