新增 trace attr
This commit is contained in:
@@ -25,7 +25,7 @@ func ApplyMiddlewares(app *fiber.App) {
|
||||
EnableStackTrace: true,
|
||||
}))
|
||||
|
||||
// metric
|
||||
// otel
|
||||
app.Use(otelfiber.Middleware())
|
||||
|
||||
// logger
|
||||
@@ -45,12 +45,23 @@ func ApplyMiddlewares(app *fiber.App) {
|
||||
return err
|
||||
}
|
||||
|
||||
str := ""
|
||||
if err != nil {
|
||||
str = err.Error()
|
||||
span.SetAttributes(attribute.String("http.response.error", err.Error()))
|
||||
}
|
||||
|
||||
authCtx := auth.GetAuthCtx(c)
|
||||
if authCtx != nil {
|
||||
if authCtx.User != nil {
|
||||
span.SetAttributes(attribute.Int("auth.user.id", int(authCtx.User.ID)))
|
||||
}
|
||||
if authCtx.Admin != nil {
|
||||
span.SetAttributes(attribute.Int("auth.admin.id", int(authCtx.Admin.ID)))
|
||||
}
|
||||
if authCtx.Client != nil {
|
||||
span.SetAttributes(attribute.Int("auth.client.id", int(authCtx.Client.ID)))
|
||||
}
|
||||
}
|
||||
|
||||
span.SetAttributes(attribute.String("http.response.error", str))
|
||||
return err
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user