feat: add gorm tracing middleware

This commit is contained in:
2024-07-24 15:40:18 +02:00
parent 9971ef17cb
commit dc4d3942f5
4 changed files with 299 additions and 0 deletions

View File

@ -58,6 +58,7 @@ const (
ServiceLayerKey = attribute.Key("service.layer")
ServiceLayerNameKey = attribute.Key("service.layer_name")
DBExecutionTimeMsKey = attribute.Key("db.execution_time_ms")
DBRowsAffectedKey = attribute.Key("db.rows_affected")
)
type ServiceArchitectureLayer string
@ -266,3 +267,10 @@ func DBExecutionTimeMs(duration time.Duration) attribute.KeyValue {
Value: attribute.Int64Value(duration.Milliseconds()),
}
}
func DBRowsAffected(rows int64) attribute.KeyValue {
return attribute.KeyValue{
Key: DBRowsAffectedKey,
Value: attribute.Int64Value(rows),
}
}