Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contrib/trace/otlpgrpc: grpc connection to opentelemetry collector authentication failed #3893

Open
ivothgle opened this issue Oct 27, 2024 · 6 comments
Assignees
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.

Comments

@ivothgle
Copy link
Contributor

Go version

go1.20

GoFrame version

2.7.0

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

  1. 使用 github.com/gogf/gf/contrib/trace/otlpgrpc/v2 上传数据到 OpenTelemetry Collector,
  2. 当我给Collector 的 receivers 添加认证时,如 basicauth 或 bearertokenauth
    如配置
extensions:
  health_check:
  bearertokenauth:
    token: "your-secret-token"

receivers:
  otlp:
    protocols:
      grpc:
        auth:
          authenticator: bearertokenauth
...

然后使用

otlpgrpc.Init(serviceName, ""localhost:4317"), "Bearer your-secret-token")

这将会报告认证失败 traces export: rpc error: code = Unknown desc = authentication didn't succeed

为什么会这样?
经过一天的排查我发现了问题原因
在例子中 https://github.com/gogf/gf/blob/master/example/trace/otlp/grpc/main.go 这里使用的阿里云
同时根据阿里云文档 https://help.aliyun.com/zh/arms/tracing-analysis/connect-opentelemetry-to-tracing-analysishttps://help.aliyun.com/zh/opentelemetry/user-guide/connect-to-managed-service-for-opentelemetry-and-authenticate-clients

这里的认证头是使用 Authentication 实现的
所以在 https://github.com/gogf/gf/blob/master/contrib/trace/otlpgrpc/otlpgrpc.go#L60 固定了hander

但是在 OpenTelemetry Collector 中是用 authorization 来接受认证头的,所以这导致认证失败
虽然只找到这个说明 https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configgrpc/README.mdhttps://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configauth/README.md
但我实测确实是用 authorization 能认证通过

期望这个能调整这个内容,或者在例子中额外说明,这个只适用于阿里云而可能不适用于其他接收器

What did you see happen?

报错
traces export: rpc error: code = Unknown desc = authentication didn't succeed

What did you expect to see?

不应该报错

@ivothgle ivothgle added the bug It is confirmed a bug, but don't worry, we'll handle it. label Oct 27, 2024
@ivothgle
Copy link
Contributor Author

@houseme
Copy link
Member

houseme commented Nov 14, 2024

otlpgrpcOpenTelemetry Collector 俩个不同的处理,OpenTelemetry Collector 需要自己单独处理一下

建议参考自定义一个 OpenTelemetry client。 https://github.com/gogf/gf/blob/master/example/trace/provider/grpc/main.go

@ivothgle
Copy link
Contributor Author

@houseme 我知道可以自己实现,但我更希望至少在文档上说明清楚,避免后续的人踩同样的坑

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@houseme I know I can implement it myself, but I would rather at least explain it clearly in the documentation to avoid subsequent people falling into the same trap.

@houseme
Copy link
Member

houseme commented Nov 18, 2024

@houseme 我知道可以自己实现,但我更希望至少在文档上说明清楚,避免后续的人踩同样的坑

辛苦您补充一下文档内容,感谢🙏

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@houseme I know I can implement it myself, but I would rather at least explain it clearly in the documentation to avoid subsequent people falling into the same trap.

Could you please add the content of the document, thank you🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.
Projects
None yet
Development

No branches or pull requests

3 participants