File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
lite_bootstrap/bootstrappers Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -60,12 +60,19 @@ class FastAPILoggingInstrument(LoggingInstrument):
6060class FastAPIOpenTelemetryInstrument (OpenTelemetryInstrument ):
6161 bootstrap_config : FastAPIConfig
6262
63+ def _build_excluded_urls (self ) -> list [str ]:
64+ excluded_urls = [* self .bootstrap_config .opentelemetry_excluded_urls ]
65+ for one_url in (self .bootstrap_config .health_checks_path , self .bootstrap_config .prometheus_metrics_path ):
66+ if one_url and one_url not in excluded_urls :
67+ excluded_urls .append (one_url )
68+ return excluded_urls
69+
6370 def bootstrap (self ) -> None :
6471 super ().bootstrap ()
6572 FastAPIInstrumentor .instrument_app (
6673 app = self .bootstrap_config .application ,
6774 tracer_provider = get_tracer_provider (),
68- excluded_urls = "," .join (self .bootstrap_config . opentelemetry_excluded_urls ),
75+ excluded_urls = "," .join (self ._build_excluded_urls () ),
6976 )
7077
7178 def teardown (self ) -> None :
Original file line number Diff line number Diff line change @@ -66,12 +66,19 @@ class LitestarLoggingInstrument(LoggingInstrument):
6666class LitestarOpenTelemetryInstrument (OpenTelemetryInstrument ):
6767 bootstrap_config : LitestarConfig
6868
69+ def _build_excluded_urls (self ) -> list [str ]:
70+ excluded_urls = [* self .bootstrap_config .opentelemetry_excluded_urls ]
71+ for one_url in (self .bootstrap_config .health_checks_path , self .bootstrap_config .prometheus_metrics_path ):
72+ if one_url and one_url not in excluded_urls :
73+ excluded_urls .append (one_url )
74+ return excluded_urls
75+
6976 def bootstrap (self ) -> None :
7077 super ().bootstrap ()
7178 self .bootstrap_config .application_config .middleware .append (
7279 OpenTelemetryConfig (
7380 tracer_provider = get_tracer_provider (),
74- exclude = self .bootstrap_config . opentelemetry_excluded_urls ,
81+ exclude = self ._build_excluded_urls () ,
7582 ).middleware ,
7683 )
7784
You can’t perform that action at this time.
0 commit comments