metrics
stac_fastapi.api.metrics ¶
Prometheus metrics with low-cardinality STAC operation labels.
instrument_app ¶
Instrument a FastAPI app and expose Prometheus metrics.
Must be called during app construction (e.g. from StacApi), before any
requests. Adding middleware after the app has started is not supported.
Raises:
-
ImportError–If
stac-fastapi-api[metrics]is not installed.
Source code in stac_fastapi/api/stac_fastapi/api/metrics.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
record_stac_metrics ¶
record_stac_metrics(info: Info) -> None
Record request count and latency using STAC operation labels.
Source code in stac_fastapi/api/stac_fastapi/api/metrics.py
95 96 97 98 99 100 101 102 103 | |
register_operations ¶
Register or override operation labels for route templates.
Source code in stac_fastapi/api/stac_fastapi/api/metrics.py
68 69 70 | |
resolve_operation ¶
Map a request method and route template to a STAC operation label.
Source code in stac_fastapi/api/stac_fastapi/api/metrics.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |