feat(infra): add OTel auto-instrumentations across all services
NestJS 6 services use getNodeAutoInstrumentations(). Python 2 services use FastAPIInstrumentor. Go 2 services use otelgin.
This commit is contained in:
@@ -11,12 +11,18 @@ import (
|
||||
|
||||
"github.com/edu-cloud/push-gateway/internal/config"
|
||||
"github.com/edu-cloud/push-gateway/internal/hub"
|
||||
"github.com/edu-cloud/push-gateway/internal/observability"
|
||||
"github.com/edu-cloud/push-gateway/internal/ws"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cfg := config.Load()
|
||||
// 初始化 OpenTelemetry tracer(endpoint 为空时自动跳过)
|
||||
tracerShutdown := observability.InitTracer("push-gateway", cfg.OTLPEndpoint)
|
||||
defer tracerShutdown()
|
||||
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
|
||||
h := hub.NewHub()
|
||||
@@ -24,6 +30,8 @@ func main() {
|
||||
|
||||
r := gin.New()
|
||||
r.Use(gin.Recovery())
|
||||
// OpenTelemetry 自动埋点(HTTP 请求/响应 span)
|
||||
r.Use(otelgin.Middleware("push-gateway"))
|
||||
|
||||
r.GET("/healthz", func(c *gin.Context) {
|
||||
c.JSON(200, gin.H{"status": "ok", "service": "push-gateway"})
|
||||
|
||||
Reference in New Issue
Block a user