Skip to content

Commit

Permalink
Merge branch 'main' into moremetrics
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jul 30, 2024
2 parents 08a7138 + 22bfbf3 commit d75524e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/frontend/mysql_cmd_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2664,6 +2664,16 @@ func doComQuery(ses *Session, execCtx *ExecCtx, input *UserInput) (retErr error)
ses.SetSql(input.getSql())
input.genHash()

sqlLen := len(input.getSql())
if sqlLen != 0 {
v2.TotalSQLLengthHistogram.Observe(float64(sqlLen))
if strings.HasPrefix(input.sql, "LOAD DATA INLINE") {
v2.LoadDataInlineSQLLengthHistogram.Observe(float64(sqlLen))
} else {
v2.OtherSQLLengthHistogram.Observe(float64(sqlLen))
}
}

//the ses.GetUserName returns the user_name with the account_name.
//here,we only need the user_name.
userNameOnly := rootName
Expand Down
22 changes: 22 additions & 0 deletions pkg/util/metric/v2/dashboard/grafana_dashboard_frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func (c *DashboardCreator) initFrontendDashboard() error {
c.initFrontendRoutineAndRequestCount(),
c.initFrontendResolveDuration(),
c.initFrontendCreateAccount(),
c.initFrontendSQLLength(),
)...)
if err != nil {
return err
Expand Down Expand Up @@ -164,3 +165,24 @@ func (c *DashboardCreator) initFrontendCreateAccount() dashboard.Option {
axis.Min(0))...,
)
}

func (c *DashboardCreator) initFrontendSQLLength() dashboard.Option {
return dashboard.Row(
"Input SQL Length",
c.getMultiHistogram(
[]string{
c.getMetricWithFilter(`mo_frontend_sql_length_bucket`, `label="total-sql-length"`),
c.getMetricWithFilter(`mo_frontend_sql_length_bucket`, `label="load-data-inline-sql-length"`),
c.getMetricWithFilter(`mo_frontend_sql_length_bucket`, `label="other-sql-length""`),
},
[]string{
"total-sql-length",
"load-data-inline-sql-length",
"other-sql-length",
},
[]float64{0.50, 0.8, 0.90, 0.99},
[]float32{3, 3, 3, 3},
axis.Unit("s"),
axis.Min(0))...,
)
}
13 changes: 13 additions & 0 deletions pkg/util/metric/v2/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,17 @@ var (
InitData1DurationHistogram = createAccountDurationHistogram.WithLabelValues("init-data1")
CreateTablesInSystemDurationHistogram = createAccountDurationHistogram.WithLabelValues("create-tables-in-system")
CreateTablesInInfoSchemaDurationHistogram = createAccountDurationHistogram.WithLabelValues("create-tables-in-info-schema")

sqlLengthHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: "mo",
Subsystem: "frontend",
Name: "input_sql_length",
Help: "Bucketed histogram of Input SQL Length",
Buckets: getDurationBuckets(),
}, []string{"label"})

TotalSQLLengthHistogram = sqlLengthHistogram.WithLabelValues("total-sql-length")
LoadDataInlineSQLLengthHistogram = sqlLengthHistogram.WithLabelValues("load-data-inline-sql-length")
OtherSQLLengthHistogram = sqlLengthHistogram.WithLabelValues("other-sql-length")
)
1 change: 1 addition & 0 deletions pkg/util/metric/v2/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ func initFrontendMetrics() {
registry.MustRegister(requestCounter)
registry.MustRegister(resolveDurationHistogram)
registry.MustRegister(createAccountDurationHistogram)
registry.MustRegister(sqlLengthHistogram)
}

func initPipelineMetrics() {
Expand Down

0 comments on commit d75524e

Please sign in to comment.