def on_add_record(
        self,
        ctx: core_instruments._RecordingContext,
        func: Callable,
        sig: Signature,
        bindings: BoundArguments,
        ret: Any,
        error: Any,
        perf: base_schema.Perf,
        cost: base_schema.Cost,
        existing_record: Optional[record_schema.Record] = None,
        final: bool = False,
    ) -> record_schema.Record:
        """Called by instrumented methods if they use _new_record to construct a
        "record call list.

        See
        [WithInstrumentCallbacks.on_add_record][trulens.core.instruments.WithInstrumentCallbacks.on_add_record].
        """
        if is_otel_tracing_enabled():
            raise RuntimeError("Not supported with OTel tracing enabled!")

        def build_record(
            calls: Iterable[record_schema.RecordAppCall],
            record_metadata: serial_utils.JSON,
            existing_record: Optional[record_schema.Record] = None,
        ) -> record_schema.Record:
            calls = list(calls)

            assert len(calls) > 0, "No information recorded in call."

            if bindings is not None:
                if existing_record is None:
                    main_in = json_utils.jsonify(
                        self.main_input(func, sig, bindings)
                    )
                else:
                    main_in = existing_record.main_input
            else:
                main_in = None

            if error is None:
                assert bindings is not None, "No bindings despite no error."
                if final:
                    main_out = self.main_output(func, sig, bindings, ret)
                else:
                    main_out = f"TruLens: Record not yet finalized: {ret}"
            else:
                main_out = None

            updates = dict(
                main_input=main_in,
                main_output=json_utils.jsonify(main_out),
                main_error=json_utils.jsonify(error),
                calls=calls,
                cost=cost,
                perf=perf,
                app_id=self.app_id,
                tags=self.tags,
                meta=json_utils.jsonify(record_metadata),
            )

            if existing_record is not None:
                existing_record.update(**updates)
            else:
                existing_record = record_schema.Record(**updates)

            return existing_record

        # Finishing record needs to be done in a thread lock, done there:
        record = ctx.finish_record(
            build_record, existing_record=existing_record
        )

        if error is not None:
            # May block on DB.
            self._handle_error(record=record, error=error)
            raise error

        # Only continue with the feedback steps if the record is final.
        if not final:
            return record

        # Will block on DB, but not on feedback evaluation, depending on
        # FeedbackMode:
        record.feedback_and_future_results = self._handle_record(record=record)
        if record.feedback_and_future_results is not None:
            record.feedback_results = [
                tup[1] for tup in record.feedback_and_future_results
            ]

        if record.feedback_and_future_results is None:
            return record

        if self.feedback_mode == feedback_schema.FeedbackMode.WITH_APP_THREAD:
            # Add the record to ones with pending feedback.

            self.records_with_pending_feedback_results.add(record)

        elif self.feedback_mode == feedback_schema.FeedbackMode.WITH_APP:
            # If in blocking mode ("WITH_APP"), wait for feedbacks to finished
            # evaluating before returning the record.

            record.wait_for_feedback_results()

        return record
Called by instrumented methods if they use _new_record to construct a
        "record call list.

        See
        [WithInstrumentCallbacks.on_add_record][trulens.core.instruments.WithInstrumentCallbacks.on_add_record].
        
src/core/trulens/core/app.py