rabbitmq-server icon indicating copy to clipboard operation
rabbitmq-server copied to clipboard

rabbitmq_tracing should open trace files using UTF-8 for encoding

Open pavelbelonosov opened this issue 6 months ago • 1 comments

Is your feature request related to a problem? Please describe.

We are using rabbitmq_tracing plugin and faced an issue - when opening log.file from admin->tracing->trace log files we see bad enconding for cyrillic symbols cause no charset is set by default.

Describe the solution you'd like

Maybe you should consider adding js function for opening file in new window:
in tracing.js add ( https://github.com/rabbitmq/rabbitmq-server/blob/main/deps/rabbitmq_tracing/priv/www/js/tracing.js )

function loadTextFile(node, file) {
  fetch('/api/trace-files/node/' + node + '/' + file)
    .then(response => response.text())
    .then(text => {
      const win = window.open();
      win.document.write('<pre style="word-wrap: break-word; white-space: pre-wrap;" >' + text + '</pre>');
    });
}

and in traces.ejs ( https://github.com/rabbitmq/rabbitmq-server/blob/main/deps/rabbitmq_tracing/priv/www/js/tmpl/traces.ejs#L94 )

 <td><a onclick=loadTextFile(<%= node.name %>, <%= file.name %>) ><%= file.name %></a></td>

Describe alternatives you've considered

No response

Additional context

No response

pavelbelonosov avatar May 26 '25 09:05 pavelbelonosov

@pavelbelonosov you are welcome to contribute the proposed changes.

michaelklishin avatar May 26 '25 09:05 michaelklishin

@michaelklishin I’d like to work on this. Could you please assign it to me?

bas0N avatar Nov 16 '25 18:11 bas0N

@bas0N after signing the CLA (that we have discussed in another issue), you are welcome to submit a PR. There are no other formalities involved, just do it.

michaelklishin avatar Nov 17 '25 02:11 michaelklishin

Got it, thanks! I’m on it

bas0N avatar Nov 17 '25 12:11 bas0N

@michaelklishin Could you please take a look at this PR? This implements a server-side fix for the UTF-8 encoding issue. The solution differs from the original JavaScript approach suggested in the issue, but it resolves the problem while providing a proper URL in the browser

bas0N avatar Nov 18 '25 01:11 bas0N