Refactor getTraceIdsByAnnotation() by pulling out queryParts