Repository: jenkinsci/prometheus-plugin (java)

Issue:
jenkins_builds_last_build_result_ordinal is missing in the  prometheus
### Jenkins and plugins versions report

<details>

  <summary>Environment</summary>

  <!-- Paste your environment details below -->
  ```
Jenkins: 2.414.2 
prometheus:2.3.2
metrics:4.2.18-442.v02e107157925
  ```

</details>


### What Operating System are you using (both controller, and any agents involved in the problem)?

OS: Linux

### Reproduction steps

We have observed changes in Prometheus version 2.3.2. The last build results ordinal gauge doesn't track the status of the running job. Previously, we were using Prometheus version 2.2.3 and didn't encounter such issues. Can someone help us with this?

### Expected Results

 The last build results ordinal gauge should track the status of the running job

```
# TYPE default_jenkins_builds_last_build_result_ordinal gauge
default_jenkins_builds_last_build_result_ordinal{jenkins_job="content/job-X.Y.Z-rhel8",repo="NA",buildable="true",} -1.0"
```


### Actual Results

we see the build job in default_jenkins_builds_last_build_result_ordinal gauge after it gets completed

```
# TYPE default_jenkins_builds_last_build_result_ordinal gauge
default_jenkins_builds_last_build_result_ordinal{jenkins_job="content/job-X.Y.Z-rhel8",repo="NA",buildable="true",} 1.0"
```

### Anything else?

_No response_

### Are you interested in contributing a fix?

_No response_

Pull request:
Fixing result ordinal when run is currently building
Fixes #597 

### Checklist

- [x] Includes tests covering the new functionality?
- [x] Follows CONTRIBUTING rules



Patch:
diff --git a/README.md b/README.md
index 88a0d73..8c3c2ac 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
 # Jenkins Prometheus Metrics Plugin
 
 ## About
-Jenkins Prometheus Plugin expose an endpoint (default `/prometheus`) with metrics where a Prometheus Server can scrape.
+Jenkins Prometheus Plugin expose an endpoint (default `/prometheus/`) with metrics where a Prometheus Server can scrape.
 
 Documentation can be found [here](https://plugins.jenkins.io/prometheus)
 
@@ -13,6 +13,11 @@ Please note that the documentation is a WIP.
 - Metrics from [Metrics-plugin](https://github.com/jenkinsci/metrics-plugin)
 - Metrics from this plugin. Refer [Prometheus-plugin](docs/metrics/index.md)
 
+## Scraping the endpoint
+The endpoint you've configured or the default endpoint `/prometheus/` in case you didn't configure an endpoint, needs to 
+end with a trailing slash when you configure the endpoint in your scraping tool. If you miss adding the trailing slash
+you'll get a 302 response with a redirection to the endpoint ending with a slash. Some tools cannot handle this well.
+
 ## Configuring the plugin
 You can find some examples in this documentation [Configuring Plugin](docs/configuration/configuration.md)
 
@@ -20,7 +25,7 @@ You can find some examples in this documentation [Configuring Plugin](docs/confi
 
 `PROMETHEUS_NAMESPACE` Prefix of metric (Default: `default`).
 
-`PROMETHEUS_ENDPOINT` REST Endpoint (Default: `prometheus`)
+`PROMETHEUS_ENDPOINT` REST Endpoint (Default: `/prometheus/`)
 
 `COLLECTING_METRICS_PERIOD_IN_SECONDS` Async task period in seconds (Default: `120` seconds)
 
diff --git a/src/main/java/org/jenkinsci/plugins/prometheus/collectors/builds/BuildResultOrdinalGauge.java b/src/main/java/org/jenkinsci/plugins/prometheus/collectors/builds/BuildResultOrdinalGauge.java
index 84125e5..3558baf 100644
--- a/src/main/java/org/jenkinsci/plugins/prometheus/collectors/builds/BuildResultOrdinalGauge.java
+++ b/src/main/java/org/jenkinsci/plugins/prometheus/collectors/builds/BuildResultOrdinalGauge.java
@@ -37,17 +37,16 @@ public class BuildResultOrdinalGauge extends BuildsMetricCollector<Run<?, ?>, Ga
             return;
         }
 
+        int ordinal = -1;
         Result result = jenkinsObject.getResult();
-        if (result == null) {
-            return;
+        if (null != result) {
+            ordinal = result.ordinal;
         }
 
         if (labelValues == null) {
-            this.collector.labels().set(result.ordinal);
+            this.collector.labels().set(ordinal);
         } else {
-            this.collector.labels(labelValues).set(result.ordinal);
+            this.collector.labels(labelValues).set(ordinal);
         }
-
-
     }
 }


Test patch:
diff --git a/src/test/java/org/jenkinsci/plugins/prometheus/collectors/builds/BuildResultOrdinalGaugeTest.java b/src/test/java/org/jenkinsci/plugins/prometheus/collectors/builds/BuildResultOrdinalGaugeTest.java
index 4e1ad4f..cda3516 100644
--- a/src/test/java/org/jenkinsci/plugins/prometheus/collectors/builds/BuildResultOrdinalGaugeTest.java
+++ b/src/test/java/org/jenkinsci/plugins/prometheus/collectors/builds/BuildResultOrdinalGaugeTest.java
@@ -13,7 +13,7 @@ public class BuildResultOrdinalGaugeTest extends MockedRunCollectorTest {
 
 
     @Test
-    public void testNothingCalculatedAsRunNotYetOver() {
+    public void testResultIsMinusOneWhenRunResultIsNull() {
 
         Mockito.when(mock.getResult()).thenReturn(null);
 
@@ -24,7 +24,11 @@ public class BuildResultOrdinalGaugeTest extends MockedRunCollectorTest {
         List<Collector.MetricFamilySamples> collect = sut.collect();
 
         Assertions.assertEquals(1, collect.size());
-        Assertions.assertEquals(0, collect.get(0).samples.size(), "Would expect no result");
+        Assertions.assertEquals(1, collect.get(0).samples.size(), "Would expect one result");
+
+        Assertions.assertEquals("default_jenkins_builds_build_result_ordinal", collect.get(0).samples.get(0).name);
+        Assertions.assertEquals(-1.0, collect.get(0).samples.get(0).value);
+
     }
 
     @Test