Skip to content

Td monitor db ce #3053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 28, 2025
Merged

Td monitor db ce #3053

merged 6 commits into from
May 28, 2025

Conversation

LordofAvernus
Copy link
Collaborator

@LordofAvernus LordofAvernus commented May 27, 2025

User description

关联的 issue

link: https://github.com/actiontech/sqle-ee/issues/1639

描述你的变更

支持TDSQL 监控库社区版变更

确认项(pr提交后操作)

Tip

请在指定复审人之前,确认并完成以下事项,完成后✅


  • 我已完成自测
  • 我已记录完整日志方便进行诊断
  • 我已在关联的issue里补充了实现方案
  • 我已在关联的issue里补充了测试影响面
  • 我已确认了变更的兼容性,如果不兼容则在issue里标记 not_compatible
  • 我已确认了是否要更新文档,如果要更新则在issue里标记 need_update_doc


Description

  • 新增监控库指标国际化翻译

  • 更新SQL查询增加过滤条件

  • 添加监控库相关指标常量映射


Changes walkthrough 📝

Relevant files
Enhancement
message_zh.go
新增监控库指标中文描述                                                                                           

sqle/locale/message_zh.go

  • 添加锁等待时间平均值和最大值的中文描述
  • 添加最大影响行数、平均影响行数及校验和中文消息
+6/-0     
instance_audit_plan.go
更新 SQL 查询函数                                                                                           

sqle/model/instance_audit_plan.go

  • 修改函数签名增加 typ 参数
  • SQL查询增加 source 和 deleted_at 过滤
+2/-2     
metrics.go
新增监控库指标常量映射                                                                                           

sqle/server/auditplan/metrics.go

  • 添加监控库指标常量定义
  • 更新 ALLMetric 映射新增监控库指标
+12/-0   
Documentation
active.en.toml
新增监控库指标英文翻译                                                                                           

sqle/locale/active.en.toml

  • 新增英文翻译新增监控库指标
+6/-0     
active.zh.toml
新增监控库指标中文翻译                                                                                           

sqle/locale/active.zh.toml

  • 新增中文翻译新增监控库指标
+6/-0     

Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @actiontech-bot actiontech-bot requested a review from winfredLIN May 27, 2025 08:51
    Copy link

    github-actions bot commented May 27, 2025

    PR Reviewer Guide 🔍

    (Review updated until commit 25036be)

    🎫 Ticket compliance analysis 🔶

    1639 - Partially compliant

    Compliant requirements:

    • 新增监控库指标国际化翻译
    • 更新SQL查询增加过滤条件
    • 添加监控库相关指标常量映射

    Non-compliant requirements:

    • 支持TDSQL监控库社区版变更

    Requires further human verification:

    无需进一步人工验证

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    接口变更核查

    请进一步验证新添加的SQL查询逻辑和参数(例如新增的 source 字段过滤)是否完全符合数据源接口定义要求,并核查相关业务逻辑对该更改的适配情况。

    func (s *Storage) GetLatestStartTimeAuditPlanSQLV2(sourceId uint, typ string) (string, error) {
    	info := struct {
    		StartTime string `gorm:"column:max_start_time"`
    	}{}
    	err := s.db.Raw(`SELECT MAX(STR_TO_DATE(JSON_UNQUOTE(JSON_EXTRACT(info, '$.start_time_of_last_scraped_sql')), '%Y-%m-%dT%H:%i:%s.%f')) 
    					AS max_start_time FROM sql_manage_records WHERE source_id = ? AND source = ? AND deleted_at is NULL`, sourceId, typ).Scan(&info).Error
    	return info.StartTime, err

    Copy link

    github-actions bot commented May 27, 2025

    PR Code Suggestions ✨

    Latest suggestions up to 25036be
    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    增加参数检查

    建议在进入函数后增加对传入 typ 参数的有效性检查,确保该参数不为空且符合预期格式,从而避免因非法参数导致 SQL 查询异常或逻辑错误。

    sqle/model/instance_audit_plan.go [175-182]

     func (s *Storage) GetLatestStartTimeAuditPlanSQLV2(sourceId uint, typ string) (string, error) {
    +	if typ == "" {
    +		return "", errors.New("invalid type parameter")
    +	}
     	info := struct {
     		StartTime string `gorm:"column:max_start_time"`
     	}{}
     	err := s.db.Raw(`SELECT MAX(STR_TO_DATE(JSON_UNQUOTE(JSON_EXTRACT(info, '$.start_time_of_last_scraped_sql')), '%Y-%m-%dT%H:%i:%s.%f')) 
     					AS max_start_time FROM sql_manage_records WHERE source_id = ? AND source = ? AND deleted_at is NULL`, sourceId, typ).Scan(&info).Error
     	return info.StartTime, err
     }
    Suggestion importance[1-10]: 7

    __

    Why: The suggestion adds a check to validate the typ parameter, which improves error handling and prevents potential SQL query issues. While this strengthens robustness, it is a moderate enhancement rather than a critical fix.

    Medium
    General
    删除尾部空格

    建议删除 ApMetricNameLockWaitTimeAvg 中结尾的多余空格,以保持翻译文本风格一致,并避免后续处理时可能出现的不必要问题。

    sqle/locale/active.en.toml [347]

    -ApMetricNameLockWaitTimeAvg = "Average lock wait time(ms) "
    +ApMetricNameLockWaitTimeAvg = "Average lock wait time(ms)"
    Suggestion importance[1-10]: 4

    __

    Why: The suggestion correctly removes the extra trailing space in the translation string for ApMetricNameLockWaitTimeAvg, ensuring consistency in the text style. Its impact is minor, addressing only a small formatting issue.

    Low

    Previous suggestions

    Suggestions up to commit e1e3740
    CategorySuggestion                                                                                                                                    Impact
    General
    去除多余空格

    建议移除字符串末尾的多余空格以避免显示或匹配问题。保持键对应的值与其他语言版本一致可以提升国际化的一致性。

    sqle/locale/active.en.toml [347]

    -ApMetricNameLockWaitTimeAvg = "Average lock wait time(ms) "
    +ApMetricNameLockWaitTimeAvg = "Average lock wait time(ms)"
    Suggestion importance[1-10]: 5

    __

    Why: The suggestion correctly removes a trailing space from the value of ApMetricNameLockWaitTimeAvg, which improves consistency. The change is minor but beneficial for internationalization consistency.

    Low

    Copy link

    Persistent review updated to latest commit 25036be

    @winfredLIN winfredLIN merged commit 79db1f3 into main May 28, 2025
    4 checks passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants