[hw-7] add metrics, tracing

This commit is contained in:
Никита Шубин
2025-07-26 14:15:40 +00:00
parent 342bd3f726
commit 4396bebe80
38 changed files with 717 additions and 36 deletions

View File

@@ -8,6 +8,7 @@ import (
"time"
"route256/loms/internal/domain/entity"
"route256/loms/internal/infra/tracing"
"github.com/IBM/sarama"
"github.com/rs/zerolog/log"
@@ -64,6 +65,9 @@ func (p *statusProducer) runCallbacks() {
}
func (p *statusProducer) Send(ctx context.Context, id entity.ID, status string) error {
ctx, span := tracing.Tracer().Start(ctx, "Producer.Send")
defer span.End()
log.Debug().Msgf("sending event for id: %d; status: %s", id, status)
newStatus, err := mapOrderStatus(status)
@@ -86,6 +90,9 @@ func (p *statusProducer) Send(ctx context.Context, id entity.ID, status string)
}
func (p *statusProducer) SendRaw(ctx context.Context, id entity.ID, value []byte) error {
ctx, span := tracing.Tracer().Start(ctx, "Producer.SendRaw")
defer span.End()
if len(value) == 0 {
return fmt.Errorf("empty message value")
}