Copilot commented on code in PR #52175: URL: https://github.com/apache/airflow/pull/52175#discussion_r2166681704
########## airflow-core/src/airflow/traces/otel_tracer.py: ########## @@ -260,24 +261,24 @@ def _new_span( links = [] if start_as_current: - span = tracer.start_as_current_span( - name=span_name, - context=parent_context, - links=links, - start_time=datetime_to_nano(start_time), - ) - else: - span = tracer.start_span( + return tracer.start_as_current_span( name=span_name, context=parent_context, links=links, start_time=datetime_to_nano(start_time), ) - current_span_ctx = trace.set_span_in_context(NonRecordingSpan(span.get_span_context())) - # We have to manually make the span context as the active context. - # If the span needs to be injected into the carrier, then this is needed to make sure - # that the injected context will point to the span context that was just created. - attach(current_span_ctx) + + span = tracer.start_span( Review Comment: The else branch in _new_span assigns the span but never returns it, causing an inconsistent return behavior. Consider adding a 'return span' after creating the span to ensure the function always returns a value as declared. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org