Compare commits

...

2 Commits

Author SHA1 Message Date
6a28053325 Replace \r\n with \n for prometheus 2025-10-05 18:11:12 +02:00
19a3e7a2eb Fix up the gitignore properly 2025-10-05 18:08:06 +02:00
2 changed files with 7 additions and 4 deletions

5
.gitignore vendored
View File

@@ -1,4 +1,3 @@
obj
.vs/LibreHardwareMonitorExporter
bin/Debug/net8.0
bin/Release/net8.0
.vs
bin

View File

@@ -38,7 +38,11 @@ while (true) {
var body = new StringBuilder();
AppendMetrics(body, computer);
var bytes = Encoding.UTF8.GetBytes(body.ToString());
var text = body.ToString();
// Normalize all line endings to '\n' for Prometheus compatibility
text = text.Replace("\r\n", "\n").Replace("\r", "\n");
if (!text.EndsWith("\n")) text += "\n";
var bytes = Encoding.UTF8.GetBytes(text);
context.Response.StatusCode = 200;
context.Response.ContentType = "text/plain; version=0.0.4";
context.Response.ContentEncoding = Encoding.UTF8;