MCPcopy Index your code
hub / github.com/prometheus/client_python / _bake_output

Function _bake_output

prometheus_client/exposition.py:116–128  ·  view source on GitHub ↗

Bake output for metrics output.

(registry, accept_header, accept_encoding_header, params, disable_compression)

Source from the content-addressed store, hash-verified

114
115
116def _bake_output(registry, accept_header, accept_encoding_header, params, disable_compression):
117 """Bake output for metrics output."""
118 # Choose the correct plain text format of the output.
119 encoder, content_type = choose_encoder(accept_header)
120 if 'name[]' in params:
121 registry = registry.restricted_registry(params['name[]'])
122 output = encoder(registry)
123 headers = [('Content-Type', content_type)]
124 # If gzip encoding required, gzip the output.
125 if not disable_compression and gzip_accepted(accept_encoding_header):
126 output = gzip.compress(output)
127 headers.append(('Content-Encoding', 'gzip'))
128 return '200 OK', headers, output
129
130
131def make_wsgi_app(registry: Collector = REGISTRY, disable_compression: bool = False) -> Callable:

Callers 5

getMethod · 0.90
prometheus_appFunction · 0.85
prometheus_appFunction · 0.85
do_GETMethod · 0.85
prometheus_handlerFunction · 0.85

Calls 3

choose_encoderFunction · 0.85
gzip_acceptedFunction · 0.85
restricted_registryMethod · 0.80

Tested by

no test coverage detected