Documentation
¶
Overview ¶
Package trace provides execution tracing and audit logging.
Index ¶
- func WithParentSpan(ctx context.Context, spanID string) context.Context
- func WithTraceID(ctx context.Context, traceID string) context.Context
- type Collector
- func (c *Collector) Audit(ctx context.Context, sessionID, actor, action, resource string) error
- func (c *Collector) EndSpan(ctx context.Context, t *storage.Trace, output any, errMsg string) error
- func (c *Collector) StartSpan(ctx context.Context, sessionID, name, kind string) (*storage.Trace, error)
- type OTelCollector
- func (c *OTelCollector) EndSpan(span *OTelSpan, err error)
- func (c *OTelCollector) Flush() []*OTelSpan
- func (c *OTelCollector) SetEnabled(enabled bool)
- func (c *OTelCollector) Spans() []*OTelSpan
- func (c *OTelCollector) StartSpan(ctx context.Context, name, kind string, attrs map[string]any) *OTelSpan
- type OTelSpan
- type SpanEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithParentSpan ¶ added in v0.3.0
WithParentSpan adds a parent span ID to the context.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector records traces and audit events.
func NewCollector ¶
type OTelCollector ¶ added in v0.3.0
type OTelCollector struct {
// contains filtered or unexported fields
}
OTelCollector collects OpenTelemetry-compatible spans and exports them to a configured endpoint. It supports proper parent-child relationships and attributes for agent, graph, tool, and model operations.
func NewOTelCollector ¶ added in v0.3.0
func NewOTelCollector(endpoint string) *OTelCollector
NewOTelCollector creates a new OTel-compatible span collector. endpoint is the OTLP endpoint to export spans to (empty = collect only, no export).
func (*OTelCollector) EndSpan ¶ added in v0.3.0
func (c *OTelCollector) EndSpan(span *OTelSpan, err error)
EndSpan completes a span, setting its end time and status.
func (*OTelCollector) Flush ¶ added in v0.3.0
func (c *OTelCollector) Flush() []*OTelSpan
Flush returns all spans and clears the collector.
func (*OTelCollector) SetEnabled ¶ added in v0.3.0
func (c *OTelCollector) SetEnabled(enabled bool)
SetEnabled enables or disables span collection.
func (*OTelCollector) Spans ¶ added in v0.3.0
func (c *OTelCollector) Spans() []*OTelSpan
Spans returns all collected spans.
type OTelSpan ¶ added in v0.3.0
type OTelSpan struct {
TraceID string `json:"trace_id"`
SpanID string `json:"span_id"`
ParentID string `json:"parent_id,omitempty"`
Name string `json:"name"`
Kind string `json:"kind"` // agent, graph, tool, model
Attributes map[string]any `json:"attributes,omitempty"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time,omitempty"`
Status string `json:"status"` // ok, error, unset
Events []SpanEvent `json:"events,omitempty"`
}
OTelSpan represents an OpenTelemetry-compatible span.