prometheus / prometheus/client_java
Invalid unicode output
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.3k
- Forks
- 833
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 86
Description
If I do this:
PrometheusRegistry registry = new PrometheusRegistry();
Counter.builder()
.name("test_我喜欢茶")
.labelNames("test")
.register(registry)
.labelValues("test_我喜欢茶").inc();
String accept = OpenMetricsTextFormatWriter.CONTENT_TYPE + "; escaping=allow-utf-8";
ExpositionFormats.init().findWriter(accept).write(System.out, registry.scrape(), EscapingScheme.fromAcceptHeader(accept));
I get this:
# TYPE "test_我喜欢茶" counter
{"test_我喜欢茶_total",test="test_我喜欢茶"} 1.0
# EOF
If I remove the non-ascii characters (still UTF-8 allowed), I get the usual output:
# TYPE test counter
test_total{test="test"} 1.0
# EOF
Is this expected?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with OpenMetricsTextFormatWriter, ExpositionFormats.init().findWriter(), and EscapingScheme.fromAcceptHeader() from the example, then reproduce the output using the provided Java snippet. Compare the UTF-8 and ASCII cases to determine whether the quoted metric names and JSON-like output are expected; done means the behavior is confirmed or the intended corrected output is established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, prometheus
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100