def get_events(
        self,
        app_id: Optional[str],
        record_ids: Optional[List[str]],
        start_time: Optional[datetime],
    ) -> pd.DataFrame:
        """See [DB.get_events][trulens.core.database.base.DB.get_events]."""
        with self.session.begin() as session:
            where_clauses = []
            if app_id is not None:
                app_id_expr = self._json_extract_otel(
                    "resource_attributes", ResourceAttributes.APP_ID
                )
                where_clauses.append(app_id_expr == app_id)
            if record_ids is not None:
                record_id_expr = self._json_extract_otel(
                    "record_attributes", SpanAttributes.RECORD_ID
                )
                where_clauses.append(record_id_expr.in_(record_ids))
            if start_time is not None:
                where_clauses.append(
                    self.orm.Event.start_timestamp >= start_time
                )

            if len(where_clauses) == 0:
                q = sa.select(self.orm.Event)
            elif len(where_clauses) == 1:
                q = sa.select(self.orm.Event).where(where_clauses[0])
            else:
                q = sa.select(self.orm.Event).where(sa.and_(*where_clauses))
            return pd.read_sql(q, session.bind)
See [DB.get_events][trulens.core.database.base.DB.get_events].
src/core/trulens/core/database/sqlalchemy.py