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

midway接入opentelemetry时,http里拿到的metricAttribute['http.route']为undefined #3078

Open
ColinChen2 opened this issue Jul 12, 2023 · 2 comments
Labels
status: Holding Same features may be hold, and implements layer.

Comments

@ColinChen2
Copy link

ColinChen2 commented Jul 12, 2023

  • Node Version:
  • Midway Version(Decorator/Core):
  • Component Name/Version:
  • Platform:
  • Mini Showcase Repository:

背景:
OPTL/koa就是接入koa项目,是正常的。
换成midway,会丢失router信息。

定位:
OPTL/koa是根据中间件的取值context._matchedRoute为空。
Screenshot 2023-07-13 at 15 31 26

期望:
能和koa中间件一样,是不是可以使用use去启动koa-router

@ColinChen2
Copy link
Author

ColinChen2 commented Jul 19, 2023

@czy88840616 你好,这个问题,我尝试使用了wrap useMiddleware去解决了,最终可以拿到_matchedRoute.
之前有同学说直接使用http的URL,不用管上层的router。但是会带来指标的多维度问题。比如:/a/123, /a/234, 会被记作不一样的label,而使用router就只有一个:/a/:id

@czy88840616 czy88840616 added the status: Holding Same features may be hold, and implements layer. label Jul 27, 2023
@waitingsong
Copy link
Member

给需要的朋友补充下 midway 如何拿到匹配路由:

const routeInfo = await this.webRouterService.getMatchedRouterInfo(ctx.path, ctx.method)
console.log(routeInfo.fullUrl)

17

docs-当前匹配的路由

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: Holding Same features may be hold, and implements layer.
Development

No branches or pull requests

3 participants