File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414)
1515from converter .logging_config import configure_logging , LoggingKeys
1616from converter .database import init_db , get_db
17- from converter .tracing import configure_tracing , tag_current_span
17+ from converter .tracing import configure_tracing , tag_current_span , untraced
1818
1919configure_logging ()
2020
@@ -106,7 +106,7 @@ def convert():
106106@app .route ("/health" , methods = ["GET" ])
107107def health_check ():
108108 try :
109- with timeout (5 ):
109+ with untraced (), timeout (5 ):
110110 get_db ().command ("ping" )
111111 db_status = "UP"
112112 except Exception :
Original file line number Diff line number Diff line change 44from opentelemetry .exporter .otlp .proto .http .trace_exporter import OTLPSpanExporter
55from opentelemetry .instrumentation .flask import FlaskInstrumentor
66from opentelemetry .instrumentation .pymongo import PymongoInstrumentor
7+ from opentelemetry .instrumentation .utils import suppress_instrumentation
78from opentelemetry .sdk .resources import SERVICE_NAME , SERVICE_VERSION , Resource
89from opentelemetry .sdk .trace import TracerProvider
910from opentelemetry .sdk .trace .export import BatchSpanProcessor
2324RECIPIENT_ATTRIBUTE = "hubsante.recipient"
2425USE_CASE_ATTRIBUTE = "hubsante.use_case"
2526
27+ # Regexes matched against the request URL: probe/scrape endpoints get no Flask span.
28+ EXCLUDED_URLS = "/health,/metrics"
29+
30+ untraced = suppress_instrumentation
31+
2632
2733def is_tracing_enabled () -> bool :
2834 return os .getenv ("OTEL_SDK_DISABLED" , "false" ).strip ().lower () != "true"
@@ -66,7 +72,7 @@ def configure_tracing(app) -> None:
6672 provider .add_span_processor (BatchSpanProcessor (OTLPSpanExporter ()))
6773 trace .set_tracer_provider (provider )
6874
69- FlaskInstrumentor ().instrument_app (app )
75+ FlaskInstrumentor ().instrument_app (app , excluded_urls = EXCLUDED_URLS )
7076 PymongoInstrumentor ().instrument ()
7177 logger .info (
7278 f"OpenTelemetry tracing configured for service '{ resource .attributes .get (SERVICE_NAME )} '"
You can’t perform that action at this time.
0 commit comments