Skip to content

[feat][trace] input/output configurable preview & agent metadata discovery#492

Open
fanhua-bytedance wants to merge 20 commits intomainfrom
feat/trace_preview
Open

[feat][trace] input/output configurable preview & agent metadata discovery#492
fanhua-bytedance wants to merge 20 commits intomainfrom
feat/trace_preview

Conversation

@fanhua-bytedance
Copy link
Copy Markdown
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

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 15, 2026

CLA assistant check
All committers have signed the CLA.

@mocayo mocayo changed the title [Feat]trace input/output configurable preview & agent metadata discovery [feat][trace] input/output configurable preview & agent metadata discovery Apr 15, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 83.43750% with 53 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...dler/coze/loop/apis/observability_trace_service.go 0.00% 22 Missing ⚠️
backend/modules/observability/application/trace.go 80.24% 15 Missing and 1 partial ⚠️
...bservability/domain/trace/service/trace_service.go 91.66% 3 Missing and 3 partials ⚠️
...ility/domain/trace/entity/column_extract_config.go 90.00% 2 Missing and 2 partials ⚠️
...ace/service/trace/span_processor/clip_processor.go 88.46% 1 Missing and 2 partials ⚠️
.../observability/infra/repo/column_extract_config.go 95.34% 1 Missing and 1 partial ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #492      +/-   ##
==========================================
+ Coverage   77.14%   77.18%   +0.03%     
==========================================
  Files         650      653       +3     
  Lines       72527    72825     +298     
==========================================
+ Hits        55953    56211     +258     
- Misses      13241    13271      +30     
- Partials     3333     3343      +10     
Flag Coverage Δ
unittests 77.18% <83.43%> (+0.03%) ⬆️

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

Files with missing lines Coverage Δ
...plication/convertor/trace/column_extract_config.go 100.00% <100.00%> (ø)
backend/pkg/json/ojg.go 95.95% <100.00%> (+0.35%) ⬆️
.../observability/infra/repo/column_extract_config.go 95.34% <95.34%> (ø)
...ace/service/trace/span_processor/clip_processor.go 90.32% <88.46%> (-1.57%) ⬇️
...ility/domain/trace/entity/column_extract_config.go 90.00% <90.00%> (ø)
...bservability/domain/trace/service/trace_service.go 89.04% <91.66%> (+0.10%) ⬆️
backend/modules/observability/application/trace.go 77.71% <80.24%> (+1.13%) ⬆️
...dler/coze/loop/apis/observability_trace_service.go 0.00% <0.00%> (ø)

... and 1 file 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 7a3ce58...1a279aa. 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.

Comment thread backend/bin/golangci-lint Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个不该传上来吧

InsertAnnotations(context.Context, *InsertAnnotationParam) error
UpsertTrajectoryConfig(context.Context, *UpsertTrajectoryConfigParam) error
GetTrajectoryConfig(context.Context, GetTrajectoryConfigParam) (*entity.TrajectoryConfig, error)
UpsertColumnExtractConfig(context.Context, *UpsertColumnExtractConfigParam) error
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个单独拆一个repo吧,和trace也没有太多关系

GetTrajectories(ctx context.Context, workspaceID int64, traceIDs []string, startTime, endTime int64,
platformType loop_span.PlatformType) (map[string]*loop_span.Trajectory, error)
MergeHistoryMessagesByRespIDBatch(ctx context.Context, spans []*loop_span.Span, platformType loop_span.PlatformType) error
UpsertColumnExtractConfig(ctx context.Context, req *UpsertColumnExtractConfigRequest) error
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ColumnExtractConfig 单独拆一个service吧,和trace关系不大。这里逻辑其实非常简单,直接application调repo都行,类似view的写法
GetAgentMetadata查trace的,可以放着

IsCustom: true,
},
{
FieldName: tagKeyGenAIAgentName,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个不需要适配

tagKeyGenAIAgentName = "gen_ai.agent.name"
)

func extractAgentName(s *loop_span.Span) string {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个也没必要了

}
var agentName string
_ = filters.Traverse(func(f *loop_span.FilterField) error {
if f.FieldName == tagKeyAgentName || f.FieldName == tagKeyGenAIAgentName {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

不需要

spanRedisDao redis_dao.ISpansRedisDao,
spanProducer mq.ISpanProducer,
trajectoryConfDao mysql.ITrajectoryConfigDao,
columnExtractConfDao mysql.IColumnExtractConfigDao,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

拆出去吧

clipProcessorSuffix = "..."
)

var defaultExtractRules = map[loop_span.SpanListType][]entity.ColumnExtractRule{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个是什么时候会用到的?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

这个是什么时候会用到的?
数据库无记录或配置为空的情况会使用默认配置

if span == nil {
var rules []entity.ColumnExtractRule
if c.traceRepo != nil && c.settings.WorkspaceId > 0 {
cfg, err := c.traceRepo.GetColumnExtractConfig(ctx, repo.GetColumnExtractConfigParam{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里应该缺了这个空间没有配置,取全局的默认配置逻辑吧?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

目前是如果无配置则会返回适用于ModelSpan的默认配置,对与自定义上报和其他的类型的还没做默认配置。

这里应该缺了这个空间没有配置,取全局的默认配置逻辑吧?

@fanhua-bytedance fanhua-bytedance force-pushed the feat/trace_preview branch 3 times, most recently from b7bb283 to fea7e85 Compare April 20, 2026 11:56
Comment thread backend/modules/observability/domain/trace/service/trace_service.go
- Move SelectBest/Extract/configScore logic from clip_processor to entity layer
- Use workspace_id=0 for global default configs with wildcard '*' matching
- Add 4-bit scoring strategy (workspace > agent > spanListType > platformType)
- Simplify ClipProcessor.Transform to delegate to entity layer
- Add DB error logging consistent with other processors
- Seed 3 default extract configs via init SQL with fixed IDs for idempotency
- Add comprehensive tests for SelectBest, configScore, Extract
Comment thread backend/modules/observability/domain/trace/entity/column_extract_config.go Outdated
…te default configs

- Rewrite SelectBest to use two-phase direct matching instead of bit-score approach
- Reduce default column extract configs from 3 to 2: (0,*,llm_span) and (0,prompt,root_span)
- Change span_list_type SQL query from wildcard IN to exact match
- Update tests with 20 cases for 100% SelectBest coverage
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