github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/internal/datastore/postgres/log_tracer.go (about)

     1  package postgres
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/jackc/pgx/v5/tracelog"
     7  	"go.opentelemetry.io/otel/attribute"
     8  	"go.opentelemetry.io/otel/trace"
     9  )
    10  
    11  type tracingLogger struct{}
    12  
    13  func (tl tracingLogger) Log(ctx context.Context, level tracelog.LogLevel, msg string, _ map[string]interface{}) {
    14  	span := trace.SpanFromContext(ctx)
    15  	span.AddEvent(msg, trace.WithAttributes(attribute.Stringer("level", level), attribute.String("datastore", "postgres")))
    16  }