Skip to content

Commit

Permalink
fix: do not fail the whole query if one versions query failed
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno committed Apr 14, 2024
1 parent 978f934 commit 8860907
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions pkg/queriers/versions/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,33 +57,32 @@ func (v *Querier) Get() ([]metrics.MetricInfo, []query_info.QueryInfo) {
if err != nil {
v.Logger.Err(err).Msg("Could not get latest Git version")
return []metrics.MetricInfo{}, queriesInfo
} else {
// stripping first "v" character: "v1.2.3" => "1.2.3"
if latestVersion[0] == 'v' {
latestVersion = latestVersion[1:]
}

metricsInfos = append(metricsInfos, metrics.MetricInfo{
MetricName: metrics.MetricNameRemoteVersion,
Labels: map[string]string{"version": latestVersion},
Value: 1,
})
}

// stripping first "v" character: "v1.2.3" => "1.2.3"
if latestVersion[0] == 'v' {
latestVersion = latestVersion[1:]
}

metricsInfos = append(metricsInfos, metrics.MetricInfo{
MetricName: metrics.MetricNameRemoteVersion,
Labels: map[string]string{"version": latestVersion},
Value: 1,
})
}

if v.Cosmovisor != nil {
versionInfo, cosmovisorVersionQueryInfo, err = v.Cosmovisor.GetVersion()
queriesInfo = append(queriesInfo, cosmovisorVersionQueryInfo)
if err != nil {
v.Logger.Err(err).Msg("Could not get app version")
return []metrics.MetricInfo{}, queriesInfo
} else {
metricsInfos = append(metricsInfos, metrics.MetricInfo{
MetricName: metrics.MetricNameLocalVersion,
Labels: map[string]string{"version": versionInfo.Version},
Value: 1,
})
}

metricsInfos = append(metricsInfos, metrics.MetricInfo{
MetricName: metrics.MetricNameLocalVersion,
Labels: map[string]string{"version": versionInfo.Version},
Value: 1,
})
}

if v.GitClient != nil && v.Cosmovisor != nil {
Expand Down

0 comments on commit 8860907

Please sign in to comment.