Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
systay committed Sep 12, 2024
1 parent c83cb44 commit f1aa806
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 16 deletions.
6 changes: 0 additions & 6 deletions go/logstats/logstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ type (
SessionUUID string
CachedPlan bool
ActiveKeyspace string // ActiveKeyspace is the selected keyspace `use ks`
PrimitiveStats map[int]PrimitiveStats
}

PrimitiveStats struct {
NoOfCalls int
Rows []int
}
)

Expand Down
8 changes: 6 additions & 2 deletions go/vt/vtgate/engine/fake_vcursor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ func (t *noopVCursor) UnresolvedTransactions(ctx context.Context, keyspace strin
panic("implement me")
}

func (t *noopVCursor) EnableOperatorTracing() {}
func (t *noopVCursor) EnableOperatorTracing() func() map[int]PrimitiveStats {
panic("implement me")
}

func (t *noopVCursor) SetExec(ctx context.Context, name string, value string) error {
panic("implement me")
Expand Down Expand Up @@ -876,7 +878,9 @@ func (f *loggingVCursor) UnresolvedTransactions(_ context.Context, _ string) ([]
return f.transactionStatusOutput, nil
}

func (f *loggingVCursor) EnableOperatorTracing() {}
func (f *loggingVCursor) EnableOperatorTracing() func() map[int]PrimitiveStats {
panic("implement me")
}

// SQLParser implements VCursor
func (t *loggingVCursor) SQLParser() *sqlparser.Parser {
Expand Down
9 changes: 8 additions & 1 deletion go/vt/vtgate/engine/primitive.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,14 @@ type (
// UnresolvedTransactions reads the state of all the unresolved atomic transactions in the given keyspace.
UnresolvedTransactions(ctx context.Context, keyspace string) ([]*querypb.TransactionMetadata, error)

EnableOperatorTracing()
// EnableOperatorTracing enables operator tracing for the current session
// the returned function should be called after the query is done to get the operator stats
EnableOperatorTracing() func() map[int]PrimitiveStats
}

PrimitiveStats struct {
NoOfCalls int
Rows []int
}

// SessionActions gives primitives ability to interact with the session state
Expand Down
5 changes: 3 additions & 2 deletions go/vt/vtgate/engine/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ func (t *Trace) GetTableName() string {
}

func (t *Trace) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) {
vcursor.EnableOperatorTracing()
return t.Inner.GetFields(ctx, vcursor, bindVars)
getter := vcursor.EnableOperatorTracing()

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_migrate_vdiff2_convert_tz)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_basic)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_suite)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_stress_suite)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_stress)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / End-to-End Test (Race)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_foreign_key_stress)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_partial_movetables_and_materialize)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_unsharded)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (12)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (15)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_multi_tenant)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtctlbackup_sharded_clustertest_heavy)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_godriver)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / End-to-End Test

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_schema)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (21)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_reservedconn)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_vschema)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_readafterwrite)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_transaction)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Unit Test (Evalengine_Race)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_vindex_heavy)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (ers_prs_newfeatures_heavy)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_gen4)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_queries)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (mysql80)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_foreignkey_stress)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (backup_pitr)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_across_db_versions)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_v2)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_general_heavy)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_schema_tracker)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (schemadiff_vrepl)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vttablet_prscomplex)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_tablet_healthcheck_cache)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (topo_connection_cache)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo_etcd)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_copy_parallel)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtbackup)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Local example using zk2 on ubuntu-22.04

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_tablegc)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Region Sharding example using etcd on ubuntu-22.04

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_consul)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_partial_keyspace)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_throttler_topo)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Local example using consul on ubuntu-22.04

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run Semi Sync Upgrade Downgrade Test

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (13)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_cellalias)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_mariadb_to_mysql)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (18)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Unit Test (Race)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_concurrentdml)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo_consul)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_revert)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Code Coverage

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Local example using etcd on ubuntu-22.04

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - E2E

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_scheduler)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vstream)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (backup_pitr_xtrabackup)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - Manual

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (mysql_server_vault)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Unit Test (evalengine_mysql57)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Unit Test (mysql80)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old VTTablet

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (xb_backup)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (xb_recovery)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Online DDL flow

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Unit Test (mysql84)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old Vtctl

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Vitess Tester (vtgate)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtorc)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Unit Test (evalengine_mysql84)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Unit Test (evalengine_mysql80)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Unit Test (mysql57)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl)

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 10

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

declared and not used: getter) (typecheck)

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

declared and not used: getter) (typecheck)

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

declared and not used: getter

Check failure on line 46 in go/vt/vtgate/engine/trace.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

declared and not used: getter
fields, err := t.Inner.GetFields(ctx, vcursor, bindVars)
return fields, err
}

func (t *Trace) NeedsTransaction() bool {
Expand Down
14 changes: 9 additions & 5 deletions go/vt/vtgate/vcursor_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ type vcursorImpl struct {
warmingReadsChannel chan bool

resultsObserver resultsObserver
primitiveStats map[int]engine.PrimitiveStats
}

// newVcursorImpl creates a vcursorImpl. Before creating this object, you have to separate out any marginComments that came with
Expand Down Expand Up @@ -520,12 +521,12 @@ func (vc *vcursorImpl) ExecutePrimitive(ctx context.Context, primitive engine.Pr
}

func (vc *vcursorImpl) logOpTraffic(primitive engine.Primitive, res *sqltypes.Result) {
if vc.logStats.LogOpStats() {
if vc.primitiveStats != nil {
key := int(primitive.GetID())
stats := vc.logStats.PrimitiveStats[key]
stats := vc.primitiveStats[key]
stats.NoOfCalls++
stats.Rows = append(stats.Rows, len(res.Rows))
vc.logStats.PrimitiveStats[key] = stats
vc.primitiveStats[key] = stats
}
}

Expand Down Expand Up @@ -1511,6 +1512,9 @@ func (vc *vcursorImpl) GetForeignKeyChecksState() *bool {
return vc.fkChecksState
}

func (vc *vcursorImpl) EnableOperatorTracing() {
vc.logStats.EnableOpStats()
func (vc *vcursorImpl) EnableOperatorTracing() func() map[int]engine.PrimitiveStats {
vc.primitiveStats = map[int]engine.PrimitiveStats{}
return func() map[int]engine.PrimitiveStats {
return vc.primitiveStats
}
}

0 comments on commit f1aa806

Please sign in to comment.