Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/sources/shared/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ ui:
# CLI flag: -ui.goldfish.max-idle-time
[max_idle_time: <int> | default = 300]

[grafana_url: <string> | default = ""]

[traces_datasource_uid: <string> | default = ""]

[logs_datasource_uid: <string> | default = ""]

[cell_a_namespace: <string> | default = ""]

[cell_b_namespace: <string> | default = ""]

discovery:
# List of peers to join the cluster. Supports multiple values separated by
# commas. Each value can be a hostname, an IP address, or a DNS name (A/AAAA
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ require (

require (
github.com/Azure/go-autorest/autorest v0.11.30
github.com/DATA-DOG/go-sqlmock v1.5.2
github.com/DataDog/sketches-go v1.4.7
github.com/DmitriyVTitov/size v1.5.0
github.com/IBM/go-sdk-core/v5 v5.21.0
Expand Down
3 changes: 0 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Code-Hex/go-generics-cache v1.5.1 h1:6vhZGc5M7Y/YD8cIUcY8kcuQLB4cHR7U+0KMqAA0KcU=
github.com/Code-Hex/go-generics-cache v1.5.1/go.mod h1:qxcC9kRVrct9rHeiYpFWSoW1vxyillCVzX13KZG8dl4=
github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU=
github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DataDog/sketches-go v1.4.7 h1:eHs5/0i2Sdf20Zkj0udVFWuCrXGRFig2Dcfm5rtcTxc=
github.com/DataDog/sketches-go v1.4.7/go.mod h1:eAmQ/EBmtSO+nQp7IZMZVRPT4BQTmIc5RZQ+deGlTPM=
Expand Down Expand Up @@ -836,7 +834,6 @@ github.com/keybase/go-keychain v0.0.1/go.mod h1:PdEILRW3i9D8JcdM+FmY6RwkHGnhHxXw
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE=
github.com/klauspost/asmfmt v1.3.2 h1:4Ri7ox3EwapiOjCki+hw14RyKk201CN4rzyCJRFLpK4=
github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
Expand Down
30 changes: 30 additions & 0 deletions pkg/goldfish/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package goldfish

// StorageConfig defines storage backend configuration
type StorageConfig struct {
Type string `yaml:"type"` // "cloudsql", "rds", "mysql", or empty string for no storage

// Direct MySQL connection
MySQLHost string `yaml:"mysql_host"`
MySQLPort int `yaml:"mysql_port"`
MySQLDatabase string `yaml:"mysql_database"`
MySQLUser string `yaml:"mysql_user"`
// MySQLPassword provided via GOLDFISH_DB_PASSWORD environment variable

// CloudSQL specific (via proxy)
CloudSQLHost string `yaml:"cloudsql_host"`
CloudSQLPort int `yaml:"cloudsql_port"`
CloudSQLDatabase string `yaml:"cloudsql_database"`
CloudSQLUser string `yaml:"cloudsql_user"`
// CloudSQLPassword provided via GOLDFISH_DB_PASSWORD environment variable

// RDS specific
RDSEndpoint string `yaml:"rds_endpoint"` // e.g., "mydb.123456789012.us-east-1.rds.amazonaws.com:3306"
RDSDatabase string `yaml:"rds_database"`
RDSUser string `yaml:"rds_user"`
// RDSPassword provided via GOLDFISH_DB_PASSWORD environment variable

// Common settings
MaxConnections int `yaml:"max_connections"`
MaxIdleTime int `yaml:"max_idle_time_seconds"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ DROP INDEX idx_sampled_queries_time ON sampled_queries;
DROP INDEX idx_sampled_queries_tenant ON sampled_queries;

DROP TABLE IF EXISTS comparison_outcomes;
DROP TABLE IF EXISTS sampled_queries;
DROP TABLE IF EXISTS sampled_queries;
42 changes: 42 additions & 0 deletions pkg/goldfish/migrations/20250805000001_performance_indexes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
-- +goose Up
-- Add performance indexes for goldfish query optimization

-- Composite index for the main query pattern (ORDER BY sampled_at DESC with joins)
CREATE INDEX idx_sampled_queries_sampled_at_desc ON sampled_queries(sampled_at DESC, correlation_id);

-- Index for status computation (covers the CASE expression fields)
CREATE INDEX idx_sampled_queries_status_computation ON sampled_queries(
cell_a_status_code,
cell_b_status_code,
cell_a_response_hash,
cell_b_response_hash
);

-- Covering index for frequently accessed columns (reduces table lookups)
-- Note: TEXT columns (query) cannot be included in covering indexes
CREATE INDEX idx_sampled_queries_covering ON sampled_queries(
correlation_id,
sampled_at DESC,
tenant_id,
query_type,
start_time,
end_time,
cell_a_status_code,
cell_b_status_code,
cell_a_response_hash,
cell_b_response_hash
);

-- Index for comparison_outcomes join performance
CREATE INDEX idx_comparison_outcomes_correlation_status ON comparison_outcomes(
correlation_id,
comparison_status
);

-- +goose Down
-- Remove performance indexes

DROP INDEX idx_comparison_outcomes_correlation_status ON comparison_outcomes;
DROP INDEX idx_sampled_queries_covering ON sampled_queries;
DROP INDEX idx_sampled_queries_status_computation ON sampled_queries;
DROP INDEX idx_sampled_queries_sampled_at_desc ON sampled_queries;
26 changes: 26 additions & 0 deletions pkg/goldfish/storage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package goldfish

import (
"context"
)

// Storage defines the interface for storing and retrieving query samples and comparison results
type Storage interface {
// Write operations (used by querytee)
StoreQuerySample(ctx context.Context, sample *QuerySample) error
StoreComparisonResult(ctx context.Context, result *ComparisonResult) error

// Read operations (used by UI)
GetSampledQueries(ctx context.Context, page, pageSize int, outcome string) (*APIResponse, error)

// Lifecycle
Close() error
}

// APIResponse represents the paginated API response for UI
type APIResponse struct {
Queries []QuerySample `json:"queries"`
Total int `json:"total"`
Page int `json:"page"`
PageSize int `json:"pageSize"`
}
Loading
Loading