Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
fix some linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pnickolov committed Oct 7, 2021
1 parent 4e6de25 commit 520095c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cmd/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ func analyzeApp(app *appmodel.App) {
}

// perform risk assessment
riskCautions := []string{}
var riskCautions []string
o.ReliabilityRisk, riskCautions = riskAssessment(app)
o.Cautions = append(o.Cautions, riskCautions...)

Expand Down
2 changes: 1 addition & 1 deletion math/round.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
m "math"
)

// round to whole numbers or up to 4 significant digits
// MagicRound rounds to whole numbers or up to 4 significant digits
func MagicRound(x float64) float64 {
if x == 0 {
return 0
Expand Down
2 changes: 1 addition & 1 deletion sources/prometheus/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func collectContainersInfo(ctx context.Context, promApi v1.API, app *appmodel.Ap
rxRate, warnings, err := getRangedMetric(ctx, promApi, app, timeRange, containerRxPacketsTemplate, &selectors)
allWarnings = handleWarnErr(allWarnings, warnings, err, app, "Received packets rate")
txRate, warnings, err := getRangedMetric(ctx, promApi, app, timeRange, containerTxPacketsTemplate, &selectors)
allWarnings = handleWarnErr(allWarnings, warnings, err, app, "Received packets rate")
allWarnings = handleWarnErr(allWarnings, warnings, err, app, "Transmitted packets rate")
if rxRate != nil {
app.Metrics.PacketReceiveRate = opsmath.MagicRound(*rxRate)
}
Expand Down
16 changes: 8 additions & 8 deletions sources/prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ func getAggregateMetric(ctx context.Context, promApi v1.API, app *appmodel.App,
defer cancel()

// prepare query string
pod_re := fmt.Sprintf("%v-.*", app.Metadata.Workload) // pod naming template is <deployment_name>-<pod_spec_hash>-<pod_unique_id> - TODO: tighten RE to avoid unlikelyconflicts
query := fmt.Sprintf("%v(%v{namespace=%q,pod=~%q})", aggrFunc, metric, app.Metadata.Namespace, pod_re)
podRE := fmt.Sprintf("%v-.*", app.Metadata.Workload) // pod naming template is <deployment_name>-<pod_spec_hash>-<pod_unique_id> - TODO: tighten RE to avoid unlikelyconflicts
query := fmt.Sprintf("%v(%v{namespace=%q,pod=~%q})", aggrFunc, metric, app.Metadata.Namespace, podRE)

// Collect values
result, warnings, err := promApi.QueryRange(ctx, query, timeRange)
Expand Down Expand Up @@ -232,28 +232,28 @@ func collectDeploymentDetails(ctx context.Context, promApi v1.API, app *appmodel
}

// collect usage
cpu_used, warnings, err := getRangedMetric(ctx, promApi, app, timeRange, cpuUtilizationTemplate, &selectors)
cpuUsed, warnings, err := getRangedMetric(ctx, promApi, app, timeRange, cpuUtilizationTemplate, &selectors)
if err != nil {
log.Errorf("Error querying Prometheus for CPU utilization %v: %v\n", app.Metadata, err)
} else {
if len(warnings) > 0 {
allWarnings = append(allWarnings, warnings...)
log.Warnf("Warnings during cpu utilization collection: %v\n", warnings)
}
if cpu_used != nil {
app.Metrics.CpuUtilization = *cpu_used
if cpuUsed != nil {
app.Metrics.CpuUtilization = *cpuUsed
}
}
memory_used, warnings, err := getRangedMetric(ctx, promApi, app, timeRange, memoryUtilizationTemplate, &selectors)
memoryUsed, warnings, err := getRangedMetric(ctx, promApi, app, timeRange, memoryUtilizationTemplate, &selectors)
if err != nil {
log.Errorf("Error querying Prometheus for memory utilization %v: %v\n", app.Metadata, err)
} else {
if len(warnings) > 0 {
allWarnings = append(allWarnings, warnings...)
log.Warnf("Warnings during memory utilization collection: %v\n", warnings)
}
if memory_used != nil {
app.Metrics.MemoryUtilization = *memory_used
if memoryUsed != nil {
app.Metrics.MemoryUtilization = *memoryUsed
}
}

Expand Down

0 comments on commit 520095c

Please sign in to comment.