Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for openmetrics 0.0.1 besides 1.0.0 #1640

Merged
merged 10 commits into from
Aug 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed lint issue
  • Loading branch information
rg2011 committed Aug 8, 2024
commit 373c87f8d07aff5786a6b4832d953306c9ba4bb5
8 changes: 4 additions & 4 deletions lib/services/stats/statsRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,18 @@ function openmetricsHandler(req, res) {
res.status(406).send('Unsupported charset');
return;
}
let selectedVersion = supportedVersions[0];
switch (req.accepts(['text/plain', 'application/openmetrics-text'])) {
case 'application/openmetrics-text':
let version = supportedVersions[0];
if (requestedVersions.length > 0) {
version = matchPreferredValue(requestedVersions, supportedVersions);
if (!version) {
selectedVersion = matchPreferredValue(requestedVersions, supportedVersions);
if (!selectedVersion) {
logger.error(statsContext, 'Unsupported openmetrics version: %s', requestedVersions);
res.status(406).send('Unsupported openmetrics version');
return;
}
}
contentType = `application/openmetrics-text; version=${version}; charset=utf-8`;
contentType = `application/openmetrics-text; version=${selectedVersion}; charset=utf-8`;
break;
case 'text/plain':
// Text/plain only supports version 0.0.4
Expand Down
Loading