Index: modules/dli-api/branches/2.0/requirements.txt
===================================================================
--- modules/dli-api/branches/2.0/requirements.txt	(revision 55991)
+++ modules/dli-api/branches/2.0/requirements.txt	(revision 55992)
@@ -19,3 +19,4 @@
 uvicorn==0.7.1
 uvloop==0.12.2
 websockets==7.0
+prometheus-client==0.5.0
Index: modules/dli-api/branches/2.0/eu/dnetlib/metricsMiddleWare.py
===================================================================
--- modules/dli-api/branches/2.0/eu/dnetlib/metricsMiddleWare.py	(nonexistent)
+++ modules/dli-api/branches/2.0/eu/dnetlib/metricsMiddleWare.py	(revision 55992)
@@ -0,0 +1,51 @@
+import time
+
+from prometheus_client import Counter, Gauge, Histogram
+from starlette.middleware.base import BaseHTTPMiddleware, RequestResponseEndpoint
+from starlette.requests import Request
+from starlette.responses import Response
+
+REQUESTS = Counter("starlette_requests_total", "Total count of requests by method and path.", ["method", "path"])
+RESPONSES = Counter(
+    "scholexplorerAPI_responses_total",
+    "Total count of responses by method, path and status codes.",
+    ["method", "path", "status_code"],
+)
+REQUESTS_PROCESSING_TIME = Histogram(
+    "scholexplorerAPI_requests_processing_time_seconds",
+    "Histogram of requests processing time by path (in seconds)",
+    ["method", "path"],
+)
+EXCEPTIONS = Counter(
+    "scholexplorerAPI_exceptions_total",
+    "Histogram of exceptions raised by path and exception type",
+    ["method", "path", "exception_type"],
+)
+REQUESTS_IN_PROGRESS = Gauge(
+    "scholexplorerAPI_requests_in_progress",
+    "Gauge of requests by method and path currently being processed",
+    ["method", "path"],
+)
+
+
+class PrometheusMiddleware(BaseHTTPMiddleware):
+    async def dispatch(self, request: Request, call_next: RequestResponseEndpoint) -> Response:
+        method = request.method
+        path = request.url.path
+
+        REQUESTS_IN_PROGRESS.labels(method=method, path=path).inc()
+        REQUESTS.labels(method=method, path=path).inc()
+        try:
+            before_time = time.time()
+            response = await call_next(request)
+            after_time = time.time()
+        except Exception as e:
+            EXCEPTIONS.labels(method=method, path=path, exception_type=type(e).__name__).inc()
+            raise e from None
+        else:
+            REQUESTS_PROCESSING_TIME.labels(method=method, path=path).observe(after_time - before_time)
+            RESPONSES.labels(method=method, path=path, status_code=response.status_code).inc()
+        finally:
+            REQUESTS_IN_PROGRESS.labels(method=method, path=path).dec()
+
+        return response
Index: modules/dli-api/branches/2.0/eu/dnetlib/metrics_utils.py
===================================================================
--- modules/dli-api/branches/2.0/eu/dnetlib/metrics_utils.py	(nonexistent)
+++ modules/dli-api/branches/2.0/eu/dnetlib/metrics_utils.py	(revision 55992)
@@ -0,0 +1,16 @@
+import os
+
+from prometheus_client import CONTENT_TYPE_LATEST, REGISTRY, CollectorRegistry, generate_latest
+from prometheus_client.multiprocess import MultiProcessCollector
+from starlette.requests import Request
+from starlette.responses import Response
+
+
+def metrics(request: Request) -> Response:
+    if "prometheus_multiproc_dir" in os.environ:
+        registry = CollectorRegistry()
+        MultiProcessCollector(registry)
+    else:
+        registry = REGISTRY
+
+    return Response(generate_latest(registry), media_type=CONTENT_TYPE_LATEST)
Index: modules/dli-api/branches/2.0/main.py
===================================================================
--- modules/dli-api/branches/2.0/main.py	(revision 55991)
+++ modules/dli-api/branches/2.0/main.py	(revision 55992)
@@ -3,9 +3,13 @@
 from v1.api import subapi_v1
 from pympler import muppy, summary
 import logging
+from eu.dnetlib.metrics_utils import metrics 
+from eu.dnetlib.metricsMiddleWare import PrometheusMiddleware
 
 
+
 app = FastAPI()
+
 log = logging.getLogger("scholexplorer")
 log.setLevel(logging.DEBUG)
 fh = logging.FileHandler('api.log')
@@ -14,5 +18,10 @@
 fh.setFormatter(formatter)
 log.addHandler(fh)
 log.info("Scholexplorer Api Restarted")
+
+
+
+app.add_middleware(PrometheusMiddleware)
+app.add_route("/metrics/", metrics)
 app.mount("/v2", subapi_v2)
 app.mount("/v1", subapi_v1)
\ No newline at end of file
