def _check_cross_format_records(
    app_name: Optional[str] = None,
    app_ids: Optional[List[str]] = None,
) -> tuple[int, int]:
    """Check record counts in both OTEL and non-OTEL formats.

    Returns:
        Tuple of (otel_count, non_otel_count)
    """
    session = get_session()
    otel_count = 0
    non_otel_count = 0

    if isinstance(session.connector.db, SQLAlchemyDB):
        db = session.connector.db  # type: ignore

        with db.session.begin() as session_ctx:  # type: ignore
            # Check OTEL records (EVENT table)
            query = sa.select(sa.func.count(db.orm.Event.event_id))  # type: ignore

            if app_name:
                # For OTEL events, app_name is in resource_attributes JSON
                app_name_expr = db._json_extract_otel(
                    "resource_attributes", ResourceAttributes.APP_NAME
                )
                query = query.where(app_name_expr == app_name)
            elif app_ids:
                # For OTEL events, app_id is in resource_attributes JSON
                app_id_expr = db._json_extract_otel(
                    "resource_attributes", ResourceAttributes.APP_ID
                )
                query = query.where(app_id_expr.in_(app_ids))

            result = session_ctx.execute(query).scalar()
            otel_count = result or 0

            # Check non-OTEL records (RECORD table)
            query = sa.select(sa.func.count(db.orm.Record.record_id))  # type: ignore

            if app_name:
                # For non-OTEL records, need to join with AppDefinition
                query = query.join(db.orm.Record.app).where(  # type: ignore
                    db.orm.AppDefinition.app_name == app_name  # type: ignore
                )
            elif app_ids:
                query = query.where(db.orm.Record.app_id.in_(app_ids))  # type: ignore

            result = session_ctx.execute(query).scalar()
            non_otel_count = result or 0

    return otel_count, non_otel_count
Check record counts in both OTEL and non-OTEL formats.

    Returns:
        Tuple of (otel_count, non_otel_count)
    
src/dashboard/trulens/dashboard/utils/dashboard_utils.py