diff --git a/save.go b/save.go index 0f2dea2..32de2d9 100644 --- a/save.go +++ b/save.go @@ -104,6 +104,18 @@ func SaveRow(ctx context.Context, db *db.DBC, dataItem meta.IMetaStruct) error { sqlSmt = sqlSmt[0:200] } + span.SetAttributes( + attribute.Int("sql_param_amount", len(params)), + ) + + // Convert SQL request parameters to slice of strings. + paramStrs := convertInterfacesToStrings(ctx, params) + if len(paramStrs) > 0 { + span.SetAttributes( + attribute.StringSlice("sql_params", paramStrs), + ) + } + resultErr := errors.Errorf("Can not execute SaveRow. Got error from updateBuilder.ExecContext. %s (%s)", err.Error(), sqlSmt) span.RecordError(resultErr) span.SetStatus(codes.Error, resultErr.Error()) @@ -118,6 +130,20 @@ func SaveRow(ctx context.Context, db *db.DBC, dataItem meta.IMetaStruct) error { return nil } +func convertInterfacesToStrings(ctx context.Context, items []interface{}) []string { + itemAmount := len(items) + if itemAmount == 0 { + return nil + } + + strs := make([]string, itemAmount) + for i, item := range items { + strs[i] = fmt.Sprint(item) + } + + return strs +} + func SaveMetaRootStruct( ctx context.Context, db *db.DBC,