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 a static metrics server #67

Merged
merged 1 commit into from
May 30, 2023

Conversation

douglascamata
Copy link
Contributor

@douglascamata douglascamata commented May 29, 2023

Extracted from thanos-io/thanos#6377.

Has been useful to have this for testing systems scraping Prometheus metrics, like the Thanos Receiver, with different topologies and configurations.

Copy link
Collaborator

@saswatamcode saswatamcode left a comment

Choose a reason for hiding this comment

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

Nice! This looks good to me! 💪🏻

But maybe we can make it more generic, as this fits quite a lot of use cases? One small suggestion about that!


// NewStaticMetricsServer creates a new nginx server that serves the content of metrics as /metrics endpoint.
// This is useful for testing different metrics scrapers.
func NewStaticMetricsServer(e e2e.Environment, name string, metrics []byte) *InstrumentedRunnable {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is great! I feel like the functionality this provides, goes beyond just metrics scrape.
This can be used for quite a few things apart from Prometheus scraping, like for example serving webpage to web scraper tool or something that polls remote config.

Maybe we can make it a bit generic, and put this in its own package? We can document the metrics scraping as one possible use case then. 🙂

Suggested change
func NewStaticMetricsServer(e e2e.Environment, name string, metrics []byte) *InstrumentedRunnable {
func NewStaticServer(e e2e.Environment, name, filename, endpoint string, content []byte) *InstrumentedRunnable {

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's fine to focus on one small specific aspect for now. We can review later before 1.0 and see if other use cases pop up (:

Copy link
Contributor

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Thanks! 👍🏽


// NewStaticMetricsServer creates a new nginx server that serves the content of metrics as /metrics endpoint.
// This is useful for testing different metrics scrapers.
func NewStaticMetricsServer(e e2e.Environment, name string, metrics []byte) *InstrumentedRunnable {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's fine to focus on one small specific aspect for now. We can review later before 1.0 and see if other use cases pop up (:

@bwplotka bwplotka merged commit 84bb33e into efficientgo:main May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants