Debian Codegraph @

stress/v2/stress_client/response.go

raw symbols SCIP
1 package stressClient
2
3 import (
4 "log"
5
6 influx "github.com/influxdata/influxdb/client/v2"
7 )
8
9 // Response holds data scraped from InfluxDB HTTP responses turned into a *influx.Point for reporting
10 // See reporting.go for more information
11 // The Tracer contains a wait group sent from the statement. It needs to be decremented when the Response is consumed
12 type Response struct {
13 Point *influx.Point
14 Tracer *Tracer
15 }
16
17 // NewResponse creates a new instance of Response
18 func NewResponse(pt *influx.Point, tr *Tracer) Response {
19 return Response{
20 Point: pt,
21 Tracer: tr,
22 }
23 }
24
25 // AddTags adds additional tags to the point held in Response and returns the point
26 func (resp Response) AddTags(newTags map[string]string) (*influx.Point, error) {
27
28 // Pull off the current tags
29 tags := resp.Point.Tags()
30
31 // Add the new tags to the current tags
32 for tag, tagValue := range newTags {
33 tags[tag] = tagValue
34 }
35
36 // Make a new point
37 fields, err := resp.Point.Fields()
38 if err != nil {
39 return nil, err
40
41 }
42 pt, err := influx.NewPoint(resp.Point.Name(), tags, fields, resp.Point.Time())
43
44 // panic on error
45 if err != nil {
46 log.Fatalf("Error adding tags to response point\n point: %v\n tags:%v\n error: %v\n", resp.Point, newTags, err)
47 }
48
49 return pt, nil
50 }