export

package
v0.0.0-...-c684d4a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExportChannelSize = 4096
)

Variables

This section is empty.

Functions

func FilePathFromTarget

func FilePathFromTarget(target string) (string, error)

func GetBootTime

func GetBootTime() *time.Time

func GetHostName

func GetHostName() string

Types

type BatchRecord

type BatchRecord struct {
	Events []any `json:"events"`
}

type DiscardSink

type DiscardSink struct{}

func NewDiscardSink

func NewDiscardSink() *DiscardSink

func (*DiscardSink) Close

func (s *DiscardSink) Close() error

func (*DiscardSink) WriteBatch

func (s *DiscardSink) WriteBatch(_ context.Context, _ string, _ []any) error

type Exporter

type Exporter struct {
	Host string
	// contains filtered or unexported fields
}

func NewExporter

func NewExporter(ctx context.Context, target string) (*Exporter, error)

func (*Exporter) Close

func (e *Exporter) Close() error

func (*Exporter) IngestAgentEvent

func (e *Exporter) IngestAgentEvent(ctx context.Context, channel <-chan *RecordAgentEvent)

func (*Exporter) IngestEvents

func (e *Exporter) IngestEvents(ctx context.Context, endpoint string, producer func() ([]any, bool))

func (*Exporter) IngestExecEvent

func (e *Exporter) IngestExecEvent(ctx context.Context, channel <-chan *RawExec)

func (*Exporter) IngestFileOpEvent

func (e *Exporter) IngestFileOpEvent(ctx context.Context, channel <-chan *RawFileOp)

func (*Exporter) IngestPostgresEvent

func (e *Exporter) IngestPostgresEvent(ctx context.Context, channel <-chan *RawPostgres)

func (*Exporter) IngestRequestEvent

func (e *Exporter) IngestRequestEvent(ctx context.Context, channel <-chan *RawRequest)

func (*Exporter) IngestResponseEvent

func (e *Exporter) IngestResponseEvent(ctx context.Context, channel <-chan *RawResponse)

func (*Exporter) IngestStdIOEvent

func (e *Exporter) IngestStdIOEvent(ctx context.Context, channel <-chan *RawStdIO)

func (*Exporter) IngestTCPConnectEvent

func (e *Exporter) IngestTCPConnectEvent(ctx context.Context, channel <-chan *RawTCPConnect)

type GatewaySink

type GatewaySink struct {
	// contains filtered or unexported fields
}

func NewGatewaySink

func NewGatewaySink(ctx context.Context, baseURL string) (*GatewaySink, error)

func (*GatewaySink) Close

func (s *GatewaySink) Close() error

func (*GatewaySink) WriteBatch

func (s *GatewaySink) WriteBatch(ctx context.Context, endpoint string, events []any) error

type JSONLRecord

type JSONLRecord struct {
	Endpoint  string    `json:"endpoint"`
	Timestamp time.Time `json:"timestamp"`
	Event     any       `json:"event"`
}

type JSONLSink

type JSONLSink struct {
	// contains filtered or unexported fields
}

func NewJSONLSink

func NewJSONLSink(target string) (*JSONLSink, error)

func (*JSONLSink) Close

func (s *JSONLSink) Close() error

func (*JSONLSink) WriteBatch

func (s *JSONLSink) WriteBatch(_ context.Context, endpoint string, events []any) error

type MCP

type MCP struct {
	JSONRPC string          `json:"jsonrpc"`
	CorrID  int             `json:"id"`
	Result  json.RawMessage `json:"result"`
	Error   json.RawMessage `json:"error"`
	Params  json.RawMessage `json:"params"`
	Method  string          `json:"method"`
}

type RawExec

type RawExec struct {
	Timestamp time.Time
	Pid       uint32
	PPid      uint32
	ExecId    string
	PExecId   string
	Cwd       string
	Comm      string
	Args      string
	Docker    string
}

func (*RawExec) ToRecord

func (raw *RawExec) ToRecord(_ context.Context, host string) any

type RawFileOp

type RawFileOp struct {
	ElapsedNs uint64
	PidTGid   uint64
	UidGid    uint64
	CgroupID  uint64
	Comm      string
	Op        string
	Access    string
	Path      string
	NewPath   string
	Bytes     uint64
	Flags     uint64
	Create    bool
	Truncate  bool
	Append    bool
}

func (*RawFileOp) ToRecord

func (raw *RawFileOp) ToRecord(ctx context.Context, host string) any

