2323import asyncio
2424import contextlib
2525import datetime
26+ import logging
2627
2728import fastapi
2829import prometheus_client
2930import requests
3031import typer
3132import uvicorn
3233from garf_executors .entrypoints import utils as garf_utils
34+ from opentelemetry .instrumentation .fastapi import FastAPIInstrumentor
3335from typing_extensions import Annotated
3436
3537import garf_exporter
3638from garf_exporter import exporter_service
39+ from garf_exporter .entrypoints .tracer import initialize_tracer
3740
3841typer_app = typer .Typer ()
3942
@@ -49,8 +52,8 @@ def healthcheck(host: str, port: int) -> bool:
4952 the delay between exports. If this delta if greater than 1.5 check is failed.
5053
5154 Args:
52- host: Hostname gaarf -exporter http server (i.e. localhost).
53- port: Port gaarf -exporter http server is running (i.e. 8000).
55+ host: Hostname garf -exporter http server (i.e. localhost).
56+ port: Port garf -exporter http server is running (i.e. 8000).
5457
5558
5659 Returns:
@@ -79,10 +82,12 @@ def healthcheck(host: str, port: int) -> bool:
7982 return not is_lagged_export
8083
8184
85+ initialize_tracer ()
8286app = fastapi .FastAPI (debug = False )
8387exporter = garf_exporter .GarfExporter ()
8488metrics_app = prometheus_client .make_asgi_app (registry = exporter .registry )
8589app .mount ('/metrics' , metrics_app )
90+ FastAPIInstrumentor .instrument_app (app )
8691
8792
8893async def start_metric_generation (
@@ -158,7 +163,7 @@ def main(
158163 logger : Annotated [
159164 str ,
160165 typer .Option (help = 'Type of logging' ),
161- ] = 'rich ' ,
166+ ] = 'local ' ,
162167 namespace : Annotated [
163168 str ,
164169 typer .Option (help = 'Namespace prefix for Prometheus' ),
@@ -223,6 +228,7 @@ async def start_uvicorn():
223228 await server .serve ()
224229
225230 asyncio .run (start_uvicorn ())
231+ logging .shutdown ()
226232
227233
228234if __name__ == '__main__' :
0 commit comments