Skip to content

Add generated OpenMetrics scrape bodies to HTTP blackhole#1895

Merged
scottopell merged 8 commits into
mainfrom
sopell/openmetrics
Jul 2, 2026
Merged

Add generated OpenMetrics scrape bodies to HTTP blackhole#1895
scottopell merged 8 commits into
mainfrom
sopell/openmetrics

Conversation

@scottopell

@scottopell scottopell commented May 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a generated OpenMetrics scrape body for the HTTP blackhole, so scrape-based tests can serve realistic metrics without embedding static response text.

Changed

  • Added a configurable OpenMetrics generator for counters, gauges, histograms, summaries, target metadata, and build metadata.
  • OpenMetrics bodies are precomputed at startup and served as static bytes on the HTTP response path.
  • OpenMetrics response headers now derive from the body variant, so selecting the body automatically serves the matching OpenMetrics content type.
  • Added validation for metric-name prefixes, bucket and quantile bounds, duplicate quantiles, enabled TYPE metadata, and disabled-family edge cases.
  • Ensured generated series remain unique when configured counts exceed label-pool cardinality by adding deterministic per-series labels.
  • Preserved existing tagged static-body YAML while also accepting singleton-map body variants for generated OpenMetrics config.

Why

This gives scrape tests a deterministic, spec-shaped OpenMetrics target while keeping HTTP blackhole configuration concise and backward-compatible.

@datadog-official

This comment has been minimized.

@blt blt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is looking good. @scottopell give me a ping when it's open for review and I'll have a look.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a reusable lading_payload::openmetrics generator and wires it into the HTTP blackhole so it can serve a generated Prometheus/OpenMetrics-style text exposition body via a new openmetrics body_variant, avoiding embedding large static response strings in configs.

Changes:

  • Added lading_payload::openmetrics module that deterministically precomputes a scrape response body plus tests (unit + proptest).
  • Extended HTTP blackhole config with body_variant.openmetrics and precomputes the body during Http::new.
  • Added an example config and documented the new variant in the changelog.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
lading/src/blackhole/http.rs Adds openmetrics body variant, deserialization support, and a config test for the new variant.
lading_payload/src/openmetrics.rs Implements deterministic, precomputed text exposition generator with validation and tests.
lading_payload/src/lib.rs Exposes the new openmetrics module and re-exports OpenMetrics.
examples/lading-openmetrics.yaml Provides an example HTTP blackhole configuration serving generated scrape text.
CHANGELOG.md Notes the new HTTP blackhole openmetrics body variant.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lading_payload/src/openmetrics.rs
Comment thread lading_payload/src/openmetrics.rs
@scottopell scottopell force-pushed the sopell/openmetrics branch from faed763 to 3bfa033 Compare June 25, 2026 18:46
@scottopell scottopell marked this pull request as ready for review June 25, 2026 20:44
@scottopell scottopell requested a review from a team as a code owner June 25, 2026 20:44

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3bfa0338d2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lading_payload/src/openmetrics.rs
Comment thread lading_payload/src/openmetrics.rs
Comment thread lading_payload/src/openmetrics.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6ee6ef9262

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lading_payload/src/openmetrics.rs
Comment thread lading/src/blackhole/http.rs Outdated
Comment thread lading/src/blackhole/http.rs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 410ae60554

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lading_payload/src/openmetrics.rs Outdated
Comment thread lading_payload/src/openmetrics.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 67dae111da

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lading_payload/src/openmetrics.rs Outdated
Comment thread lading_payload/src/openmetrics.rs
@scottopell scottopell changed the title Add OpenMetrics HTTP blackhole body Add generated OpenMetrics scrape bodies to HTTP blackhole Jul 1, 2026
@scottopell

Copy link
Copy Markdown
Contributor Author

@blt the bots are happy, ready for a human stamp

@scottopell scottopell merged commit 5761294 into main Jul 2, 2026
32 checks passed
@scottopell scottopell deleted the sopell/openmetrics branch July 2, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants