Documentation
¶
Index ¶
- Constants
- func AddStageEvents(span trace.Span, toolStartedAt time.Time, stages []StageRecord)
- func RecordStage(ctx context.Context, name Stage, startedAt time.Time, success bool)
- func TraceIdentifiers(parentCtx, activeCtx context.Context) (string, string)
- func WithExecution(ctx context.Context, startedAt time.Time) context.Context
- func WithSource(ctx context.Context, source Source) context.Context
- type DiagnosticCall
- type DiagnosticStage
- type ExecutionRecord
- type ProcessSnapshot
- type Recorder
- type Snapshot
- type Source
- type Stage
- type StageRecord
- type ToolStats
- type Tracing
Constants ¶
const DefaultRecentCapacity = 500
const MaxStagesPerExecution = 16
Variables ¶
This section is empty.
Functions ¶
func AddStageEvents ¶
func AddStageEvents(span trace.Span, toolStartedAt time.Time, stages []StageRecord)
CloseExecution 关闭当前调用的阶段收集并返回按开始时间排序的快照。 后续异步 Goroutine 的迟到打点会被忽略,避免 child stage 超出父 Tool 生命周期。 AddStageEvents projects the existing lightweight stage model into OpenTelemetry without creating another child-span tree. Event timestamps are the actual stage completion times derived from the parent Tool start.
func RecordStage ¶
RecordStage 记录固定枚举阶段。未知名称、缺失 execution 或已结束调用都会安全忽略。
func TraceIdentifiers ¶
TraceIdentifiers 返回当前 TraceID 与“本次调用实际创建的”SpanID。 默认 no-op tracer 会原样保留上游 SpanContext;这种情况下只关联 TraceID, 不把上游 SpanID 冒充成本地 child span。
func WithExecution ¶
WithExecution 为当前 Tool 调用附加本进程阶段收集状态。 该状态只在 Runtime.Call 生命周期内有效,不承担跨进程 tracing。
Types ¶
type DiagnosticCall ¶
type DiagnosticCall struct {
ID string `json:"id"`
Tool string `json:"tool"`
Source string `json:"source"`
TraceID string `json:"trace_id,omitempty"`
StartedAt time.Time `json:"started_at"`
DurationMS float64 `json:"duration_ms"`
Success bool `json:"success"`
ErrorCode string `json:"error_code,omitempty"`
ErrorCategory string `json:"error_category,omitempty"`
Stages []DiagnosticStage `json:"stages,omitempty"`
}
DiagnosticCall 是 Nexus 远程诊断消费的最小调用视图。 不包含 SpanID、参数、结果、命令、路径、错误正文或其他 Payload。
func ProjectDiagnostics ¶
func ProjectDiagnostics(records []ExecutionRecord) []DiagnosticCall
ProjectDiagnostics 把本地运行分析模型裁剪成稳定的远程诊断契约。
type DiagnosticStage ¶
type DiagnosticStage struct {
Name string `json:"name"`
StartedOffsetMS float64 `json:"started_offset_ms"`
DurationMS float64 `json:"duration_ms"`
Success bool `json:"success"`
}
DiagnosticStage 是远程诊断允许跨进程暴露的阶段字段。 它有意与 StageRecord 分离,避免未来给本地阶段模型增加字段时扩大远程契约。
type ExecutionRecord ¶
type ExecutionRecord struct {
ID uint64 `json:"id"`
Tool string `json:"tool"`
Source Source `json:"source"`
TraceID string `json:"trace_id,omitempty"`
SpanID string `json:"span_id,omitempty"`
StartedAt time.Time `json:"started_at"`
DurationMS float64 `json:"duration_ms"`
Success bool `json:"success"`
ErrorCode string `json:"error_code,omitempty"`
ErrorCategory string `json:"error_category,omitempty"`
Stages []StageRecord `json:"stages,omitempty"`
}
ExecutionRecord 是运行分析保存的最小工具调用元数据。 这里有意不包含参数、结果、错误正文或路径等 Payload。
type ProcessSnapshot ¶
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
func NewRecorder ¶
func (*Recorder) RecentCalls ¶
func (r *Recorder) RecentCalls() []ExecutionRecord
RecentCalls 返回当前内存环里最近调用的独立副本,不计算百分位或进程指标。
type Snapshot ¶
type Snapshot struct {
StartedAt time.Time `json:"started_at"`
RecentCapacity int `json:"recent_capacity"`
WindowCalls int `json:"window_calls"`
TotalCalls uint64 `json:"total_calls"`
TotalErrors uint64 `json:"total_errors"`
ActiveCalls int `json:"active_calls"`
ToolStats []ToolStats `json:"tool_stats"`
RecentCalls []ExecutionRecord `json:"recent_calls"`
Process ProcessSnapshot `json:"process"`
}
type Source ¶
type Source string
Source 标识一次工具调用进入 Runtime 的传输来源。 来源只允许固定枚举,避免把任意请求数据带入观测记录。
func SourceFromContext ¶
type StageRecord ¶
type StageRecord struct {
Name Stage `json:"name"`
StartedOffsetMS float64 `json:"started_offset_ms"`
DurationMS float64 `json:"duration_ms"`
Success bool `json:"success"`
}
StageRecord 只描述一次 Tool 调用中的固定阶段耗时。 不允许记录参数、结果、命令、路径、错误正文或其他 Payload。
func CloseExecution ¶
func CloseExecution(ctx context.Context) []StageRecord
type Tracing ¶
type Tracing struct {
// contains filtered or unexported fields
}
Tracing 只持有 OpenTelemetry API 层的 Tracer。 默认使用 no-op 实现,不创建 SDK Provider,也不拥有采样、导出或 Shutdown 生命周期。