prometheus / prometheus/client_java

Escaping API inconsistencies

Open
#1,577 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
2.3k
Forks
833
Avg merge
2d 16h
Merged PRs (30d)
86

Description

If I understand correctly, this is approximately how I should produce an output:

expositionFormats.findWriter(accept)
    .write(System.out, registry.scrape(), EscapingScheme.fromAcceptHeader(accept));

The problem with this is that the API forces me to pass the accept header twice, so theoretically I can do this:

expositionFormats.findWriter(acceptHeaderOne)
    .write(System.out, registry.scrape(), EscapingScheme.fromAcceptHeader(acceptHeaderTwo));

Which can lead to inconsistencies, it is easy to misuse the API.
I'm wondering if something like this would make sense:

expositionFormats.findWriter(accept).write(System.out, registry.scrape());

and the writer would have the EscapingScheme.
The writer still can be cached but it would be a little more than today.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the expositionFormats.findWriter API, the writer's write method, and EscapingScheme.fromAcceptHeader usages in the Java client. Compare how cached writers are handled and determine how the API can avoid accepting two potentially different headers; done means the proposed usage is consistent without losing writer caching.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.