Sub2API v1.0 - AI API 网关(二开初始版本,基于上游 Wei-Shaw/sub2api)
Release / update-version (push) Has been cancelled
Release / build-frontend (push) Has been cancelled
Release / release (push) Has been cancelled
Release / sync-version-file (push) Has been cancelled
CI / shell (push) Canceled after 0s
CI / test (push) Canceled after 0s
CI / frontend (push) Canceled after 0s
CI / golangci-lint (push) Canceled after 0s
Security Scan / backend-security (push) Canceled after 0s
Security Scan / frontend-security (push) Canceled after 0s
Release / update-version (push) Has been cancelled
Release / build-frontend (push) Has been cancelled
Release / release (push) Has been cancelled
Release / sync-version-file (push) Has been cancelled
CI / shell (push) Canceled after 0s
CI / test (push) Canceled after 0s
CI / frontend (push) Canceled after 0s
CI / golangci-lint (push) Canceled after 0s
Security Scan / backend-security (push) Canceled after 0s
Security Scan / frontend-security (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package openai_ws_v2
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
// MetricsSnapshot 是 OpenAI WS v2 passthrough 路径的轻量运行时指标快照。
|
||||
type MetricsSnapshot struct {
|
||||
SemanticMutationTotal int64 `json:"semantic_mutation_total"`
|
||||
UsageParseFailureTotal int64 `json:"usage_parse_failure_total"`
|
||||
}
|
||||
|
||||
var (
|
||||
// passthrough 路径默认不会做语义改写,该计数通常应保持为 0(保留用于未来防御性校验)。
|
||||
passthroughSemanticMutationTotal atomic.Int64
|
||||
passthroughUsageParseFailureTotal atomic.Int64
|
||||
)
|
||||
|
||||
func recordUsageParseFailure() {
|
||||
passthroughUsageParseFailureTotal.Add(1)
|
||||
}
|
||||
|
||||
// SnapshotMetrics 返回当前 passthrough 指标快照。
|
||||
func SnapshotMetrics() MetricsSnapshot {
|
||||
return MetricsSnapshot{
|
||||
SemanticMutationTotal: passthroughSemanticMutationTotal.Load(),
|
||||
UsageParseFailureTotal: passthroughUsageParseFailureTotal.Load(),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user