Found a small bug. There is an error parsing such constructs, but only if the comment contains parentheses with spaces inside them. Without spaces, everything is processed normally.
log_format analytics escape=json '{'
'"request_length": "$request_length"' # text (spaces inside) text
'}';