spiderpool icon indicating copy to clipboard operation
spiderpool copied to clipboard

add otel metrics for spiderpool

Open Icarus9913 opened this issue 2 years ago • 8 comments

Signed-off-by: Icarus9913 [email protected]

Add otel metrics module for spiderpool to monitor.

  • [x] Test

Icarus9913 avatar Mar 29 '22 15:03 Icarus9913

每个函数的健壮性不好,没有入参校验,错误了没有抛给外部 单元测试太简单,需要有正向和反向用例,甚至是并发竞争,且覆盖率100%

weizhoublue avatar Mar 30 '22 08:03 weizhoublue

metric 部分的设计,是否应该做成不对业务影响的模块,不耦合?对此,我只在新建接口时才有过一次err异常抛出。 指标收集部分的代码是插入在业务代码中,应该仅作为一个插入,而不应该对业务层有err介入,否则写业务会因为没有记录到指标而抛异常?我的想法是,中间键部分的代码,仅仅作为业务代码部门的某一两行的污染,若有异常应log指出。不应让其err影响到业务层?

Icarus9913 avatar Mar 30 '22 08:03 Icarus9913

不让外部感知 erro 不叫 “不耦合”,外部不要 call function call 才叫 不耦合 没见过哪个 开源的 module 能自己内部消化掉 error,整个 function call 都失败了,还完全不让外部感知 应该要 传递 error 出来 , 上层 业务 是否 忽略或处理,是上层的事,打印出错也可以上 层自己的logger 来控制 。 不需要 本pkg 操心 error 的处理,否则外部业务 完全丧失控制

weizhoublue avatar Mar 30 '22 14:03 weizhoublue

Codecov Report

Merging #81 (0a8b6d0) into main (1621ec6) will increase coverage by 3.94%. The diff coverage is 92.68%.

Impacted file tree graph

@@            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%> (ø)

codecov[bot] avatar Apr 18 '22 15:04 codecov[bot]

对于metrics的unitest记录某种指标是否成功记录/消费的验证,otel库目前缺少该功能。已有其他contributor提过该类的issue和pr,但是还没有merge。 https://github.com/open-telemetry/opentelemetry-go/pull/2776

Icarus9913 avatar Apr 19 '22 03:04 Icarus9913

有冲突了,解决下

weizhoublue avatar Apr 21 '22 03:04 weizhoublue

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarcloud[bot] avatar Apr 23 '22 14:04 sonarcloud[bot]

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.

github-actions[bot] avatar Jul 09 '22 20:07 github-actions[bot]