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

API Gateway exceptionQps not recorded for upstream 5xx | 网关访问后端返回 5xx 时无法统计为异常 #1706

Open
guojing762 opened this issue Aug 30, 2020 · 5 comments
Labels
area/gateway-flow-control Issues or PRs related to API gateway flow control good first issue Good for newcomers

Comments

@guojing762
Copy link

Issue Description

bug report

Describe what happened (or what feature you want)

使用spring-cloud-alibbaa集成的sentinel-spring-cloud-gateway-example测试代码
①通过网关访问后端服务,路由里配置一个错误的端口导致连接不上时,请求返回500,,exceptionQps统计数据有计数
image
image
②通过网关访问后端服务,接口能连接上,但是后端服务代码异常,请求同样返回500,,exceptionQps统计数据一直显示为0
image
image

Describe what you expected to happen

请求同样是500 希望都能统计

How to reproduce it (as minimally and precisely as possible)

  1. 使用spring-cloud-alibbaa集成的sentinel-spring-cloud-gateway-example测试代码
  2. 将网关路由配置错的端口,请求访问返回500,exceptionQps会计数
  3. 将网关路由配置对的端口,但代码内部使用 10/0 这种错误代码,请求返回500,exceptionQps不会计数

Tell us your environment

spring-cloud-alibaba-gateway,2.2.1.RELEASE

Anything else we need to know?

@sczyh30
Copy link
Member

sczyh30 commented Aug 30, 2020

Web/API Gateway 统计异常时仅统计直接抛出的异常,而默认不对异常的 HTTP 状态码进行统计。当然这里可以搞个扩展点来完善下,欢迎讨论。

@guojing762
Copy link
Author

Web/API Gateway 统计异常时仅统计直接抛出的异常,而默认不对异常的 HTTP 状态码进行统计。当然这里可以搞个扩展点来完善下,欢迎讨论。

感谢.
想确认下您这边说的 "Web/API Gateway 统计异常时仅统计直接抛出的异常是什么意思"?
现在是可以在网关中获取请求状态码,调用Tracer.trace(Throwable e)手动统计,但是这样统计了我例子中的第一种情况就会多统计一次异常数了.
想问下,在sentinel框架下或者spring-clouad-alibaba-sentinel框架范围内有没有原生的处理方式?

@cdfive
Copy link
Collaborator

cdfive commented Aug 30, 2020

本机用sentinel-spring-cloud-gateway-example试了下,结果跟问题描述一致。有点奇怪,第一种找不到端口的场景,status也是500,这个不是状态码么,但异常进了统计

@cdfive cdfive added area/gateway-flow-control Issues or PRs related to API gateway flow control kind/question Category issues related to questions or problems labels Aug 30, 2020
@guojing762
Copy link
Author

看代码应该是在InheritableBaseSubscriber里面进行的onError进行的判断,只针对连接进行了判断.
希望能提供针对http状态码进行的控制.或者把这种连接异常和业务异常能有个区分统计.谢谢.

@Sunyelw
Copy link

Sunyelw commented Mar 25, 2021

网关后端服务异常的返回是不会走到网关的异常处理器的, 它默认这种是属于成功的(?) 而端口找不到就是网关内部的错误了, 都是500,区别还是存在的. 若要记录这种后端服务自身异常, 可以考虑添加一个过滤器使用ServerHttpResponseDecorator, 判断响应返回500时手动调用 Tracer.trace(ex), 或者返回 Mono.error(ex).

@sczyh30 sczyh30 added the good first issue Good for newcomers label Apr 13, 2021
@sczyh30 sczyh30 changed the title 监控exceptionQps的问题 API Gateway exceptionQps not recorded for upstream 5xx | 网关访问后端返回 5xx 时无法统计为异常 Apr 13, 2021
@sczyh30 sczyh30 removed the kind/question Category issues related to questions or problems label Apr 13, 2021
CST11021 pushed a commit to CST11021/Sentinel that referenced this issue Nov 3, 2021
[ISSUE alibaba#1706]feat(pull_consumer) refactor the consumer offset update logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/gateway-flow-control Issues or PRs related to API gateway flow control good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants