Documentation
¶
Index ¶
- Variables
- func BeginObservation(ctx context.Context, meta captelemetry.ObservationMeta) (context.Context, func(captelemetry.ObservationEnd))
- func BeginTurn(ctx context.Context, meta captelemetry.TurnMeta) (context.Context, func(captelemetry.TurnEnd))
- func EnrichEventAttrs(ctx context.Context, attrs map[string]string) map[string]string
- func ExporterFrom(ctx context.Context) captelemetry.Exporter
- func FormatMessage(msg agentkit.ModelMessage) string
- func LLMCompletionStarted(ev agentkit.LLMEvent) bool
- func LLMTextStarted(ev agentkit.LLMEvent) bool
- func ObservationMetaFromContext(ctx context.Context, meta captelemetry.ObservationMeta) captelemetry.ObservationMeta
- func ParentObservationIDFrom(ctx context.Context) string
- func PreparePayload(raw string, maxBytes int, redact bool) string
- func RecordEvent(ctx context.Context, name string, attrs map[string]string)
- func RecordTurnOutput(ctx context.Context, msg agentkit.ModelMessage)
- func RecordTurnSteps(ctx context.Context, steps int)
- func RecordTurnStopReason(ctx context.Context, reason string)
- func RecordTurnUsage(ctx context.Context, usage captelemetry.Usage)
- func RedactJSON(raw string) string
- func ScopeParentFrom(ctx context.Context) string
- func SummarizeMessage(msg agentkit.ModelMessage) string
- func SummarizeMessages(messages []agentkit.ModelMessage, maxBytes int, redact bool) string
- func ToolNamesFromSpecs(specs []agentkit.ToolSpec) []string
- func ToolParentFrom(ctx context.Context) string
- func TruncatePayload(raw string, maxBytes int) string
- func TurnEndFromAccum(ctx context.Context) captelemetry.TurnEnd
- func TurnIDFrom(ctx context.Context) string
- func WithExporter(ctx context.Context, exp captelemetry.Exporter) context.Context
- func WithParentObservationID(ctx context.Context, observationID string) context.Context
- func WithScopeParent(ctx context.Context, observationID string) context.Context
- func WithToolParent(ctx context.Context, observationID string) context.Context
- func WithTurnAccum(ctx context.Context) context.Context
- func WithTurnID(ctx context.Context, turnID string) context.Context
- func WrapOutboundEmit(ctx context.Context, emit agentkit.OutboundEmit) agentkit.OutboundEmit
- type RecordedEvent
- type RecordedObservation
- type RecordedTurn
- type RecordingExporter
- func (r *RecordingExporter) BeginObservation(ctx context.Context, meta captelemetry.ObservationMeta) (context.Context, func(captelemetry.ObservationEnd))
- func (r *RecordingExporter) BeginTurn(ctx context.Context, meta captelemetry.TurnMeta) (context.Context, func(captelemetry.TurnEnd))
- func (r *RecordingExporter) Flush(context.Context) error
- func (r *RecordingExporter) RecordEvent(_ context.Context, name string, attrs map[string]string)
- func (r *RecordingExporter) Shutdown(context.Context) error
- func (r *RecordingExporter) Snapshot() (turns []RecordedTurn, observations []RecordedObservation, ...)
Constants ¶
This section is empty.
Variables ¶
var Noop captelemetry.Exporter = noopExporter{}
Noop is the default exporter that discards all telemetry.
Functions ¶
func BeginObservation ¶
func BeginObservation(ctx context.Context, meta captelemetry.ObservationMeta) (context.Context, func(captelemetry.ObservationEnd))
BeginObservation starts a nested observation on the exporter stored in ctx.
func BeginTurn ¶
func BeginTurn(ctx context.Context, meta captelemetry.TurnMeta) (context.Context, func(captelemetry.TurnEnd))
BeginTurn starts a turn on the exporter stored in ctx.
func EnrichEventAttrs ¶
EnrichEventAttrs adds agent_id and session_id from ctx when missing.
func ExporterFrom ¶
func ExporterFrom(ctx context.Context) captelemetry.Exporter
ExporterFrom returns the exporter on ctx, or Noop when unset.
func FormatMessage ¶
func FormatMessage(msg agentkit.ModelMessage) string
FormatMessage JSON-encodes a model message for trace input/output display.
func LLMCompletionStarted ¶
LLMCompletionStarted reports whether ev is the first model-produced output from an LLM stream: text, thinking, tool call, or a one-shot message.
func LLMTextStarted ¶
LLMTextStarted reports whether ev is the first user-visible text or thinking delta.
func ObservationMetaFromContext ¶
func ObservationMetaFromContext(ctx context.Context, meta captelemetry.ObservationMeta) captelemetry.ObservationMeta
ObservationMetaFromContext fills agent and session ids from ctx when unset.
func ParentObservationIDFrom ¶
ParentObservationIDFrom is an alias for ToolParentFrom.
func PreparePayload ¶
PreparePayload applies optional redaction and truncation for exporter payloads.
func RecordEvent ¶
RecordEvent records a point-in-time event on the active trace.
func RecordTurnOutput ¶
func RecordTurnOutput(ctx context.Context, msg agentkit.ModelMessage)
RecordTurnOutput appends one final assistant reply to the turn trace output.
func RecordTurnSteps ¶
RecordTurnSteps records how many model steps completed in the active turn.
func RecordTurnStopReason ¶
RecordTurnStopReason records why the turn stopped.
func RecordTurnUsage ¶
func RecordTurnUsage(ctx context.Context, usage captelemetry.Usage)
RecordTurnUsage adds one step's token usage to the active turn total.
func RedactJSON ¶
RedactJSON scrubs sensitive keys from JSON objects before export.
func ScopeParentFrom ¶
ScopeParentFrom returns the active scope parent observation id when present.
func SummarizeMessage ¶
func SummarizeMessage(msg agentkit.ModelMessage) string
SummarizeMessage returns a compact text summary of a model message.
func SummarizeMessages ¶
func SummarizeMessages(messages []agentkit.ModelMessage, maxBytes int, redact bool) string
SummarizeMessages JSON-encodes a message list for exporter input.
func ToolNamesFromSpecs ¶
ToolNamesFromSpecs returns tool names exposed to the model for one step.
func ToolParentFrom ¶
ToolParentFrom returns the active tool parent observation id when present.
func TruncatePayload ¶
TruncatePayload limits payload size for external export.
func TurnEndFromAccum ¶
func TurnEndFromAccum(ctx context.Context) captelemetry.TurnEnd
TurnEndFromAccum reads accumulated turn output and usage for trace closure.
func TurnIDFrom ¶
TurnIDFrom returns the active turn id when present.
func WithExporter ¶
WithExporter stores an exporter on the context for downstream runtime code.
func WithParentObservationID ¶
WithParentObservationID is an alias for WithToolParent.
func WithScopeParent ¶
WithScopeParent marks the span that should parent nested generations.
func WithToolParent ¶
WithToolParent marks the observation that should parent nested tool spans.
func WithTurnAccum ¶
WithTurnAccum stores per-turn output and usage accumulators on ctx.
func WithTurnID ¶
WithTurnID stores the active turn id for slog and exporter correlation.
func WrapOutboundEmit ¶
func WrapOutboundEmit(ctx context.Context, emit agentkit.OutboundEmit) agentkit.OutboundEmit
WrapOutboundEmit records user-visible outbound events on the active turn trace.
Types ¶
type RecordedEvent ¶
type RecordedObservation ¶
type RecordedObservation struct {
ID string
Meta captelemetry.ObservationMeta
End captelemetry.ObservationEnd
ParentID string
}
type RecordedTurn ¶
type RecordedTurn struct {
Meta captelemetry.TurnMeta
End captelemetry.TurnEnd
}
type RecordingExporter ¶
type RecordingExporter struct {
Turns []RecordedTurn
Observations []RecordedObservation
Events []RecordedEvent
FlushCalls int
ShutdownCalls int
// contains filtered or unexported fields
}
RecordingExporter captures telemetry calls for tests.
func (*RecordingExporter) BeginObservation ¶
func (r *RecordingExporter) BeginObservation(ctx context.Context, meta captelemetry.ObservationMeta) (context.Context, func(captelemetry.ObservationEnd))
func (*RecordingExporter) BeginTurn ¶
func (r *RecordingExporter) BeginTurn(ctx context.Context, meta captelemetry.TurnMeta) (context.Context, func(captelemetry.TurnEnd))
func (*RecordingExporter) RecordEvent ¶
func (*RecordingExporter) Snapshot ¶
func (r *RecordingExporter) Snapshot() (turns []RecordedTurn, observations []RecordedObservation, events []RecordedEvent)