-
Notifications
You must be signed in to change notification settings - Fork 546
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
基于现有的 Tracer 设计,如何监控 inflight 指标? #1094
Labels
question
Further information is requested
Comments
|
// genLabels make labels values.
func genLabels(c *app.RequestContext) prometheus.Labels {
labels := make(prometheus.Labels)
labels[labelMethod] = defaultValIfEmpty(string(c.Request.Method()), unknownLabelValue)
labels[labelStatusCode] = defaultValIfEmpty(strconv.Itoa(c.Response.Header.StatusCode()), unknownLabelValue)
labels[labelPath] = defaultValIfEmpty(c.FullPath(), unknownLabelValue)
return labels
}
// Start record the start of server handling request from client.
func (s *ServerTracer) Start(ctx context.Context, c *app.RequestContext) context.Context {
// inflight
gaugeIncDec(s.serverHandledInFlight, true, genLabels(c))
return ctx
}
// Finish record the ending of server handling request from client.
func (s *ServerTracer) Finish(_ context.Context, c *app.RequestContext) {
if c.GetTraceInfo().Stats().Level() == stats.LevelDisabled {
return
}
httpStart := c.GetTraceInfo().Stats().GetEvent(stats.HTTPStart)
httpFinish := c.GetTraceInfo().Stats().GetEvent(stats.HTTPFinish)
if httpFinish == nil || httpStart == nil {
return
}
cost := httpFinish.Time().Sub(httpStart.Time())
_ = counterAdd(s.serverHandledCounter, 1, genLabels(c))
_ = histogramObserve(s.serverHandledHistogram, cost, genLabels(c))
gaugeIncDec(s.serverHandledInFlight, false, genLabels(c))
} |
cc @rogerogers 帮看下哈,这里是不是要判断一下所处的阶段 |
得在 Finish 里获取数据,埋点只是记录耗时... |
|
|
目前 start 获取不到 path 信息 |
那现阶段有比较好的解决方案嘛?🤔 |
这种中间件的方式,用 hertz 中间件也可以实现类似的 |
那暂时先按这种方式实现先迁移吧。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the Question
疑惑点:想问一下 hertz server(hertz/pkg/protocol/http1/server.go at develop · cloudwego/hertz) 这一段逻辑前置在 req.ReadHeader(https://github.com/cloudwego/hertz/blob/develop/pkg/protocol/http1/server.go#L195)是有什么 tracer 设计上的考虑嘛?
问题:由于上面的疑惑点会导致无法监控 inflight 指标(想监控请求中的条数)
Expected behavior
如何能够监控到 inflight request 指标?
Hertz version:
v0.8.1
Environment:
go1.21.7
The text was updated successfully, but these errors were encountered: