Некоторые проверки не удались
CI / test (push) Successful in 2m5s
Docker / Build and publish worker image (push) Failing after 31s
53 строки
1.6 KiB
Go
53 строки
1.6 KiB
Go
package llmhttp
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"rocketgit.ru/rsmon/worker/app/models"
|
|
"rocketgit.ru/rsmon/worker/internal/checkresult"
|
|
)
|
|
|
|
// Result is a result of an LLM HTTP health check
|
|
type Result struct {
|
|
checkresult.CheckResult
|
|
|
|
// Captured data
|
|
HTML string `json:"html"` // HTML content
|
|
URL string `json:"url"` // Final URL after redirects
|
|
StatusCode int `json:"status_code"` // HTTP status code
|
|
Title string `json:"title"` // Page title (extracted from HTML)
|
|
ContentLength int64 `json:"content_length"` // Size of response body
|
|
ContentType string `json:"content_type"` // Content-Type header
|
|
|
|
// LLM analysis
|
|
LLMResponse string `json:"llm_response"` // Full LLM response
|
|
LLMVerdict string `json:"llm_verdict"` // "normal", "error", "warning"
|
|
LLMReasoning string `json:"llm_reasoning"` // LLM's explanation
|
|
|
|
// Metadata
|
|
CheckID uint `json:"check_id"` // For database reference
|
|
}
|
|
|
|
// InfluxTags provides functionality.
|
|
func (r *Result) InfluxTags(c models.Check) map[string]string { //nolint:gocritic // hugeParam: accepted for interface compatibility
|
|
ret := make(map[string]string, 0)
|
|
ret["check"] = strconv.FormatInt(c.ID, 10)
|
|
ret["state"] = r.State
|
|
ret["code"] = strconv.Itoa(r.StatusCode)
|
|
if r.Error != nil {
|
|
ret["error"] = r.Error.Error()
|
|
}
|
|
ret["warnings"] = strings.Join(r.Warnings, ",")
|
|
return ret
|
|
}
|
|
|
|
// InfluxFields provides functionality.
|
|
func (r *Result) InfluxFields() map[string]interface{} {
|
|
ret := make(map[string]interface{}, 0)
|
|
ret["took"] = int64(r.Duration / time.Millisecond)
|
|
|
|
return ret
|
|
}
|