feat: 提供 APM 关联数据绑定 API --story=137160935 - #12011
Merged
ZhuoZhuoCrayon merged 5 commits intoAug 19, 2026
Merged
Conversation
Collaborator
Author
ZhuoZhuoCrayon
left a comment
Member
There was a problem hiding this comment.
汇总评论
不建议合入。 1 个 P0(外部写入的容器负载关联会被 SaaS 保存清空),2 个 P1。根因是外部写入与 SaaS 全量保存共用同一份 EventServiceRelation.relations,两侧都按全量语义写。
CI 无后端单测信号:unittest.yml 只跑 bklog/,testpaths 不含 packages/apm_web/tests,新增的 369 行测试不会执行。
已存在未解决 review 线程的解决情况
| 评论 / 线程 | 位置 | 状态 | 处理动作 | 证据 |
|---|---|---|---|---|
| 无 | — | — | — | pulls/12011/comments 与 /reviews 均为空,仅有作者一条含测试截图的 issue comment |
已核对无问题
| 检查项 | 结论 | 证据 |
|---|---|---|
serializers.py:134 字段裁剪是否改变前端行为 |
无回归 | 配置页每次保存无条件下发 event_relation,full_relation_fields 恒非空,pop 分支对前端永不触发 |
| 前端是否依赖"缺省即清空" | 依赖,不可放宽 | log_relation_list 仅在非空时下发,删光日志关联靠默认值 [] 生效 |
| CICD 增量写入是否会被前端丢弃 | 不会 | pipeline-select-panel.tsx:50 的 ISendValue 与增量写入结构一致 |
perform_request 中 Application.objects.get 的 DoesNotExist |
无需处理 | 鉴权层 get_application_id_by_app_name 已先行查询并抛 ValueError(f"application({app_name}) not found") |
from apm_web.tasks import ... 提到模块级是否循环导入 |
无 | apm_web.tasks 未直接或间接导入 apm_web.service.resources |
| APIGW 资源与后端路由 | 匹配 | 后端 post /api/v4/service_web/service_config/ 对应 kernel_api/views/v4/apm.py:51;doc 文件名与 operationId 一致 |
Collaborator
Author
ZhuoZhuoCrayon
approved these changes
Aug 19, 2026
ZhuoZhuoCrayon
left a comment
Member
There was a problem hiding this comment.
LGTM
汇总评论
可以合入。上一轮 P0(增量写入后配置页保存清空 Workload)、权限回退、字段长度和 select_for_update 都已修好。
剩余一项不阻塞,后续再修:
bkmonitor/packages/apm_web/service/resources.py:561 [P1]
_prepare_event_relations 在全量保存遇到 k8s_event + 空 relations + is_auto: true 时,会把存量 Workload 写回并强制 is_auto=False。配置页「恢复自动关联」下发的就是这条 payload,保存后刷新会停在手动模式。增量路径已经把 is_auto 写成 False,刷新后的正常保存不会误清空;真正会走到这条分支的是用户主动恢复自动关联。
建议后续删掉这段拦截,event_relation 继续走 _prepare_default。若产品就是要外部绑定在恢复自动关联后仍保留,给外部关系打标记,并改配置页文案或禁用该按钮。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
























No description provided.