Skip to content

Commit

Permalink
feat(profefe): Support labels
Browse files Browse the repository at this point in the history
Labels where not supported, they where not pushed down in profefe.
We not store them in the profile as well.

Signed-off-by: Gianluca Arbezzano <gianarb92@gmail.com>
  • Loading branch information
Gianluca Arbezzano committed Dec 23, 2019
1 parent 40d8482 commit d650e0b
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions pkg/profefe/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ func (c *Client) GetProfiles(ctx context.Context, req GetProfilesRequest) (*GetP
q.Add("to", req.To.Format(timeFormat))
q.Add("type", req.Type.String())
q.Add("service", req.Service)
labels := ""
isLabels := false
// Set labels as part of the profile and push them down to profefe
for k, v := range req.Labels {
isLabels = true
labels = labels + "," + k + "=" + v
}
if isLabels {
q.Add("labels", labels)
}
r.URL.RawQuery = q.Encode()

resp, err := c.Do(r)
Expand Down Expand Up @@ -169,10 +179,6 @@ type GetProfilesResponse struct {
func (c *Client) SavePprof(ctx context.Context, req SavePprofRequest) (*SavePprofResponse, error) {
buf := bytes.NewBuffer([]byte{})
req.Profile.Write(buf)
labels := ""
for k, v := range req.Labels {
labels = labels + "," + k + "=" + v
}
r, err := http.NewRequest("POST", c.HostPort+"/api/0/profiles", buf)
if err != nil {
return nil, err
Expand All @@ -182,6 +188,17 @@ func (c *Client) SavePprof(ctx context.Context, req SavePprofRequest) (*SavePpro
q.Add("service", req.Service)
q.Add("instance_id", req.InstanceID)
q.Add("type", req.Type.String())
labels := ""
isLabels := false
// Set labels as part of the profile and push them down to profefe
for k, v := range req.Labels {
isLabels = true
labels = labels + "," + k + "=" + v
req.Profile.SetLabel(k, []string{v})
}
if isLabels {
q.Add("labels", labels)
}
r.URL.RawQuery = q.Encode()

r.Header.Add("UserAgent", c.UserAgent)
Expand Down

0 comments on commit d650e0b

Please sign in to comment.