Skip to content

Conversation

@adelsz
Copy link
Contributor

@adelsz adelsz commented Dec 6, 2025

Running the official example for native histograms always returns empty response on the metrics protobuf endpoint:

> cargo run --example native_histograms --features="http-listener protobuf"
Recording metrics... Check http://127.0.0.1:9000/metrics
Native histograms will only be visible in protobuf format.
Try: curl -H 'Accept: application/vnd.google.protobuf' http://127.0.0.1:9000/metrics
Recorded 1 samples
Recorded 101 samples
Recorded 201 samples
Recorded 301 samples
Recorded 401 samples
Recorded 501 samples
Recorded 601 samples
Recorded 701 samples
Recorded 801 samples
Recorded 901 samples
Metrics server will continue running. Access http://127.0.0.1:9000/metrics
❯  curl -H 'Accept: application/vnd.google.protobuf' http://127.0.0.1:9000/metrics -v
*   Trying 127.0.0.1:9000...
* Connected to 127.0.0.1 (127.0.0.1) port 9000
> GET /metrics HTTP/1.1
> Host: 127.0.0.1:9000
> User-Agent: curl/8.7.1
> Accept: application/vnd.google.protobuf
>
* Request completely sent off
< HTTP/1.1 200 OK
< content-type: application/vnd.google.protobuf; proto=io.prometheus.client.MetricFamily; encoding=delimited
< content-length: 0
< date: Sat, 06 Dec 2025 19:26:00 GMT
<
* Connection #0 to host 127.0.0.1 left intact

This is caused by not setting the metric_type to Histogram so it skipped when encoding protobuf.

Comment on lines 219 to 222
let Some(metric_type) = metric_type else {
// Skip empty metric families
continue;
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop skips the None metric types, which the native histogram was.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh, good catch. 👍🏻

@tobz tobz merged commit 31b9ffe into metrics-rs:main Dec 7, 2025
14 checks passed
@tobz tobz added C-exporter Component: exporters such as Prometheus, TCP, etc. E-simple Effort: simple. T-bug Type: bug. S-awaiting-release Status: awaiting a release to be considered fixed/implemented. labels Dec 7, 2025
@tobz
Copy link
Member

tobz commented Dec 7, 2025

Released in [email protected].

Thanks again for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-exporter Component: exporters such as Prometheus, TCP, etc. E-simple Effort: simple. S-awaiting-release Status: awaiting a release to be considered fixed/implemented. T-bug Type: bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants