From b8218c95c4836e8dc377c2ec01ec59972b1e5274 Mon Sep 17 00:00:00 2001 From: Michal Matloka Date: Fri, 2 Mar 2018 11:22:31 +0100 Subject: Prometheus backend --- docs/backends/prometheus.rst | 18 ++++++++++++++++++ docs/backends/summary.rst | 5 +++-- docs/index.rst | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 docs/backends/prometheus.rst (limited to 'docs') diff --git a/docs/backends/prometheus.rst b/docs/backends/prometheus.rst new file mode 100644 index 0000000..a86b6e6 --- /dev/null +++ b/docs/backends/prometheus.rst @@ -0,0 +1,18 @@ +.. _prometheus_backend: + +Prometheus backend +============= + +To use, add the following dependency to your project:: + + "com.softwaremill.sttp" %% "prometheus-backend" % "1.1.6" + +This backend depends on `Prometheus JVM Client `_. Keep in mind this backend registers histograms and gathers request times, but you have to expose those metrics to `Prometheus `_ e.g. using `prometheus-akka-http `_. + +The Prometheus backend wraps any other backend, for example:: + + implicit val sttpBackend = PrometheusBackend(AkkaHttpBackend()) + +It uses by default ``sttp_request_latency`` histogram name, defined in ``PrometheusBackend.DefaultHistogramName``. It is possible to define custom histograms name by passing function mapping request to histogram name:: + + implicit val sttpBackend = PrometheusBackend(AkkaHttpBackend(), Some(request => request.uri.toString)) \ No newline at end of file diff --git a/docs/backends/summary.rst b/docs/backends/summary.rst index 9fb9dec..11e9b55 100644 --- a/docs/backends/summary.rst +++ b/docs/backends/summary.rst @@ -17,7 +17,7 @@ Below is a summary of all the backends. See the sections on individual backend i ================================ ============================ ================================================ Class Response wrapper Supported stream type ================================ ============================ ================================================ -``HttpURLConnectionBackend`` None (``Id``) n/a +``HttpURLConnectionBackend`` None (``Id``) n/a ``TryHttpURLConnectionBackend`` ``scala.util.Try`` n/a ``AkkaHttpBackend`` ``scala.concurrent.Future`` ``akka.stream.scaladsl.Source[ByteString, Any]`` ``AsyncHttpClientFutureBackend`` ``scala.concurrent.Future`` n/a @@ -33,4 +33,5 @@ Class Response wrapper Supported stream t There are also backends which wrap other backends to provide additional functionality. These include: * ``TryBackend``, which safely wraps any exceptions thrwon by a synchronous backend in ``scala.util.Try`` -* ``BraveBackend``, for Zipkin-compatible distributed tracing. See the :ref:`dedicated section `. \ No newline at end of file +* ``BraveBackend``, for Zipkin-compatible distributed tracing. See the :ref:`dedicated section `. +* ``PrometheusBackend``, for gathering Prometheus-format metrics. See the :ref:`dedicated section `. \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index 1f97373..0ea1cda 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -68,6 +68,7 @@ For more examples, see the :ref:`usage examples ` section. Or ex backends/asynchttpclient backends/okhttp backends/brave + backends/prometheus backends/custom .. toctree:: -- cgit v1.2.3