Skip to content

Conversation

@ioggstream
Copy link
Contributor

What does this PR do?

Add registry parameter to start_http_server, so you can serve data
from a custom registry.

How it's implemented

Added:

  • the optional named parameter registry to start_http_server
  • create a MetricHandler tied to the passed registry via MetricHandler.factory

How do you use it

Create a new or a multiprocess registry
Pass registry=myregistry to start_http_server.

from prometheus_client import multiprocess, start_http_server
from prometheus_client import Counter
...
# Serve myregistry metrics.
myregistry = CollectorRegistry()
start_http_server(8000, registry=myregistry)

# Server core.REGISTRY metrics
start_http_server(8001) 
...

  Pass a registry to start_http_server via a MetricsHandler
    factory implemented as a staticmethod of the existing class.
@brian-brazil
Copy link
Contributor

Why are you opening a new PR?

@ioggstream
Copy link
Contributor Author

I split the patch in two. This is just the custom registry part. No multiprocess.

@brian-brazil brian-brazil merged commit 24d4d95 into prometheus:master Dec 13, 2017
@brian-brazil
Copy link
Contributor

Thanks!

@ioggstream
Copy link
Contributor Author

You welcome :D your suggestions were precious to implement that in a few lines 👍

@ioggstream ioggstream deleted the 222-pass-registry-to-handler branch December 14, 2017 19:25
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.

2 participants