@@ -239,7 +239,11 @@ async def iter(
239239 entered_span : AbstractSpan | None = None
240240 if span is None :
241241 if self .auto_instrument : # pragma: no branch
242- entered_span = stack .enter_context (logfire_span ('run graph {graph.name}' , graph = self ))
242+ # Separate variable because we actually don't want logfire's f-string magic here,
243+ # we want the span_name to be preformatted for other backends
244+ # as requested in https://github.com/pydantic/pydantic-ai/issues/3173.
245+ span_name = f'run graph { self .name } '
246+ entered_span = stack .enter_context (logfire_span (span_name , graph = self ))
243247 else :
244248 entered_span = stack .enter_context (span )
245249 traceparent = None if entered_span is None else get_traceparent (entered_span )
@@ -724,7 +728,11 @@ async def main():
724728
725729 with ExitStack () as stack :
726730 if self .graph .auto_instrument : # pragma: no branch
727- stack .enter_context (logfire_span ('run node {node_id}' , node_id = node_id , node = node ))
731+ # Separate variable because we actually don't want logfire's f-string magic here,
732+ # we want the span_name to be preformatted for other backends
733+ # as requested in https://github.com/pydantic/pydantic-ai/issues/3173.
734+ span_name = f'run node { node_id } '
735+ stack .enter_context (logfire_span (span_name , node_id = node_id , node = node ))
728736
729737 async with self .persistence .record_run (node_snapshot_id ):
730738 ctx = GraphRunContext (state = self .state , deps = self .deps )
0 commit comments