agentanalytics

package module
v0.0.0-...-60216c0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package agentanalytics implements the BigQuery Agent Analytics Plugin.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrowSchema

func ArrowSchema() *arrow.Schema

ArrowSchema returns the Arrow schema for the events table.

func EventsSchema

func EventsSchema() bq.Schema

EventsSchema returns the BigQuery schema for the events table.

func FormatContentParts

func FormatContentParts(content *genai.Content, maxLength int) []map[string]any

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

func SerializedArrowSchema() ([]byte, error)

SerializedArrowSchema returns the serialized Arrow schema for the events table.

func SmartTruncate

func SmartTruncate(obj any, maxLength int) ([]byte, bool, error)

SmartTruncate recursively truncates long strings inside a map or slice and returns JSON bytes.

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.

type Logger

type Logger interface {
	Printf(format string, v ...any)
	Println(v ...any)
}

Logger interface to use standard log operations natively.

type RetryConfig

type RetryConfig struct {
	MaxRetries   int
	InitialDelay time.Duration
	MaxDelay     time.Duration
	Multiplier   float64
}

RetryConfig holds retry parameters for operations like BigQuery Appends.