Unable to pass doublequote to labels method
I am trying to check is certain special unicode chars can be parsed by the prometheus client as per the documentation here https://prometheus.io/docs/instrumenting/exposition_formats/#text-based-format
So I'm first trying to test the prescribed clients in the prometheus site. When I try to pass backslash as a string value to the labels method of the java client, the output does not escape the backslash. Here is the code.
static final Counter requests = Counter
.build()
.name("hello_worlds_total")
.help("Number of hello worlds served.")
.labelNames("utfChars")
.register();
@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp)
throws ServletException, IOException {
resp.getWriter().println("Hello World!");
String utfCharValue = new String("A" + "\u00ea" + "\u00f1" + "\u00fc" + "C" + "\"" + "\u0B85");
System.out.println(utfCharValue);
// Increment the number of requests.
requests.labels(utfCharValue).inc();
}
}
Output on console: 2018-07-24 09:52:52.671:INFO:oejs.AbstractConnector:Started [email protected]:1234 AêñüC"அ
Output on localhost:1234/metrics: (See the unescaped backslash being printed)

Please advice.
Your code isn't passing a backslash, it's passing a double quote which is being correctly escaped.
I was testing backsslash, double quote and I marked this incorrectly
In any case, the code is parsing it correctly.

Apologies for the scare.