Documentation
¶
Overview ¶
Package obs provides a unified observability layer for Go applications, integrating structured logging, metrics, and distributed tracing via OpenTelemetry.
It offers simple, high-level APIs to initialize and use telemetry components without exposing underlying complexity. Ideal for microservices and cloud-native apps.
Index ¶
- type ActionType
- type RecordEntry
- type RecordMode
- type RecordRequest
- type RecordResponse
- type Sink
- func (r *Sink) Close()
- func (r *Sink) GetBaseDir() string
- func (r *Sink) IsEnabled() bool
- func (r *Sink) Record(provider, model string, req *RecordRequest, resp *RecordResponse, ...)
- func (r *Sink) RecordWithMetadata(provider, model string, req *RecordRequest, resp *RecordResponse, ...)
- func (r *Sink) RecordWithScenario(provider, model, scenario string, req *RecordRequest, resp *RecordResponse, ...)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionType ¶
type ActionType = string
ActionType represents the type of action performed
const ( ActionAddProvider ActionType = "add_provider" ActionDeleteProvider ActionType = "delete_provider" ActionUpdateProvider ActionType = "update_provider" ActionStartServer ActionType = "start_server" ActionStopServer ActionType = "stop_server" ActionRestartServer ActionType = "restart_server" ActionGenerateToken ActionType = "generate_token" ActionUpdateDefaults ActionType = "update_defaults" ActionFetchModels ActionType = "fetch_models" )
type RecordEntry ¶
type RecordEntry struct {
Timestamp string `json:"timestamp"`
RequestID string `json:"request_id"`
Provider string `json:"provider"`
Scenario string `json:"scenario,omitempty"` // Scenario: openai, anthropic, claude_code, etc.
Model string `json:"model"`
Request *RecordRequest `json:"request"`
Response *RecordResponse `json:"response"`
DurationMs int64 `json:"duration_ms"`
Error string `json:"error,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
RecordEntry represents a single recorded request/response pair
type RecordMode ¶
type RecordMode string
RecordMode defines the recording mode
const ( RecordModeAll RecordMode = "all" // Record both request and response RecordModeResponse RecordMode = "response" // Record only response RecordModeScenario RecordMode = "scenario" RecordModeSlim RecordMode = "slim" // TODO: Not implemented yet )
type RecordRequest ¶
type RecordRequest struct {
Method string `json:"method"`
URL string `json:"url"`
Headers map[string]string `json:"headers"`
Body map[string]interface{} `json:"body,omitempty"`
}
RecordRequest represents the HTTP request details
type RecordResponse ¶
type RecordResponse struct {
StatusCode int `json:"status_code"`
Headers map[string]string `json:"headers"`
Body map[string]interface{} `json:"body,omitempty"`
// Streaming support
IsStreaming bool `json:"is_streaming,omitempty"`
StreamChunks []string `json:"-"` // Parsed SSE data chunks
}
RecordResponse represents the HTTP response details
type Sink ¶
type Sink struct {
// contains filtered or unexported fields
}
Sink manages recording of HTTP requests/responses to JSONL files
func NewSink ¶
func NewSink(baseDir string, mode RecordMode) *Sink
NewSink creates a new record sink mode: empty string = disabled, "all" = record all, "response" = response only
func (*Sink) GetBaseDir ¶
GetBaseDir returns the base directory for recordings
func (*Sink) Record ¶
func (r *Sink) Record(provider, model string, req *RecordRequest, resp *RecordResponse, duration time.Duration, err error)
Record records a single request/response pair
func (*Sink) RecordWithMetadata ¶
func (r *Sink) RecordWithMetadata(provider, model string, req *RecordRequest, resp *RecordResponse, duration time.Duration, metadata map[string]interface{}, err error)
RecordWithMetadata records a request/response with additional metadata
func (*Sink) RecordWithScenario ¶
func (r *Sink) RecordWithScenario(provider, model, scenario string, req *RecordRequest, resp *RecordResponse, duration time.Duration, err error)
RecordWithScenario records a request/response with scenario information Uses scenario-based file naming (e.g., claude_code-{date}.jsonl)