Skip to content

Commit

Permalink
addressed minor changes
Browse files Browse the repository at this point in the history
Signed-off-by: Namanl2001 <namanlakhwani@gmail.com>
  • Loading branch information
Namanl2001 committed Mar 27, 2021
1 parent f4069b7 commit 6c2ec33
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cmd/thanos/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func runSidecar(
{
ctx, cancel := context.WithCancel(context.Background())
g.Add(func() error {
// We retry infinitely until we reach and fetch BuildInfo from our Prometheus.
// We retry infinitely until we reach and fetch BuildVersion from our Prometheus.
err := runutil.Retry(2*time.Second, ctx.Done(), func() error {
if err := m.BuildVersion(ctx); err != nil {
level.Warn(logger).Log(
Expand Down Expand Up @@ -424,7 +424,7 @@ func (s *promMetadata) Timestamps() (mint int64, maxt int64) {
}

func (s *promMetadata) BuildVersion(ctx context.Context) error {
ver, err := s.client.BuildInfo(ctx, s.promURL)
ver, err := s.client.BuildVersion(ctx, s.promURL)
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/promclient/promclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,14 +608,14 @@ func (c *Client) AlertmanagerAlerts(ctx context.Context, base *url.URL) ([]*mode
return v.Data, nil
}

// BuildInfo returns Prometheus version from /api/v1/status/buildinfo Prometheus endpoint.
func (c *Client) BuildInfo(ctx context.Context, base *url.URL) (string, error) {
// BuildVersion returns Prometheus version from /api/v1/status/buildinfo Prometheus endpoint.
func (c *Client) BuildVersion(ctx context.Context, base *url.URL) (string, error) {
u := *base
u.Path = path.Join(u.Path, "/api/v1/status/buildinfo")

level.Debug(c.logger).Log("msg", "querying instant", "url", u.String())
level.Debug(c.logger).Log("msg", "build version", "url", u.String())

span, ctx := tracing.StartSpan(ctx, "/prom_buildinfo HTTP[client]")
span, ctx := tracing.StartSpan(ctx, "/prom_buildversion HTTP[client]")
defer span.Finish()

body, _, err := c.req2xx(ctx, &u, http.MethodGet)
Expand Down
6 changes: 4 additions & 2 deletions pkg/store/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ func (p *PrometheusStore) LabelValues(ctx context.Context, r *storepb.LabelValue
if err != nil {
return nil, err
}
sort.Strings(vals)
} else {
matchers, err := storepb.MatchersToPromMatchers(r.Matchers...)
if err != nil {
Expand All @@ -522,8 +521,11 @@ func (p *PrometheusStore) LabelValues(ctx context.Context, r *storepb.LabelValue
return nil, err
}
for _, s := range sers {
vals = append(vals, s[r.Label])
if val, exists := s[r.Label]; exists {
vals = append(vals, val)
}
}
}
sort.Strings(vals)
return &storepb.LabelValuesResponse{Values: vals}, nil
}

0 comments on commit 6c2ec33

Please sign in to comment.