Skip to content

Commit

Permalink
Merge pull request #846 from prometheus/remove-deprecated-function
Browse files Browse the repository at this point in the history
Remove choose_formatter before 0.15.0 release
  • Loading branch information
csmarchbanks authored Oct 11, 2022
2 parents 64328fb + 3babf4b commit e6b9ebf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
10 changes: 0 additions & 10 deletions prometheus_client/exposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
BaseHandler, build_opener, HTTPHandler, HTTPRedirectHandler, HTTPSHandler,
Request,
)
import warnings
from wsgiref.simple_server import make_server, WSGIRequestHandler, WSGIServer

from .openmetrics import exposition as openmetrics
Expand Down Expand Up @@ -249,15 +248,6 @@ def choose_encoder(accept_header: str) -> Tuple[Callable[[CollectorRegistry], by
return generate_latest, CONTENT_TYPE_LATEST


def choose_formatter(accept_header: str) -> Tuple[Callable[[CollectorRegistry], bytes], str]:
warnings.warn(
"choose_formatter is deprecated and will be removed in 0.15.0, please use choose_encoder instead",
DeprecationWarning,
stacklevel=2
)
return choose_encoder(accept_header)


def gzip_accepted(accept_encoding_header: str) -> bool:
accept_encoding_header = accept_encoding_header or ''
for accepted in accept_encoding_header.split(','):
Expand Down
13 changes: 2 additions & 11 deletions tests/test_exposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import threading
import time
import unittest
import warnings

import pytest

Expand All @@ -14,8 +13,8 @@
)
from prometheus_client.core import GaugeHistogramMetricFamily, Timestamp
from prometheus_client.exposition import (
basic_auth_handler, choose_encoder, choose_formatter, default_handler,
MetricsHandler, passthrough_redirect_handler, tls_auth_handler,
basic_auth_handler, choose_encoder, default_handler, MetricsHandler,
passthrough_redirect_handler, tls_auth_handler,
)
import prometheus_client.openmetrics.exposition as openmetrics

Expand Down Expand Up @@ -480,13 +479,5 @@ def test_choose_encoder():
assert choose_encoder(openmetrics.CONTENT_TYPE_LATEST) == (openmetrics.generate_latest, openmetrics.CONTENT_TYPE_LATEST)


def test_choose_formatter():
with warnings.catch_warnings(record=True) as w:
assert choose_formatter('') == (generate_latest, CONTENT_TYPE_LATEST)
assert len(w) == 1
assert issubclass(w[-1].category, DeprecationWarning)
assert "choose_formatter is deprecated" in str(w[-1].message)


if __name__ == '__main__':
unittest.main()

0 comments on commit e6b9ebf

Please sign in to comment.