Skip to content

Conversation

@cuichen01
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

- 修复backend/modules/observability/infra/repo/ck/spans_test.go中的未定义QueryParam类型错误
- 修复backend/modules/observability/infra/repo/trace_test.go中的多个构建和运行时错误
- 创建backend/modules/observability/application/convertor/page_test.go用于测试新的convertor函数
- 创建backend/modules/observability/application/convertor/task/filter_test.go用于测试新的TaskFilters转换函数
- 修复mock文件中的包导入和类型引用错误
- 确保所有trace repo测试用例通过

主要修复内容包括:
- 修正结构体字段名称不匹配问题(spansDao → spanDaos)
- 添加缺失的mockStorageProvider实现
- 更新所有构造函数调用以使用正确的TraceRepoOption模式
- 修复mock期望以匹配实际方法签名
- 解决参数匹配问题

所有测试现已通过,确保代码库保持高质量和可靠性。
- 修复backend/modules/observability/domain/task/service/task_service_test.go中的构建错误
  - 修复NewTaskServiceImpl构造函数调用,添加缺失的必需参数
  - 创建stubIDGenerator、stubStorageProvider、stubTenantProvider实现
  - 修复测试函数中直接使用未导出类型的问题

- 修复backend/modules/observability/domain/task/service/task_callback_test.go中的mock期望问题
  - 添加缺失的GetTask方法期望
  - 修复TaskCallbackServiceImpl初始化时缺少的taskRepo字段

- 修复backend/modules/observability/domain/trace/service/trace_service_test.go中的参数匹配问题
  - 修复SearchTraceOApi测试中GetTrace参数期望不匹配问题

所有TaskServiceImpl、TaskCallbackServiceImpl和TraceServiceImpl相关的测试现已通过,确保代码库的稳定性和可靠性。
@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

❌ Patch coverage is 57.14286% with 180 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ules/observability/infra/repo/ck/convertor/span.go 0.00% 63 Missing ⚠️
.../observability/application/convertor/trace/span.go 0.00% 31 Missing ⚠️
backend/modules/observability/infra/repo/trace.go 75.22% 16 Missing and 12 partials ⚠️
...les/observability/infra/repo/dao/converter/span.go 82.85% 14 Missing and 4 partials ⚠️
...ckend/modules/observability/infra/repo/ck/spans.go 8.33% 11 Missing ⚠️
...observability/domain/task/service/task_callback.go 44.44% 9 Missing and 1 partial ⚠️
...end/modules/observability/infra/storage/storage.go 0.00% 7 Missing ⚠️
.../observability/domain/task/service/task_service.go 44.44% 3 Missing and 2 partials ⚠️
.../modules/observability/infra/repo/ck/annotation.go 0.00% 4 Missing ⚠️
backend/api/api.go 0.00% 1 Missing ⚠️
... and 2 more

❌ Your patch check has failed because the patch coverage (57.14%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #323      +/-   ##
==========================================
- Coverage   69.28%   69.19%   -0.09%     
==========================================
  Files         588      586       -2     
  Lines       55147    54453     -694     
==========================================
- Hits        38206    37681     -525     
+ Misses      14047    13902     -145     
+ Partials     2894     2870      -24     
Flag Coverage Δ
unittests 69.19% <57.14%> (-0.09%) ⬇️

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

Files with missing lines Coverage Δ
...ules/observability/domain/metric/service/metric.go 68.24% <100.00%> (+0.09%) ⬆️
.../modules/observability/domain/task/entity/event.go 46.51% <100.00%> (+0.62%) ⬆️
...y/domain/task/service/taskexe/tracehub/backfill.go 66.07% <100.00%> (+0.12%) ⬆️
.../domain/task/service/taskexe/tracehub/trace_hub.go 0.00% <ø> (ø)
...ility/domain/trace/service/trace_export_service.go 72.69% <100.00%> (+0.29%) ⬆️
...servability/infra/repo/dao/converter/annotation.go 46.60% <100.00%> (ø)
backend/api/api.go 0.00% <0.00%> (ø)
...ckend/modules/observability/application/openapi.go 74.68% <0.00%> (ø)
...bservability/domain/trace/service/trace_service.go 83.42% <97.36%> (+0.26%) ⬆️
.../modules/observability/infra/repo/ck/annotation.go 0.00% <0.00%> (ø)
... and 8 more

... and 10 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 3678804...bbdbbb2. 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.

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.

Summary of key findings:

  • [🚫Must-Fix] Remove hard-coded environment injection via context.WithValue in task_service.go (line 387). Use configuration/wiring instead; contexts should carry cancellation/timeouts and request-scoped values.
  • [🚫Must-Fix] Fix invalid go directive in backend/go.mod (go 1.24.6go 1.24; optionally keep toolchain go1.24.6).
  • [🚫Must-Fix] Fix invalid go directive in modules/observability/lib/go.mod (go 1.24.6go 1.24; optionally keep toolchain go1.24.6).

Other changes reviewed are scoped workspace additions, DAO refactors, wiring updates, and OTEL/loop span conversions. No correctness/concurrency/security risks identified within the modified lines.

return errorx.NewByCode(obErrorx.CommonInternalErrorCode, errorx.WithExtraMsg("backfill producer not initialized"))
}
// todo ppe test
ctx = context.WithValue(ctx, "K_ENV", "ppe_6788399583")
Copy link
Collaborator

