spec-first / connexion

Connexion is a modern Python web framework that makes spec-first and api-first development easy.
https://connexion.readthedocs.io/en/latest/
Apache License 2.0
4.49k stars 765 forks source link

Expose Request Metrics as JSON endpoint #49

Closed hjacobs closed 8 years ago

hjacobs commented 9 years ago

Connexion could (optionally) expose request metrics via a dedicated "/metrics" endpoint as JSON. The format could be like Dropwizard Metrics (http://metrics.dropwizard.io/3.1.0/manual/servlets/) or Prometheus.

Example metrics JSON (Dropwizard format):

{
  "version": "3.0.0",
  "gauges": {},
  "counters": {},
  "histograms": {},
  "meters": {},
  "timers": {
    "connexion.response.200.GET.pets": {
      "count": 1917,
      "max": 1125,
      "mean": 386.16423467091,
      "min": 295,
      "p50": 383,
      "p75": 383,
      "p95": 383,
      "p98": 460,
      "p99": 460,
      "p999": 460,
      "stddev": 15.285876814113,
      "m15_rate": 0.0027894332885165,
      "m1_rate": 3.7570008143941E-5,
      "m5_rate": 0.0016195023085788,
      "mean_rate": 0.0031567415804972,
      "duration_units": "milliseconds",
      "rate_units": "calls/second"
    },
    "connexion.response.200.GET.pets.{pet_id}": {
      "count": 392373,
      "max": 627,
      "mean": 219.38202968217,
      "min": 163,
      "p50": 218,
      "p75": 224,
      "p95": 249,
      "p98": 265,
      "p99": 425,
      "p999": 425,
      "stddev": 30.77609293132,
      "m15_rate": 0.69320705677888,
      "m1_rate": 0.67804789230544,
      "m5_rate": 0.71816217263666,
      "mean_rate": 0.64605322610366,
      "duration_units": "milliseconds",
      "rate_units": "calls/second"
    }
  }
}
hjacobs commented 9 years ago

http://uwsgi-metrics.readthedocs.org/en/latest/

Jan-M commented 9 years ago

The "status_code" is missing currently.

hjacobs commented 9 years ago

ZMON reference: https://github.com/zalando/zmon-worker/blob/master/zmon_worker_monitor/zmon_worker/functions/http.py#L103

hjacobs commented 8 years ago

This works with uWSGI :smile: