Skip to content

fix(contrib/metric/otelmetric): Fix MustProvider function parameter and improve runtime version retrieval - #4729

Open
H4x3rs wants to merge 4 commits into
gogf:masterfrom
H4x3rs:fix/4727
Open

fix(contrib/metric/otelmetric): Fix MustProvider function parameter and improve runtime version retrieval#4729
H4x3rs wants to merge 4 commits into
gogf:masterfrom
H4x3rs:fix/4727

Conversation

@H4x3rs

@H4x3rs H4x3rs commented Mar 2, 2026

Copy link
Copy Markdown

docs(otelmetric/README.MD): 修复MustProvider函数参数错误

  • 将metric.WithReader替换为otelmetric.WithReader以匹配正确的函数签名

fix(otelmetric): 兼容不同版本runtime版本获取逻辑

  • 添加 reflect 包导入以支持动态调用
  • 实现 getRuntimeVersion 函数,通过反射安全获取运行时版本
  • 替换直接调用 runtime.Version() 为 getRuntimeVersion() 调用
  • 提高版本获取的稳定性和兼容性

haojie.ren added 2 commits March 2, 2026 16:58
- 将metric.WithReader替换为otelmetric.WithReader以匹配正确的函数签名
- 添加 reflect 包导入以支持动态调用
- 实现 getRuntimeVersion 函数,通过反射安全获取运行时版本
- 替换直接调用 runtime.Version() 为 getRuntimeVersion() 调用
- 提高版本获取的稳定性和兼容性

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the otelmetric contrib module to (1) correct the README example to use the module’s Option helpers, and (2) make built-in runtime metrics scope version retrieval resilient to upstream API differences.

Changes:

  • Update README example to pass otelmetric.WithReader(...) into otelmetric.MustProvider(...).
  • Introduce getRuntimeVersion() and replace direct runtime.Version() calls when constructing built-in metric views.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
contrib/metric/otelmetric/otelmetric_provider.go Adds a compatibility runtime version getter and uses it for instrumentation scope version in built-in metric views.
contrib/metric/otelmetric/README.MD Fixes the README example to use otelmetric.WithReader (matching MustProvider(...Option)).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread contrib/metric/otelmetric/otelmetric_provider.go Outdated
Comment thread contrib/metric/otelmetric/otelmetric_provider.go
Comment thread contrib/metric/otelmetric/otelmetric_provider.go
Comment thread contrib/metric/otelmetric/README.MD
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@gqcn

gqcn commented Jul 8, 2026

Copy link
Copy Markdown
Member

@H4x3rs Please resolve the comment.

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.

3 participants