Feat: enhance mapping observability - #3605
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3605 +/- ##
===========================================
- Coverage 54.57% 53.99% -0.59%
===========================================
Files 460 474 +14
Lines 35443 36466 +1023
===========================================
+ Hits 19344 19690 +346
- Misses 14543 15200 +657
- Partials 1556 1576 +20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
看了一下这个CI流程的失败应该不是由于这次commits修改导致的,好像是dubbo-go-samples仓库的新变动导致ci流程有竞态缺陷,会偶发失败 |
| registry := newMockMetricRegistry() | ||
| collector := &MetadataMetricCollector{BaseCollector: metrics.BaseCollector{R: registry}} | ||
| collector.start() | ||
| defer metrics.Unsubscribe(constant.MetricsMetadata) |
There was a problem hiding this comment.
[P1] 不要关闭包级 channel,并同步异步 registry 断言
collector.start() 使用包级 channel,这里的 Unsubscribe 会把它永久关闭;当前用例执行 -count=2 时第二轮稳定 panic:send on closed channel / close of closed channel。同时 collector goroutine 在写 mock maps,而 Eventually 并发读取,go test -race 也稳定失败。请给测试提供可重建的专用 channel/teardown seam,不要关闭生产包级 channel,并给 mock registry 加锁或等待完成信号后再断言;修复后补 -race 与 -count=2 门禁。
| collector.start() | ||
| defer metrics.Unsubscribe(constant.MetricsMetadata) | ||
|
|
||
| publish := func(name MetricName, succ bool) { |
There was a problem hiding this comment.
[P1] 让回归测试从 DelegateMetadataReport 驱动真实附件链
当前测试从手工构造 MetadataMetricEvent 开始,并自行填充 interface/group/application,仍绕过 DelegateMetadataReport。在 exact Head 的隔离副本中删除 metadata/report_instance.go 全部七处新增附件赋值后,go test ./metadata ./metrics/metadata -count=1 仍通过;生产指标此时会丢失标签。请用 mock report 调用 Register/Get/Listen/Remove 的 Delegate 方法,经过真实 event bus、start() switch、handler 到 registry,并断言标签;删除任一附件连接时测试应失败。



Description
Related to #3356 PR1
Add metrics and logs for register, get, listen, and remove
Changes
metadata/report_instance.go: Instrumented the four mapping methods onDelegateMetadataReport—RegisterServiceAppMapping(register),GetServiceAppMapping(switches to the listen event when listener is non-nil),RemoveServiceAppMappingListener(remove), emitting events with interface/group/application context, success status, and duration via the existingmetrics.Publishpatternmetrics/metadata/metric_set.go: Added metric definitions for the four mapping operations — 4 event names (MetadataMappingRegister/Get/Listen/Remove), each with_num_total/_num_succeed_total/_num_failed_total/_rt_milliseconds, mapped to Prometheus namesdubbo_metadata_mapping_{register,get,listen,remove}_*metrics/metadata/collector.go: Added 4 event handlers (StateCountcounters +Rtduration observations) and ametadataMappingMetricLeveltag layer exposing interface/group labels, with application overridingapplication_nameon register, keeping label cardinality boundedmetadata/mapping/metadata/service_name_mapping.go: Added logs for mapping operations — Map/Get/Remove log success at Debug level and failures at Warn/Error with interface, group, application, report count, operation (get/listen), and error fields; Get now explicitly returns nil result on empty successAdded corresponding tests
Checklist
develop