Documentation
¶
Overview ¶
Package agentanalytics implements the BigQuery Agent Analytics Plugin.
Index ¶
- func ArrowSchema() *arrow.Schema
- func EventsSchema() bq.Schema
- func FormatContentParts(content *genai.Content, maxLength int) []map[string]any
- func NewBigQueryAgentAnalyticsPlugin(ctx context.Context, projectID string, datasetID string, tableID string) (*baseplugin.Plugin, error)
- func NewBigQueryAgentAnalyticsPluginWithClients(ctx context.Context, config Config, bqClient *bq.Client, ...) (*baseplugin.Plugin, error)
- func NewBigQueryAgentAnalyticsPluginWithConfig(ctx context.Context, config Config) (*baseplugin.Plugin, error)
- func SerializedArrowSchema() ([]byte, error)
- func SmartTruncate(obj any, maxLength int) ([]byte, bool, error)
- type BatchProcessor
- type Config
- type Logger
- type RetryConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArrowSchema ¶
ArrowSchema returns the Arrow schema for the events table.
func EventsSchema ¶
EventsSchema returns the BigQuery schema for the events table.
func FormatContentParts ¶
FormatContentParts formats Content parts into a map array for BigQuery logging.
func NewBigQueryAgentAnalyticsPlugin ¶
func NewBigQueryAgentAnalyticsPlugin( ctx context.Context, projectID string, datasetID string, tableID string, ) (*baseplugin.Plugin, error)
NewBigQueryAgentAnalyticsPlugin creates a newly configured analytics plugin with default config.
func NewBigQueryAgentAnalyticsPluginWithClients ¶
func NewBigQueryAgentAnalyticsPluginWithClients( ctx context.Context, config Config, bqClient *bq.Client, writeClient *bqstorage.BigQueryWriteClient, ) (*baseplugin.Plugin, error)
NewBigQueryAgentAnalyticsPluginWithClients creates a newly configured analytics plugin using the provided BigQuery clients.
func NewBigQueryAgentAnalyticsPluginWithConfig ¶
func NewBigQueryAgentAnalyticsPluginWithConfig( ctx context.Context, config Config, ) (*baseplugin.Plugin, error)
NewBigQueryAgentAnalyticsPluginWithConfig creates a newly configured analytics plugin.
func SerializedArrowSchema ¶
SerializedArrowSchema returns the serialized Arrow schema for the events table.
Types ¶
type BatchProcessor ¶
type BatchProcessor struct {
// contains filtered or unexported fields
}
BatchProcessor handles asynchronous batching and writing of events to BigQuery.
func NewBatchProcessor ¶
func NewBatchProcessor(ctx context.Context, writeClient *bqstorage.BigQueryWriteClient, streamName string, config Config) (*BatchProcessor, error)
NewBatchProcessor creates a new BatchProcessor instance.
func (*BatchProcessor) Append ¶
func (b *BatchProcessor) Append(row map[string]any)
Append adds a row to the processor queue asynchronously.
func (*BatchProcessor) Close ¶
func (b *BatchProcessor) Close()
Close gracefully shuts down the processing loop, flushes, and stops.
func (*BatchProcessor) Start ¶
func (b *BatchProcessor) Start()
Start begins the background goroutine to process and flush the queue periodically.
type Config ¶
type Config struct {
Enabled bool
ProjectID string
DatasetID string
TableName string
MaxContentLen int
BatchSize int
BatchFlushIntv time.Duration
QueueMaxSize int
ClientOptions []option.ClientOption
// Fields to cluster the table by.
ClusteringFields []string
CustomTags map[string]any
// Whether to log multi-modal content.
LogMultiModalContent bool
// Max time to wait for shutdown.
ShutdownTimeout time.Duration
// Injected logger.
Logger Logger
// Retry configuration for appending rows.
RetryConfig RetryConfig
}
Config represents settings mapping to BigQueryLoggerConfig.java.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default configuration for the agent analytics plugin.