@@ -235,18 +235,10 @@ async def _generate_research_summary(
235235
236236 import time as _time
237237
238- try :
239- from opentelemetry import trace as _otel_trace # type: ignore
240- except Exception :
241- _otel_trace = None # type: ignore
242238 from redis_sre_agent .observability .llm_metrics import record_llm_call_metrics
243239
244240 _t0 = _time .perf_counter ()
245- _tr = _otel_trace .get_tracer (__name__ ) if _otel_trace else None
246- if _tr :
247- with _tr .start_as_current_span ("llm.call" , attributes = {"llm.component" : "runbook" }):
248- response = await self .llm .ainvoke ([HumanMessage (content = prompt )])
249- else :
241+ with tracer .start_as_current_span ("llm.call" , attributes = {"llm.component" : "runbook" }):
250242 response = await self .llm .ainvoke ([HumanMessage (content = prompt )])
251243 record_llm_call_metrics (
252244 component = "runbook" , llm = self .llm , response = response , start_time = _t0
@@ -480,20 +472,10 @@ async def _evaluate_runbook(self, runbook: GeneratedRunbook) -> RunbookEvaluatio
480472
481473 import time as _time
482474
483- try :
484- from opentelemetry import trace as _otel_trace # type: ignore
485- except Exception :
486- _otel_trace = None # type: ignore
487475 from redis_sre_agent .observability .llm_metrics import record_llm_call_metrics
488476
489477 _t0 = _time .perf_counter ()
490- _tr = _otel_trace .get_tracer (__name__ ) if _otel_trace else None
491- if _tr :
492- with _tr .start_as_current_span ("llm.call" , attributes = {"llm.component" : "runbook" }):
493- response = await self .llm .ainvoke (
494- [SystemMessage (content = system_prompt ), HumanMessage (content = user_prompt )]
495- )
496- else :
478+ with tracer .start_as_current_span ("llm.call" , attributes = {"llm.component" : "runbook" }):
497479 response = await self .llm .ainvoke (
498480 [SystemMessage (content = system_prompt ), HumanMessage (content = user_prompt )]
499481 )
0 commit comments