Add advice as a trace option to spot checks (#12105)

* Add advice as a trace option to spot checks

* typo

* Collect advice when forming the tree
This commit is contained in:
Scott Miller 2021-07-15 18:01:51 -05:00 committed by GitHub
parent 53759228b0
commit 555eb2ae0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 8 deletions

View File

@ -552,8 +552,8 @@ SEALFAIL:
err = findClusterAddress(server, &coreConfig, config, disableClustering)
if err != nil {
diagnose.Advise(ctx, "Please check that the API and Cluster addresses are different, and that the API, Cluster and Redirect addresses have both a host and port.")
return diagnose.SpotError(ctx, "Check Cluster Address", fmt.Errorf("Cluster Address could not be determined or was invalid: %w.", err))
return diagnose.SpotError(ctx, "Check Cluster Address", fmt.Errorf("Cluster Address could not be determined or was invalid: %w.", err),
diagnose.Advice("Please check that the API and Cluster addresses are different, and that the API, Cluster and Redirect addresses have both a host and port."))
}
diagnose.SpotOk(ctx, "Check Cluster Address", "Cluster address is logically valid and can be found.")

View File

@ -31,11 +31,11 @@ partLoop:
Warn(ctx, fmt.Sprintf("Could not obtain partition usage for %s: %v.", partition.Mountpoint, err))
} else {
if usage.UsedPercent > 95 {
SpotWarn(ctx, testName, fmt.Sprintf(partition.Mountpoint+" is %d percent full.", usage.UsedPercent))
Advise(ctx, "It is recommended to have more than five percent of the partition free.")
SpotWarn(ctx, testName, fmt.Sprintf(partition.Mountpoint+" is %d percent full.", usage.UsedPercent),
Advice("It is recommended to have more than five percent of the partition free."))
} else if usage.Free < 2<<30 {
SpotWarn(ctx, testName, partition.Mountpoint+" has %d bytes full.")
Advise(ctx, "It is recommended to have at least 1 GB of space free per partition.")
SpotWarn(ctx, testName, partition.Mountpoint+" has %d bytes full.",
Advice("It is recommended to have at least 1 GB of space free per partition."))
} else {
SpotOk(ctx, testName, partition.Mountpoint+" usage ok.")
}

View File

@ -24,8 +24,8 @@ func OSChecks(ctx context.Context) {
min = limit.Max
}
if min <= 1024 {
SpotWarn(ctx, fileLimitsName, fmt.Sprintf("Open file limits are set to %d", min))
Advise(ctx, "These limits may be insufficient. We recommend raising the soft and hard limits to 1024768.")
SpotWarn(ctx, fileLimitsName, fmt.Sprintf("Open file limits are set to %d", min),
Advice("These limits may be insufficient. We recommend raising the soft and hard limits to 1024768."))
} else {
SpotOk(ctx, fileLimitsName, fmt.Sprintf("Open file limits are set to %d.", min))
}

View File

@ -210,6 +210,7 @@ func (t *TelemetryCollector) getOrBuildResult(id trace.SpanID) *Result {
Status: OkStatus,
Message: message,
Time: e.Time,
Advice: findAttribute(e, adviceKey),
})
}
case spotCheckWarnEventName:
@ -221,6 +222,7 @@ func (t *TelemetryCollector) getOrBuildResult(id trace.SpanID) *Result {
Status: WarningStatus,
Message: message,
Time: e.Time,
Advice: findAttribute(e, adviceKey),
})
}
case spotCheckErrorEventName:
@ -232,6 +234,7 @@ func (t *TelemetryCollector) getOrBuildResult(id trace.SpanID) *Result {
Status: ErrorStatus,
Message: message,
Time: e.Time,
Advice: findAttribute(e, adviceKey),
})
}
case spotCheckSkippedEventName:
@ -243,6 +246,7 @@ func (t *TelemetryCollector) getOrBuildResult(id trace.SpanID) *Result {
Status: SkippedStatus,
Message: message,
Time: e.Time,
Advice: findAttribute(e, adviceKey),
})
}
case adviceEventName:
@ -274,6 +278,15 @@ func (t *TelemetryCollector) getOrBuildResult(id trace.SpanID) *Result {
return r
}
func findAttribute(e trace.Event, attr attribute.Key) string {
for _, a := range e.Attributes {
if a.Key == attr {
return a.Value.AsString()
}
}
return ""
}
func findAttributes(e trace.Event, attr1, attr2 attribute.Key) (string, string) {
var av1, av2 string
for _, a := range e.Attributes {