Skip to content

[feat][backend]: ob metrics#256

Closed
kidkidkid wants to merge 85 commits intomainfrom
feat/ob_metrics
Closed

[feat][backend]: ob metrics#256
kidkidkid wants to merge 85 commits intomainfrom
feat/ob_metrics

Conversation

@kidkidkid
Copy link
Collaborator

What type of PR is this?

Check the PR title.

  • This PR title match the format: [<type>][<scope>]: <description>. For example: [fix][backend] flaky fix
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Add documentation if the current PR requires user awareness at the usage level.
  • This PR is written in English. PRs not in English will not be reviewed.

(Optional) Translate the PR title into Chinese.

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:
zh(optional):

(Optional) Which issue(s) this PR fixes:

kidkidkid and others added 30 commits September 17, 2025 16:39
(LogID: 202509171627200100911101158442AB5)

Co-Authored-By: Coda <coda@bytedance.com>
(LogID: 202509171627200100911101158442AB5)

Co-Authored-By: Coda <coda@bytedance.com>
(LogID: 2025091717345901009111011567354BF)

Co-Authored-By: Coda <coda@bytedance.com>
…tion

(LogID: 20250917174630010091110115283AA9A)

Co-Authored-By: Coda <coda@bytedance.com>
…nstants

(LogID: 2025091811100901009111011538111C3)

Co-Authored-By: Coda <coda@bytedance.com>
…TraceRepo

(LogID: 202509181158370100911101150622C9A)

Co-Authored-By: Coda <coda@bytedance.com>
… calls

(LogID: 202509181938080100911101156688B07)

Co-Authored-By: Coda <coda@bytedance.com>
…terface

(LogID: 20250919125803010091110115303BB0B)

Co-Authored-By: Coda <coda@bytedance.com>
(LogID: 20250919125803010091110115303BB0B)

Co-Authored-By: Coda <coda@bytedance.com>
(LogID: 202509191728280100911101157415799)

Co-Authored-By: Coda <coda@bytedance.com>
(LogID: 2025092217305901009110607501234E6)

Co-Authored-By: Coda <coda@bytedance.com>
(LogID: 202509261759130100911042537649351)

Co-Authored-By: Coda <coda@bytedance.com>
…_count metric

(LogID: 202509291209590100911092389298F4D)

Co-Authored-By: Coda <coda@bytedance.com>
(LogID: 20251015105314010091104094405CFC2)

Co-Authored-By: Coda <coda@bytedance.com>
(LogID: 202510151538390100911040946941251)

Co-Authored-By: Coda <coda@bytedance.com>
(LogID: 202510161048080100911040943155F84)

Co-Authored-By: Coda <coda@bytedance.com>
@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 87.66901% with 228 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ules/observability/domain/metric/service/metric.go 68.97% 71 Missing and 32 partials ⚠️
...ckend/modules/observability/infra/repo/ck/spans.go 63.85% 24 Missing and 6 partials ⚠️
...ce/metric/model/model_output_token_count_metric.go 0.00% 24 Missing ⚠️
.../metric/service/metric/wrapper/multiple_wrapper.go 0.00% 19 Missing ⚠️
...ackend/modules/observability/application/metric.go 85.82% 13 Missing and 5 partials ⚠️
...main/metric/service/metric/wrapper/self_wrapper.go 25.00% 12 Missing ⚠️
.../observability/application/convertor/trace/span.go 68.00% 4 Missing and 4 partials ⚠️
backend/modules/observability/infra/repo/trace.go 76.92% 6 Missing ⚠️
...ler/coze/loop/apis/observability_metric_service.go 0.00% 4 Missing ⚠️
backend/api/handler/coze/loop/apis/handler.go 0.00% 2 Missing ⚠️
... and 1 more

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #256      +/-   ##
==========================================
+ Coverage   65.68%   67.81%   +2.12%     
==========================================
  Files         507      565      +58     
  Lines       57718    49697    -8021     