Choose a reason for hiding this comment

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

[🚫Must-Fix] Hard-coded environment injected via context

  • Problem: This line injects a hard-coded environment value into the request context ("ppe_6788399583"). Using context.WithValue for config and hard-coding an env breaks correctness across environments and violates Go’s context usage guidance (context is for cancellation, deadlines, and request-scoped values, not global config). It will force all backfill sends to use PPE and can leak into production unexpectedly.
  • Fix: Remove the hard-coded WithValue and pass environment via typed configuration or explicit parameter wiring. Example:
// remove: ctx = context.WithValue(ctx, "K_ENV", "ppe_6788399583")
// use injected config/env instead (e.g., from t.config or service wiring)
return t.backfillProducer.SendBackfill(ctx, event)
  • Reference: Go Code Review Comments – Context; Effective Go – Package context (use for cancellation/timeouts, avoid ad-hoc key/value globals).

limit = 10000
}
spans, err := r.traceRepo.GetTrace(ctx, &repo.GetTraceParam{
WorkSpaceID: strconv.FormatInt(req.WorkspaceID, 10),
Copy link
Collaborator

Choose a reason for hiding this comment

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

No risk found in this change.

go 1.24.1

toolchain go1.24.6
go 1.24.6
Copy link
Collaborator

Choose a reason for hiding this comment

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

[🚫Must-Fix] Invalid go directive version in go.mod

  • Problem: The go directive must specify the Go language version as major.minor (e.g., go 1.24). Using go 1.24.6 is invalid and will cause tooling/build issues. If you need to pin a patch toolchain, use the toolchain directive instead.
  • Fix: Change to go 1.24 and optionally (re-)add toolchain go1.24.6 if your build requires a specific patch toolchain.
  • Reference: Go Modules Reference – go directive semantics; Effective Go module guidelines.

const PlatformType PlatformType_Workflow = "coze_workflow"
const PlatformType PlatformType_Ark = "ark"
const PlatformType PlatformType_VeADK = "veadk"
const PlatformType PlatformType_VeAgentkit = "ve_agentkit"
Copy link
Collaborator

Choose a reason for hiding this comment

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

No risk found in this change.

spans := otel.OtelSpansConvertToSendSpans(ctx, workspaceId, otelSpans)

tenantSpanMap := o.unpackTenant(ctx, spans)
tenantSpanMap := o.unpackTenant(ctx, tconv.OtelSpans2LoopSpans(spans))
Copy link
Collaborator

Choose a reason for hiding this comment

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

No risk found in this change.


func (t *TraceCkRepoImpl) ListSpans(ctx context.Context, req *repo.ListSpansParam) (*repo.ListSpansResult, error) {
func (t *TraceRepoImpl) ListSpans(ctx context.Context, req *repo.ListSpansParam) (*repo.ListSpansResult, error) {
spanStorage := t.storageProvider.GetTraceStorage(ctx, req.WorkSpaceID, req.Tenants)
Copy link
Collaborator

Choose a reason for hiding this comment

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

No risk found in this change.

)
)

func provideTraceRepo(
Copy link
Collaborator

Choose a reason for hiding this comment

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

No risk found in this change.

List(context.Context, *ListAnnotationsParam) ([]*Annotation, error)
}

type Annotation struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

No risk found in this change.

}

func NewAnnotationCkDaoImpl(db ck.Provider) (IAnnotationDao, error) {
func NewAnnotationCkDaoImpl(db ck.Provider) (dao.IAnnotationDao, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

No risk found in this change.

@@ -0,0 +1,33 @@
module github.com/coze-dev/coze-loop/backend/modules/observability/lib

go 1.24.6
Copy link
Collaborator

Choose a reason for hiding this comment

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

[🚫Must-Fix] Invalid go directive version in module go.mod

  • Problem: The go directive must be major.minor (e.g., go 1.24). go 1.24.6 is invalid for the go directive and can break tooling. If pinning a patch toolchain is required, use toolchain.
  • Fix: Change to go 1.24 and optionally add toolchain go1.24.6.
  • Reference: Go Modules Reference – go directive.

taoyifan89 and others added 4 commits December 2, 2025 21:58
Change-Id: Idef45fe757a98f87c5f731934a47d11e57fcd953
Change-Id: I92b5ca667d4bf5aac67ca7ccd069902b664c4713
- 修复了buildTestTask函数中缺失的SpanFilter字段导致的空指针解引用问题
- 修正了SpanFilter相关的类型定义错误
- 补充了buildEvalTargetParam函数的测试用例,覆盖不同平台类型
- 添加了NewAutoEvaluteProcessor构造函数测试
- 补充了错误处理路径的测试用例
- 整体测试覆盖率从74.3%提升到76.5%
- 关键函数buildEvalTargetParam覆盖率从66.7%提升到100%
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.

5 participants