spiderpool
spiderpool copied to clipboard
add otel metrics for spiderpool
Signed-off-by: Icarus9913 [email protected]
Add otel metrics module for spiderpool to monitor.
- [x] Test
每个函数的健壮性不好,没有入参校验,错误了没有抛给外部 单元测试太简单,需要有正向和反向用例,甚至是并发竞争,且覆盖率100%
metric 部分的设计,是否应该做成不对业务影响的模块,不耦合?对此,我只在新建接口时才有过一次err异常抛出。 指标收集部分的代码是插入在业务代码中,应该仅作为一个插入,而不应该对业务层有err介入,否则写业务会因为没有记录到指标而抛异常?我的想法是,中间键部分的代码,仅仅作为业务代码部门的某一两行的污染,若有异常应log指出。不应让其err影响到业务层?
不让外部感知 erro 不叫 “不耦合”,外部不要 call function call 才叫 不耦合 没见过哪个 开源的 module 能自己内部消化掉 error,整个 function call 都失败了,还完全不让外部感知 应该要 传递 error 出来 , 上层 业务 是否 忽略或处理,是上层的事,打印出错也可以上 层自己的logger 来控制 。 不需要 本pkg 操心 error 的处理,否则外部业务 完全丧失控制
Codecov Report
Merging #81 (0a8b6d0) into main (1621ec6) will increase coverage by
3.94%
. The diff coverage is92.68%
.
@@ Coverage Diff @@
## main #81 +/- ##
==========================================
+ Coverage 77.58% 81.52% +3.94%
==========================================
Files 2 3 +1
Lines 116 157 +41
==========================================
+ Hits 90 128 +38
- Misses 19 21 +2
- Partials 7 8 +1
Flag | Coverage Δ | |
---|---|---|
unittests | 81.52% <92.68%> (+3.94%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
Impacted Files | Coverage Δ | |
---|---|---|
pkg/metrics/metrics.go | 92.68% <92.68%> (ø) |
对于metrics的unitest记录某种指标是否成功记录/消费的验证,otel库目前缺少该功能。已有其他contributor提过该类的issue和pr,但是还没有merge。 https://github.com/open-telemetry/opentelemetry-go/pull/2776
有冲突了,解决下
Kudos, SonarCloud Quality Gate passed!
0 Bugs
0 Vulnerabilities
0 Security Hotspots
0 Code Smells
No Coverage information
0.0% Duplication
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.