==========================================
- Hits        37912    33701    -4211     
+ Misses      17199    13343    -3856     
- Partials     2607     2653      +46     
Flag Coverage Δ
unittests 67.81% <87.66%> (+2.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
backend/infra/ck/ck.go 0.00% <ø> (ø)
...servability/application/convertor/metric/metric.go 100.00% <100.00%> (ø)
...bility/application/convertor/trace/trace_export.go 95.73% <ø> (-0.87%) ⬇️
...dules/observability/domain/metric/entity/metric.go 100.00% <100.00%> (ø)
...ervice/metric/general/general_fail_ratio_metric.go 100.00% <100.00%> (ø)
.../metric/general/general_model_fail_ratio_metric.go 100.00% <100.00%> (ø)
...ice/metric/general/general_model_latency_metric.go 100.00% <100.00%> (ø)
...etric/general/general_model_total_tokens_metric.go 100.00% <100.00%> (ø)
...e/metric/general/general_tool_fail_ratio_metric.go 100.00% <100.00%> (ø)
...vice/metric/general/general_tool_latency_metric.go 100.00% <100.00%> (ø)
... and 55 more

... and 446 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 43f34db...e177408. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

kidkidkid and others added 17 commits October 24, 2025 20:57
(LogID: 202510242052381921680001031104016)

Co-Authored-By: Coda <coda@bytedance.com>
(LogID: 20251024215714192168000103764C39D)

Co-Authored-By: Coda <coda@bytedance.com>
(LogID: 20251024215714192168000103764C39D)

Co-Authored-By: Coda <coda@bytedance.com>
(LogID: 20251024215714192168000103764C39D)

Co-Authored-By: Coda <coda@bytedance.com>
(LogID: 20251024215714192168000103764C39D)

Co-Authored-By: Coda <coda@bytedance.com>
(LogID: 20251024215714192168000103764C39D)

Co-Authored-By: Coda <coda@bytedance.com>
(LogID: 20251024215714192168000103764C39D)

Co-Authored-By: Coda <coda@bytedance.com>
(LogID: 20251027112907010091111069183BB83)

Co-Authored-By: Coda <coda@bytedance.com>
(LogID: 202510271430510100911110693736081)

Co-Authored-By: Coda <coda@bytedance.com>
Copy link
Collaborator

@CozeLoop CozeLoop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall review: The PR introduces observability metrics and minor API/config changes. Inline comments cover a potential compatibility concern (IDL mapping for span_ids) and a deployment config inconsistency (key_columns). Other changes appear low-risk (docs and span type additions).

5: optional string granularity (api.body="granularity")
6: optional filter.FilterFields filters (api.body="filters")
7: optional common.PlatformType platform_type (api.body="platform_type")
8: optional list<filter.FilterField> drill_down_fields (api.body="drill_down_fields")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drill_down_fields有什么用?

}

struct GetDrillDownValuesResponse {
1: optional list<string> values
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里要不要给个数据结构,说不定以后显示值和实际库里的值不一致?

3: required i64 end_time (api.js_conv='true', go.tag='json:"end_time"', api.body="end_time", vt.gt="0")
4: optional filter.FilterFields filters (api.body="filters")
5: optional common.PlatformType platform_type (api.body="platform_type")
6: required metric.DrillDownValueType drill_down_value_type (api.body="drill_down_value_type")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里如果是枚举值,会不会以后内场或者商业化专用的下钻维度不太好处理?

errorx.WithExtraMsg(fmt.Sprintf("metric definition %s not found", metricName)))
}
if _, ok := mVal.(entity.IMetricCompound); ok {
return m.queryCompoundMetric(ctx, req, mVal)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果传入多个metricsName,其中有符合指标,直接return就不对了吧?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果现在就是不支持,多个直接报错吧

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok 预期就是只能传一个复合指标 不然就是前端传的有问题

"github.com/coze-dev/coze-loop/backend/modules/observability/domain/trace/service/trace/span_filter"
)

type GeneralModelFailRatioMetric struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

model_fail为什么不在model下面,这个是按什么逻辑分的

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按PRD中的展示区域分的

MetricTypeSummary MetricType = "summary" // 汇总
MetricTypePie MetricType = "pie" // 饼图

MetricSourceCK MetricSource = "ck"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是不是不应该暴露ck,这个只需要表达使用内置存储就好?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果存储复用的话 那确实不应该用ck

taoyifan89
taoyifan89 previously approved these changes Oct 27, 2025
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.

3 participants