type RawPostgres

type RawPostgres struct {
	ElapsedNs uint64
	PidTGid   uint64
	UidGid    uint64
	CgroupID  uint64
	Comm      string
	MsgType   string
	Data      []byte
}

func (*RawPostgres) ToRecord

func (raw *RawPostgres) ToRecord(ctx context.Context, host string) any

type RawRecord

type RawRecord interface {
	ToRecord(ctx context.Context, host string) any
}

type RawRequest

type RawRequest struct {
	ElapsedNs     uint64
	SessionKey    string
	PidTGid       uint64
	UidGid        uint64
	CgroupID      uint64
	Comm          string
	Method        string
	URL           string
	Protocol      string
	ContentLength int64
	Headers       map[string]string
	Body          []byte
	Truncated     bool
}

func (*RawRequest) ToRecord

func (raw *RawRequest) ToRecord(ctx context.Context, host string) any

type RawResponse

type RawResponse struct {
	ElapsedNs     uint64
	SessionKey    string
	PidTGid       uint64
	UidGid        uint64
	CgroupID      uint64
	Comm          string
	StatusCode    int
	Protocol      string
	ContentLength int64
	Headers       map[string]string
	Body          []byte
	Truncated     bool
}

func (*RawResponse) ToRecord

func (raw *RawResponse) ToRecord(ctx context.Context, host string) any

type RawStdIO

type RawStdIO struct {
	ElapsedNs   uint64
	PidTGid     uint64
	UidGid      uint64
	CgroupID    uint64
	MessageType string
	Data        []byte
}

func (*RawStdIO) ToRecord

func (raw *RawStdIO) ToRecord(ctx context.Context, host string) any

type RawTCPConnect

type RawTCPConnect struct {
	ElapsedNs  uint64
	PidTGid    uint64
	UidGid     uint64
	CgroupID   uint64
	Comm       string
	Family     uint16
	TargetAddr string
	TargetPort uint16
}

func (*RawTCPConnect) ToRecord

func (raw *RawTCPConnect) ToRecord(ctx context.Context, host string) any

type RecordAgentEvent

type RecordAgentEvent struct {
	Timestamp      time.Time       `json:"timestamp"`
	Tool           string          `json:"tool"`
	EventName      string          `json:"event_name"`
	EventType      string          `json:"event_type"`
	ConversationID string          `json:"conversation_id,omitempty"`
	SessionID      string          `json:"session_id,omitempty"`
	Model          string          `json:"model,omitempty"`
	Slug           string          `json:"slug,omitempty"`
	AppVersion     string          `json:"app_version,omitempty"`
	Host           string          `json:"host"`
	Attributes     json.RawMessage `json:"attributes"`

	Prompt       string `json:"prompt,omitempty"`
	PromptLength int64  `json:"prompt_length,omitempty"`

	ToolName   string `json:"tool_name,omitempty"`
	CallID     string `json:"call_id,omitempty"`
	Arguments  string `json:"arguments,omitempty"`
	Output     string `json:"output,omitempty"`
	Success    bool   `json:"success,omitempty"`
	DurationMs int64  `json:"duration_ms,omitempty"`
	Decision   string `json:"decision,omitempty"`

	StatusCode int64   `json:"status_code,omitempty"`
	CostUSD    float64 `json:"cost_usd,omitempty"`
	ErrorMsg   string  `json:"error,omitempty"`

	InputTokenCount     int64 `json:"input_token_count,omitempty"`
	OutputTokenCount    int64 `json:"output_token_count,omitempty"`
	CachedTokenCount    int64 `json:"cached_token_count,omitempty"`
	ReasoningTokenCount int64 `json:"reasoning_token_count,omitempty"`
}

func (*RecordAgentEvent) ToRecord

func (r *RecordAgentEvent) ToRecord(_ context.Context, host string) any

type RecordExec

type RecordExec struct {
	Timestamp   time.Time `json:"timestamp"`
	Pid         int32     `json:"pid"`
	PPid        int32     `json:"ppid"`
	ExecId      string    `json:"exec_id"`
	PExecId     string    `json:"p_exec_id"`
	Cwd         string    `json:"cwd"`
	Comm        string    `json:"comm"`
	Args        string    `json:"args"`
	Host        string    `json:"host"`
	ContainerID string    `json:"container_id"`
}

type RecordFileOp

