mirror of
https://github.com/3ybactuk/marketplace-go-service-project.git
synced 2025-10-30 14:03:45 +03:00
[hw-7] add metrics, tracing
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/IBM/sarama"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"google.golang.org/grpc"
|
||||
@@ -22,9 +23,9 @@ import (
|
||||
stocksRepository "route256/loms/internal/domain/repository/stocks/sqlc"
|
||||
"route256/loms/internal/domain/service"
|
||||
"route256/loms/internal/infra/config"
|
||||
"route256/loms/internal/infra/db/postgres"
|
||||
mw "route256/loms/internal/infra/grpc/middleware"
|
||||
"route256/loms/internal/infra/messaging/kafka"
|
||||
"route256/loms/internal/infra/postgres"
|
||||
|
||||
pb "route256/pkg/api/loms/v1"
|
||||
)
|
||||
@@ -134,7 +135,9 @@ func (app *App) ListenAndServe(ctx context.Context) error {
|
||||
|
||||
app.grpcServer = grpc.NewServer(
|
||||
grpc.ChainUnaryInterceptor(
|
||||
mw.WithTracing,
|
||||
mw.Logging,
|
||||
mw.WithMetrics,
|
||||
mw.Validate,
|
||||
),
|
||||
)
|
||||
@@ -166,9 +169,13 @@ func (app *App) ListenAndServe(ctx context.Context) error {
|
||||
return fmt.Errorf("pb.RegisterLOMSHandler: %w", err)
|
||||
}
|
||||
|
||||
root := http.NewServeMux()
|
||||
root.Handle("/metrics", promhttp.Handler())
|
||||
root.Handle("/", gwmux)
|
||||
|
||||
app.httpServer = &http.Server{
|
||||
Addr: fmt.Sprintf("%s:%s", app.config.Service.Host, app.config.Service.HTTPPort),
|
||||
Handler: gwmux,
|
||||
Handler: root,
|
||||
ReadTimeout: 10 * time.Second,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user