17 lines
499 B
Go
17 lines
499 B
Go
package middleware
|
|
|
|
import (
|
|
"git.lzcwy.cn/zhengchiliu/zt-closet-manage-backend/global"
|
|
"github.com/gin-gonic/gin"
|
|
"go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin"
|
|
)
|
|
|
|
// GinOTelMiddleware 为每个 HTTP 请求自动开启 server span。
|
|
func GinOTelMiddleware() gin.HandlerFunc {
|
|
name := "zt-closet-manage-backend"
|
|
if global.OtelSetting != nil && global.OtelSetting.ServiceName != "" {
|
|
name = global.OtelSetting.ServiceName
|
|
}
|
|
return otelgin.Middleware(name)
|
|
}
|