type RecordFileOp struct {
	Timestamp   time.Time `json:"timestamp"`
	Pid         int32     `json:"pid"`
	Tid         int32     `json:"tid"`
	Uid         int32     `json:"uid"`
	Gid         int32     `json:"gid"`
	Host        string    `json:"host"`
	ContainerID string    `json:"container_id"`
	Comm        string    `json:"comm"`
	Op          string    `json:"op"`
	Access      string    `json:"access,omitempty"`
	Path        string    `json:"path"`
	NewPath     string    `json:"new_path,omitempty"`
	Bytes       uint64    `json:"bytes,omitempty"`
	Flags       uint64    `json:"flags,omitempty"`
	Create      bool      `json:"create,omitempty"`
	Truncate    bool      `json:"truncate,omitempty"`
	Append      bool      `json:"append,omitempty"`
}

type RecordPostgres

type RecordPostgres struct {
	Timestamp   time.Time `json:"timestamp"`
	Pid         int32     `json:"pid"`
	Tid         int32     `json:"tid"`
	Uid         int32     `json:"uid"`
	Gid         int32     `json:"gid"`
	Host        string    `json:"host"`
	ContainerID string    `json:"container_id"`
	Comm        string    `json:"comm"`
	Data        []byte    `json:"data"`
	MsgType     string    `json:"msg_type"`
}

type RecordRequest

type RecordRequest struct {
	Timestamp time.Time `json:"timestamp"`
	// SessionKey is a best-effort correlation key for an observed HTTP exchange.
	// It is normally created on the request side, but may be created on the response
	// side when the request was not successfully captured or emitted.
	SessionKey    string          `json:"session_key"`
	Pid           int32           `json:"pid"`
	Tid           int32           `json:"tid"`
	Uid           int32           `json:"uid"`
	Gid           int32           `json:"gid"`
	Comm          string          `json:"comm"`
	Method        string          `json:"method"`
	URL           string          `json:"url"`
	Protocol      string          `json:"protocol"`
	ContentLength int64           `json:"content_length"`
	Headers       json.RawMessage `json:"headers"`
	Body          []byte          `json:"body"`
	Truncated     bool            `json:"truncated"`
	Host          string          `json:"host"`
	ContainerID   string          `json:"container_id"`
}

type RecordResponse

type RecordResponse struct {
	Timestamp time.Time `json:"timestamp"`
	// SessionKey is a best-effort correlation key for an observed HTTP exchange.
	// A response may carry a SessionKey even when the matching request event was not emitted.
	SessionKey    string          `json:"session_key"`
	Pid           int32           `json:"pid"`
	Tid           int32           `json:"tid"`
	Uid           int32           `json:"uid"`
	Gid           int32           `json:"gid"`
	Comm          string          `json:"comm"`
	StatusCode    int32           `json:"status_code"`
	Protocol      string          `json:"protocol"`
	ContentLength int64           `json:"content_length"`
	Headers       json.RawMessage `json:"headers"`
	Body          []byte          `json:"body"`
	Truncated     bool            `json:"truncated"`
	Host          string          `json:"host"`
	ContainerID   string          `json:"container_id"`
}

type RecordStdIO

type RecordStdIO struct {
	Timestamp   time.Time       `json:"timestamp"`
	Pid         int32           `json:"pid"`
	Tid         int32           `json:"tid"`
	Uid         int32           `json:"uid"`
	Gid         int32           `json:"gid"`
	Host        string          `json:"host"`
	ContainerID string          `json:"container_id"`
	MessageType string          `json:"message_type"`
	JSONRPC     string          `json:"jsonrpc"`
	Method      string          `json:"method"`
	Params      json.RawMessage `json:"params"`
	Result      json.RawMessage `json:"result"`
	Error       json.RawMessage `json:"error"`
	CorrID      string          `json:"corr_id"`
}

type RecordTCPConnect

type RecordTCPConnect struct {
	Timestamp   time.Time `json:"timestamp"`
	Pid         int32     `json:"pid"`
	Tid         int32     `json:"tid"`
	Uid         int32     `json:"uid"`
	Gid         int32     `json:"gid"`
	Host        string    `json:"host"`
	ContainerID string    `json:"container_id"`
	Comm        string    `json:"comm"`
	Family      uint16    `json:"family"`
	TargetAddr  string    `json:"target_addr"`
	TargetPort  uint16    `json:"target_port"`
}

type Sink

type Sink interface {
	WriteBatch(ctx context.Context, endpoint string, events []any) error
	Close() error
}

func NewSink

func NewSink(ctx context.Context, target string) (Sink, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL