Skip to content

Commit

Permalink
Merge branch 'master' into keyviz/merge-cold
Browse files Browse the repository at this point in the history
  • Loading branch information
HunDunDM authored Jul 14, 2020
2 parents 264451a + 6f58636 commit 75841d1
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 34 deletions.
2 changes: 1 addition & 1 deletion cmd/tidb-dashboard/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func NewCLIConfig() *DashboardCLIConfig {
flag.StringVar(&cfg.CoreConfig.DataDir, "data-dir", "/tmp/dashboard-data", "path to the Dashboard Server data directory")
flag.StringVar(&cfg.CoreConfig.PublicPathPrefix, "path-prefix", config.DefaultPublicPathPrefix, "public URL path prefix for reverse proxies")
flag.StringVar(&cfg.CoreConfig.PDEndPoint, "pd", "http://127.0.0.1:2379", "PD endpoint address that Dashboard Server connects to")
flag.BoolVar(&cfg.CoreConfig.DisableTelemetry, "disable-telemetry", false, "disable client to report data")
flag.BoolVar(&cfg.CoreConfig.EnableTelemetry, "enable-telemetry", true, "enable client to report data for analysis")

showVersion := flag.BoolP("version", "v", false, "print version information and exit")

Expand Down
10 changes: 4 additions & 6 deletions pkg/apiserver/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ func Register(r *gin.RouterGroup, auth *user.AuthService, s *Service) {
}

type InfoResponse struct { //nolint:golint
Version *version.Info `json:"version"`
PDEndPoint string `json:"pd_end_point"`
DisableTelemetry bool `json:"disable_telemetry"`
Version *version.Info `json:"version"`
EnableTelemetry bool `json:"enable_telemetry"`
}

// @Summary Dashboard info
Expand All @@ -62,9 +61,8 @@ type InfoResponse struct { //nolint:golint
// @Failure 401 {object} utils.APIError "Unauthorized failure"
func (s *Service) infoHandler(c *gin.Context) {
resp := InfoResponse{
Version: version.GetInfo(),
PDEndPoint: s.config.PDEndPoint,
DisableTelemetry: s.config.DisableTelemetry,
Version: version.GetInfo(),
EnableTelemetry: s.config.EnableTelemetry,
}
c.JSON(http.StatusOK, resp)
}
Expand Down
24 changes: 14 additions & 10 deletions pkg/apiserver/logsearch/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,20 @@ func NewService(lc fx.Lifecycle, config *config.Config, db *dbstore.DB) *Service

func Register(r *gin.RouterGroup, auth *user.AuthService, s *Service) {
endpoint := r.Group("/logs")

endpoint.GET("/download", s.DownloadLogs)
endpoint.GET("/download/acquire_token", auth.MWAuthRequired(), s.GetDownloadToken)
endpoint.PUT("/taskgroup", auth.MWAuthRequired(), s.CreateTaskGroup)
endpoint.GET("/taskgroups", auth.MWAuthRequired(), s.GetAllTaskGroups)
endpoint.GET("/taskgroups/:id", auth.MWAuthRequired(), s.GetTaskGroup)
endpoint.GET("/taskgroups/:id/preview", auth.MWAuthRequired(), s.GetTaskGroupPreview)
endpoint.POST("/taskgroups/:id/retry", auth.MWAuthRequired(), s.RetryTask)
endpoint.POST("/taskgroups/:id/cancel", auth.MWAuthRequired(), s.CancelTask)
endpoint.DELETE("/taskgroups/:id", auth.MWAuthRequired(), s.DeleteTaskGroup)
{
endpoint.GET("/download", s.DownloadLogs)
endpoint.Use(auth.MWAuthRequired())
{
endpoint.GET("/download/acquire_token", s.GetDownloadToken)
endpoint.PUT("/taskgroup", s.CreateTaskGroup)
endpoint.GET("/taskgroups", s.GetAllTaskGroups)
endpoint.GET("/taskgroups/:id", s.GetTaskGroup)
endpoint.GET("/taskgroups/:id/preview", s.GetTaskGroupPreview)
endpoint.POST("/taskgroups/:id/retry", s.RetryTask)
endpoint.POST("/taskgroups/:id/cancel", s.CancelTask)
endpoint.DELETE("/taskgroups/:id", s.DeleteTaskGroup)
}
}
}

type CreateTaskGroupRequest struct {
Expand Down
16 changes: 10 additions & 6 deletions pkg/apiserver/slowquery/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,16 @@ func QuerySlowLogList(db *gorm.DB, req *GetListRequest) ([]Base, error) {

if req.Text != "" {
lowerStr := strings.ToLower(req.Text)
tx = tx.Where("txn_start_ts REGEXP ? OR LOWER(digest) REGEXP ? OR LOWER(CONVERT(prev_stmt USING utf8)) REGEXP ? OR LOWER(CONVERT(query USING utf8)) REGEXP ?",
lowerStr,
lowerStr,
lowerStr,
lowerStr,
)
arr := strings.Fields(lowerStr)
for _, v := range arr {
tx = tx.Where(
`txn_start_ts REGEXP ?
OR LOWER(digest) REGEXP ?
OR LOWER(CONVERT(prev_stmt USING utf8)) REGEXP ?
OR LOWER(CONVERT(query USING utf8)) REGEXP ?`,
v, v, v, v,
)
}
}

if len(req.DB) > 0 {
Expand Down
19 changes: 11 additions & 8 deletions pkg/apiserver/statement/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,17 @@ func QueryStatementsOverview(

if len(text) > 0 {
lowerText := strings.ToLower(text)
query = query.Where(
`LOWER(digest_text) REGEXP ?
OR LOWER(digest) REGEXP ?
OR LOWER(schema_name) REGEXP ?
OR LOWER(table_names) REGEXP ?
OR LOWER(plan) REGEXP ?`,
lowerText, lowerText, lowerText, lowerText, lowerText,
)
arr := strings.Fields(lowerText)
for _, v := range arr {
query = query.Where(
`LOWER(digest_text) REGEXP ?
OR LOWER(digest) REGEXP ?
OR LOWER(schema_name) REGEXP ?
OR LOWER(table_names) REGEXP ?
OR LOWER(plan) REGEXP ?`,
v, v, v, v, v,
)
}
}

err = query.Find(&result).Error
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ type Config struct {
// TLS config for mTLS authentication between TiDB and MySQL client.
TiDBTLSConfig *tls.Config

// Disable client to report data for analysis
DisableTelemetry bool
// Enable client to report data for analysis
EnableTelemetry bool
}

func (c *Config) NormalizePDEndPoint() error {
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/utils/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function init(info: InfoInfoResponse) {
mixpanel.init(token, options)
// disable mixpanel to report data immediately
mixpanel.opt_out_tracking()
if (info?.disable_telemetry === false) {
if (info?.enable_telemetry) {
mixpanel.register({
$current_url: getPathInLocationHash(),
})
Expand Down

0 comments on commit 75841d1

Please sign in to comment.