Comments (6)
We have confirmation from MicroProfile that the spec is misleading:
https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!topic/microprofile/t4YgzPpmOsA
"I'm part of the metrics community and I agree that what's specified in section 2.3, related to the Accept header isn't as specific as it ought to be. The way it's worded in the spec right now isn't right, as illustrated by Joe's example.
The way we'd intended for it to be interpreted was that if the incoming request accepts text/plain with a higher priority than application/json, then you should use Prometheus format. If the incoming request accepts application/json with a higher priority than text/plain, then use JSON format. If the incoming request doesn't accept either of those, then return a 406 status code."
There is now an issue to clarify this in the spec: eclipse/microprofile-metrics#291
from helidon.
Interesting, I agree. Take a look at HashRequestHeaders::bestAccepted
.
from helidon.
The issue appears to be that Prometheus sends an Accept
header that looks like:
text/plain;version=0.0.4;q=1,*/*;q=0.1
So it is requesting text/plain
with a quality of 1, but will also accept anything. One can argue this isn't correct (since Prometheus can't handle JSON for example). But that's not the point.
The point is that Helidon will generate JSON in this case, and not Prometheus text. This is because of this method:
private void getMultiple(ServerRequest req, ServerResponse res, Registry... registries) {
if (req.headers().isAccepted(MediaType.APPLICATION_JSON)) {
res.send(toJsonData(registries));
} else {
res.send(toPrometheusData(registries));
}
}
Since the request headers will accept JSON, we generate JSON.
The logic needs to be more sophisticated. Since Prometheus prefers text/plain, that's what we should generate. To be explicit:
If the Accept header is text/plain;version=0.0.4;q=1,*/*;q=0.1
then we should generate a Prometheus text report.
If the Accept header is application/json;version=0.0.4;q=1,*/*;q=0.1
then we should generate a JSON report.
from helidon.
I have requested clarification from Metrics spec on media types:
https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!topic/microprofile/t4YgzPpmOsA
My current understanding of the spec would mean that we cannot change the behavior as requested by this issue.
from helidon.
Thanks for asking for clarification. I hope this is a case of the MicroProfile spec being sloppy because the current behavior means that MicroProfile apps (and by extension Helidon apps) can't be scraped by Prometheus -- which is absurd.
from helidon.
@barchetta I agree. The spec may need to be clarified, but I doubt their intent was to ignore quality factors in an Accept
header. We should really return text/plain
for that value of Accept
.
from helidon.
Related Issues (20)
- Helidon 4.0.7: Parameters.first(String) generates java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0 HOT 6
- 4.x Add next() for io.helidon.webserver.http.ServerRequest HOT 3
- session-token-config-file ADP supplier is never selected
- 4.x: Can't resolve `com.google.protobuf:protoc:exe:osx-aarch_64:3.5.1-1` on MacOS 14 on apple silicon
- Upgrade runners to MacOS 14
- 4.x: @HelidonTest / @AddConfig* Provide a config parser by type HOT 1
- Adopt Jersey 3.1.7
- Contexts#wrap(ExecutorService) doesn't propagate OTEL span HOT 7
- MicroProfile Config 3.1 HOT 1
- 4.x The received message "send" should be capitalized in io.helidon.examples.webserver.websocket.MessageBoardEndpoint.
- helidon se 4 native-image build error: HelidonFlavor was found in the image heap.
- MicroProfile Telemetry 1.1
- MicroProfile Rest Client 3.0.1
- Config - HOCON mapped Map has keys detached with extra parent key
- Support Originating IP discovery in Access Logging HOT 1
- 4.x: add tests for multiple JDK releases
- `OpenTelemetryTracer#spanBuilder` always sets parent to active span; should this be left to the developer?
- 4.x: MP `ConfigSource.getOrdinal()` always returns 100 if default ordinals are used
- 4.x: MP Config does not correctly handling per property overriding with config profiles HOT 1
- Weld uses synchronized in ApplicationScopedContextualInstanceStrategy, so carrier thread is pinned HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from helidon.