feat(storage): lab6 add PostgreSQL, Redis and S3 tracing and DB pool metrics

This commit is contained in:
Голиков Maximillian Антон
2026-11-16 14:48:07 +03:00
parent c403b23595
commit 472b4761d6
11 changed files with 225 additions and 3 deletions
+20 -3
View File
@@ -3,9 +3,11 @@ package s3
import (
"context"
"io"
"net/http"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"high-loud-apps-labs/internal/domain"
)
@@ -25,10 +27,25 @@ type MinioStorage struct {
}
func New(ctx context.Context, cfg Config) (*MinioStorage, error) {
base, err := minio.DefaultTransport(cfg.UseSSL)
if err != nil {
return nil, err
}
// Оборачиваем базовый транспорт в otelhttp.
// Опция WithSpanNameFormatter задаёт красивое имя спана (s3.PUT, s3.GET),
// чтобы в Grafana не смотреть на дефолтное "HTTP PUT".
tracedTransport := otelhttp.NewTransport(base,
otelhttp.WithSpanNameFormatter(func(operation string, r *http.Request) string {
return "s3." + r.Method
}),
)
client, err := minio.New(cfg.Endpoint, &minio.Options{
Creds: credentials.NewStaticV4(cfg.AccessKey, cfg.SecretKey, ""),
Secure: cfg.UseSSL,
Region: cfg.Region,
Transport: tracedTransport,
Creds: credentials.NewStaticV4(cfg.AccessKey, cfg.SecretKey, ""),
Secure: cfg.UseSSL,
Region: cfg.Region,
})
if err != nil {
return nil, err