Files
apinto/entries/monitor-entry/label.go
Liujian 2a0e090f44 1. 修复自动重定向插件bug
2. loki新增输出字段
3. influxdb新增输出字段
2025-05-06 17:48:24 +08:00

44 lines
1.0 KiB
Go

package monitor_entry
import http_context "github.com/eolinker/eosc/eocontext/http-context"
var (
LabelApi = "api"
LabelApp = "app"
LabelUpstream = "upstream"
LabelHandler = "handler"
LabelProvider = "provider"
LabelAPIKind = "api_kind"
LabelStatusCode = "status_code"
)
var labels = map[string]string{
LabelApi: "api",
LabelApp: "application",
LabelHandler: "handler",
LabelUpstream: "service",
LabelProvider: "provider",
LabelAPIKind: "api_kind",
LabelStatusCode: "status_code",
}
type GetLabel func(ctx http_context.IHttpContext) string
var readLabel = map[string]GetLabel{
"status_code": func(ctx http_context.IHttpContext) string {
statusCode := ctx.Response().StatusCode()
switch {
case statusCode >= 200 && statusCode < 300:
return "2xx"
case statusCode >= 300 && statusCode < 400:
return "3xx"
case statusCode >= 400 && statusCode < 500:
return "4xx"
case statusCode >= 500 && statusCode < 600:
return "5xx"
default:
return "other"
}
},
}