public List<TopNRecord> getTopNRecords(TopNRecordsCondition condition) throws IOException {
        TopNCondition topNCondition = new TopNCondition();
        topNCondition.setName(condition.getMetricName());
        final IDManager.ServiceID.ServiceIDDefinition serviceIDDefinition = IDManager.ServiceID.analysisId(
            condition.getServiceId());
        topNCondition.setParentService(serviceIDDefinition.getName());
        // Scope is not required in topN record query.
        // topNCondition.setScope();
        topNCondition.setOrder(condition.getOrder());
        topNCondition.setTopN(condition.getTopN());

        final List<SelectedRecord> selectedRecords = query.readSampledRecords(topNCondition, condition.getDuration()).join();
        List<TopNRecord> list = new ArrayList<>(selectedRecords.size());
        selectedRecords.forEach(record -> {
            TopNRecord top = new TopNRecord();
            top.setStatement(record.getName());
            top.setTraceId(record.getRefId());
            top.setLatency(Long.parseLong(record.getValue()));
            list.add(top);
        });
        return list;
    }
@since 8.0.0 This query is replaced by {@link MetricsQuery}, all queries have been delegated to there.
oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TopNRecordsQuery.java