Documentation
¶
Index ¶
- func Attach(mux goahttp.Muxer, service *Service)
- func EmitHTTPRequestLog(ctx context.Context, logger *slog.Logger, provider ToolMetricsProvider, ...)
- type PosthogClient
- type Service
- func (s *Service) APIKeyAuth(ctx context.Context, key string, schema *security.APIKeyScheme) (context.Context, error)
- func (s *Service) CaptureEvent(ctx context.Context, payload *telem_gen.CaptureEventPayload) (res *telem_gen.CaptureEventResult, err error)
- func (s *Service) JWTAuth(ctx context.Context, token string, schema *security.JWTScheme) (context.Context, error)
- func (s *Service) ListLogs(ctx context.Context, payload *gen.ListLogsPayload) (res *gen.ListToolLogResponse, err error)
- func (s *Service) ListToolExecutionLogs(ctx context.Context, payload *gen.ListToolExecutionLogsPayload) (res *gen.ListToolExecutionLogsResult, err error)
- func (s *Service) SearchLogs(ctx context.Context, payload *telem_gen.SearchLogsPayload) (res *telem_gen.SearchLogsResult, err error)
- func (s *Service) SearchToolCalls(ctx context.Context, payload *telem_gen.SearchToolCallsPayload) (res *telem_gen.SearchToolCallsResult, err error)
- type StubToolMetricsClient
- func (n *StubToolMetricsClient) InsertTelemetryLog(_ context.Context, _ repo.InsertTelemetryLogParams) error
- func (n *StubToolMetricsClient) ListHTTPRequests(_ context.Context, _ repo.ListToolLogsOptions) (*repo.ListResult, error)
- func (n *StubToolMetricsClient) ListLogsForTrace(_ context.Context, _ repo.ListLogsForTraceParams) ([]repo.TelemetryLog, error)
- func (n *StubToolMetricsClient) ListTelemetryLogs(_ context.Context, _ repo.ListTelemetryLogsParams) ([]repo.TelemetryLog, error)
- func (n *StubToolMetricsClient) ListToolLogs(_ context.Context, _ repo.ListToolLogsParams) (*repo.ToolLogsListResult, error)
- func (n *StubToolMetricsClient) ListTraces(_ context.Context, _ repo.ListTracesParams) ([]repo.TraceSummary, error)
- func (n *StubToolMetricsClient) LogHTTPRequest(_ context.Context, _ repo.ToolHTTPRequest) error
- type ToolCallLogRoundTripper
- type ToolCallLogger
- type ToolInfo
- type ToolMetricsProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EmitHTTPRequestLog ¶
func EmitHTTPRequestLog( ctx context.Context, logger *slog.Logger, provider ToolMetricsProvider, toolName string, request repo.ToolHTTPRequest, )
EmitHTTPRequestLog logs the provided HTTP request using the tool metrics provider. Errors are reported through the supplied logger. Logging happens asynchronously to avoid blocking the caller and the request struct is copied to prevent data races.
Types ¶
type PosthogClient ¶
type PosthogClient interface {
CaptureEvent(ctx context.Context, eventName string, distinctID string, eventProperties map[string]interface{}) error
}
PosthogClient defines the interface for capturing events in PostHog.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(logger *slog.Logger, db *pgxpool.Pool, sessions *sessions.Manager, chatSessions *chatsessions.Manager, tcm ToolMetricsProvider, features *productfeatures.Client, posthogClient PosthogClient) *Service
func (*Service) APIKeyAuth ¶
func (*Service) CaptureEvent ¶
func (s *Service) CaptureEvent(ctx context.Context, payload *telem_gen.CaptureEventPayload) (res *telem_gen.CaptureEventResult, err error)
CaptureEvent captures a telemetry event and forwards it to PostHog.
func (*Service) ListLogs ¶
func (s *Service) ListLogs(ctx context.Context, payload *gen.ListLogsPayload) (res *gen.ListToolLogResponse, err error)
func (*Service) ListToolExecutionLogs ¶
func (s *Service) ListToolExecutionLogs(ctx context.Context, payload *gen.ListToolExecutionLogsPayload) (res *gen.ListToolExecutionLogsResult, err error)
func (*Service) SearchLogs ¶
func (s *Service) SearchLogs(ctx context.Context, payload *telem_gen.SearchLogsPayload) (res *telem_gen.SearchLogsResult, err error)
SearchLogs retrieves unified telemetry logs with pagination.
func (*Service) SearchToolCalls ¶
func (s *Service) SearchToolCalls(ctx context.Context, payload *telem_gen.SearchToolCallsPayload) (res *telem_gen.SearchToolCallsResult, err error)
SearchToolCalls retrieves tool call summaries with pagination.
type StubToolMetricsClient ¶
type StubToolMetricsClient struct{}
func (*StubToolMetricsClient) InsertTelemetryLog ¶
func (n *StubToolMetricsClient) InsertTelemetryLog(_ context.Context, _ repo.InsertTelemetryLogParams) error
func (*StubToolMetricsClient) ListHTTPRequests ¶
func (n *StubToolMetricsClient) ListHTTPRequests(_ context.Context, _ repo.ListToolLogsOptions) (*repo.ListResult, error)
func (*StubToolMetricsClient) ListLogsForTrace ¶
func (n *StubToolMetricsClient) ListLogsForTrace(_ context.Context, _ repo.ListLogsForTraceParams) ([]repo.TelemetryLog, error)
func (*StubToolMetricsClient) ListTelemetryLogs ¶
func (n *StubToolMetricsClient) ListTelemetryLogs(_ context.Context, _ repo.ListTelemetryLogsParams) ([]repo.TelemetryLog, error)
func (*StubToolMetricsClient) ListToolLogs ¶
func (n *StubToolMetricsClient) ListToolLogs(_ context.Context, _ repo.ListToolLogsParams) (*repo.ToolLogsListResult, error)
func (*StubToolMetricsClient) ListTraces ¶
func (n *StubToolMetricsClient) ListTraces(_ context.Context, _ repo.ListTracesParams) ([]repo.TraceSummary, error)
func (*StubToolMetricsClient) LogHTTPRequest ¶
func (n *StubToolMetricsClient) LogHTTPRequest(_ context.Context, _ repo.ToolHTTPRequest) error
type ToolCallLogRoundTripper ¶
type ToolCallLogRoundTripper struct {
// contains filtered or unexported fields
}
ToolCallLogRoundTripper wraps an http.RoundTripper and logs HTTP requests to ClickHouse
func NewToolCallLogRoundTripper ¶
func NewToolCallLogRoundTripper(rt http.RoundTripper, logger *slog.Logger, tracer trace.Tracer, toolInfo *ToolInfo, toolLogger ToolCallLogger) *ToolCallLogRoundTripper
NewToolCallLogRoundTripper creates a new RoundTripper that logs HTTP requests to ClickHouse
type ToolCallLogger ¶
type ToolCallLogger interface {
Enabled() bool
Emit(ctx context.Context, logger *slog.Logger)
RecordDurationMs(durationMs float64)
RecordHTTPServerURL(url string)
RecordHTTPMethod(method string)
RecordHTTPRoute(route string)
RecordStatusCode(code int)
RecordUserAgent(agent string)
RecordRequestHeaders(headers map[string]string, isSensitive bool)
RecordResponseHeaders(headers map[string]string)
RecordRequestBodyBytes(bytes int64)
RecordResponseBodyBytes(bytes int64)
}
ToolCallLogger represents a logging strategy for tool HTTP requests. Implementations may be backed by a real ToolHTTPRequest or behave as no-ops.
func NewNoopToolCallLogger ¶
func NewNoopToolCallLogger() ToolCallLogger
NewNoopToolCallLogger creates a ToolCallLogger that drops all logging information.
func NewToolCallLogger ¶
func NewToolCallLogger( ctx context.Context, provider ToolMetricsProvider, featuresClient *productfeatures.Client, organizationID string, info ToolInfo, toolName string, toolType repo.ToolType, ) (ToolCallLogger, error)
NewToolCallLogger returns a ToolCallLogger that records tool calls when logging is enabled for the organization; otherwise it returns a no-op logger. When an error occurs while preparing the logger, a no-op logger is returned alongside the error.
type ToolInfo ¶
type ToolInfo struct {
ID string
Urn string
Name string
ProjectID string
DeploymentID string
OrganizationID string
}
ToolInfo represents the minimal tool information needed for logging
type ToolMetricsProvider ¶
type ToolMetricsProvider interface {
// List tool call logs
ListHTTPRequests(ctx context.Context, opts repo.ListToolLogsOptions) (*repo.ListResult, error)
// List structured tool logs
ListToolLogs(ctx context.Context, params repo.ListToolLogsParams) (*repo.ToolLogsListResult, error)
// List unified telemetry logs (new OTel-based table)
ListTelemetryLogs(ctx context.Context, params repo.ListTelemetryLogsParams) ([]repo.TelemetryLog, error)
// List trace summaries for distributed tracing
ListTraces(ctx context.Context, params repo.ListTracesParams) ([]repo.TraceSummary, error)
// List all logs for a specific trace ID
ListLogsForTrace(ctx context.Context, params repo.ListLogsForTraceParams) ([]repo.TelemetryLog, error)
// Log tool call request/response
LogHTTPRequest(context.Context, repo.ToolHTTPRequest) error
// Insert telemetry log
InsertTelemetryLog(ctx context.Context, params repo.InsertTelemetryLogParams) error
}
ToolMetricsProvider defines the interface for tool metrics operations.