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):
60
60
class FastAPIOpenTelemetryInstrument (OpenTelemetryInstrument ):
61
61
bootstrap_config : FastAPIConfig
62
62
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
+
63
70
def bootstrap (self ) -> None :
64
71
super ().bootstrap ()
65
72
FastAPIInstrumentor .instrument_app (
66
73
app = self .bootstrap_config .application ,
67
74
tracer_provider = get_tracer_provider (),
68
- excluded_urls = "," .join (self .bootstrap_config . opentelemetry_excluded_urls ),
75
+ excluded_urls = "," .join (self ._build_excluded_urls () ),
69
76
)
70
77
71
78
def teardown (self ) -> None :
Original file line number Diff line number Diff line change @@ -66,12 +66,19 @@ class LitestarLoggingInstrument(LoggingInstrument):
66
66
class LitestarOpenTelemetryInstrument (OpenTelemetryInstrument ):
67
67
bootstrap_config : LitestarConfig
68
68
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
+
69
76
def bootstrap (self ) -> None :
70
77
super ().bootstrap ()
71
78
self .bootstrap_config .application_config .middleware .append (
72
79
OpenTelemetryConfig (
73
80
tracer_provider = get_tracer_provider (),
74
- exclude = self .bootstrap_config . opentelemetry_excluded_urls ,
81
+ exclude = self ._build_excluded_urls () ,
75
82
).middleware ,
76
83
)
77
84
You can’t perform that action at this time.
0 commit comments