Skip to content

Commit

Permalink
Versioning to query endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
adityauj committed Sep 17, 2024
1 parent 7400273 commit f1893c5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions internal/metricdata/cc-metric-store.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ func (ccms *CCMetricStore) doRequest(
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", ccms.jwt))
}

// versioning the cc-metric-store query API.
// v2 = data with resampling
// v1 = data without resampling
q := req.URL.Query()
q.Add("version", "v2")
req.URL.RawQuery = q.Encode()

res, err := ccms.client.Do(req)
if err != nil {
log.Error("Error while performing request")
Expand Down Expand Up @@ -198,12 +205,17 @@ func (ccms *CCMetricStore) LoadData(
jobData[metric] = make(map[schema.MetricScope]*schema.JobMetric)
}

res := row[0].Resolution
if res == 0 {
res = mc.Timestep
}

jobMetric, ok := jobData[metric][scope]

if !ok {
jobMetric = &schema.JobMetric{
Unit: mc.Unit,
Timestep: row[0].Resolution,
Timestep: res,
Series: make([]schema.Series, 0),
}
jobData[metric][scope] = jobMetric
Expand Down Expand Up @@ -623,7 +635,7 @@ func (ccms *CCMetricStore) LoadNodeData(

resBody, err := ccms.doRequest(ctx, &req)
if err != nil {
log.Error("Error while performing request")
log.Error(fmt.Sprintf("Error while performing request %#v\n", err))
return nil, err
}

Expand Down

0 comments on commit f1893c5

Please sign in to comment.