use of com.google.cloud.trace.core.TraceContext in project activityinfo by bedatadriven.
the class GetSitesHandler method buildQueries.
private void buildQueries() {
TraceContext queryBuildTrace = Trace.startSpan("ai/cmd/GetSites/buildQuery");
queryBuildTime.start();
for (Map.Entry<ResourceId, FormTree> formTreeEntry : formTreeMap.entrySet()) {
addToQueryMap(formTreeEntry, null);
}
if (command.isFetchLinks() && linkedFormTreeMap != null) {
for (Map.Entry<ResourceId, FormTree> linkedFormTreeEntry : linkedFormTreeMap.entrySet()) {
for (ActivityLink activityLink : activityLinkMap.get(CuidAdapter.getLegacyIdFromCuid(linkedFormTreeEntry.getKey()))) {
addToQueryMap(linkedFormTreeEntry, activityLink);
}
}
}
queryBuildTime.stop();
Trace.endSpan(queryBuildTrace);
}
use of com.google.cloud.trace.core.TraceContext in project activityinfo by bedatadriven.
the class GetSitesHandler method fetchActivityMetadata.
private void fetchActivityMetadata(Filter filter) {
TraceContext activityMetadataTrace = Trace.startSpan("ai/cmd/GetSites/fetchActivityMetadata");
try {
metadataTime.start();
activities = loadMetadata(filter);
} catch (SQLException excp) {
throw new CommandException("Could not fetch metadata from server");
} finally {
metadataTime.stop();
Trace.endSpan(activityMetadataTrace);
}
}
use of com.google.cloud.trace.core.TraceContext in project activityinfo by bedatadriven.
the class GetSitesHandler method fetchLinkedActivityMetadata.
private void fetchLinkedActivityMetadata(List<Integer> linkedActivitiesToFetch) {
TraceContext linkedActivityMetadataTrace = Trace.startSpan("ai/cmd/GetSites/fetchLinkedActivityMetadata");
try {
metadataTime.start();
LOGGER.info("Fetching Linked Activity Metadata for: " + Arrays.toString(linkedActivitiesToFetch.toArray()));
Filter linkedFilter = new Filter();
linkedFilter.addRestriction(DimensionType.Activity, linkedActivitiesToFetch);
linkedActivities = loadMetadata(linkedFilter);
} catch (SQLException excp) {
throw new CommandException("Could not fetch linked activity metadata from server");
} finally {
metadataTime.stop();
Trace.endSpan(linkedActivityMetadataTrace);
}
}
use of com.google.cloud.trace.core.TraceContext in project activityinfo by bedatadriven.
the class GetSitesHandler method mergeMonthlyRootSites.
private void mergeMonthlyRootSites() {
TraceContext monthlyMergeTrace = Trace.startSpan("ai/cmd/GetSites/executeBatch/mergeMonthlySites");
monthlyMergeTime.start();
for (SiteDTO monthlySite : monthlySiteList) {
if (monthlyRootSiteMap.containsKey(monthlySite.getInstanceId())) {
SiteDTO rootSite = monthlyRootSiteMap.get(monthlySite.getInstanceId());
monthlySite.setLocation(rootSite.getLocation());
monthlySite.setProject(rootSite.getProject());
monthlySite.setPartner(rootSite.getPartner());
}
}
monthlyMergeTime.stop();
Trace.endSpan(monthlyMergeTrace);
}
use of com.google.cloud.trace.core.TraceContext in project activityinfo by bedatadriven.
the class GetSitesHandler method queryFormTrees.
private void queryFormTrees() {
TraceContext formTreeQueryTrace = Trace.startSpan("ai/cmd/GetSites/queryFormTrees");
treeTime.start();
Set<ResourceId> formIds = new HashSet<>();
Set<ResourceId> linkedFormIds = new HashSet<>();
List<Integer> linkedActivitiesToFetch = new ArrayList<>();
ResourceId activityFormId;
for (Activity activity : activities.values()) {
if (reject(activity)) {
continue;
}
activityFormId = activity.getSiteFormClassId();
formIds.add(activityFormId);
if (activity.isMonthly() && command.isFetchAllReportingPeriods()) {
formIds.add(CuidAdapter.reportingPeriodFormClass(CuidAdapter.getLegacyIdFromCuid(activityFormId)));
}
if (command.isFetchLinks()) {
for (LinkedActivity linkedActivity : activity.getLinkedActivities()) {
linkedActivitiesToFetch.add(linkedActivity.getActivityId());
linkedFormIds.add(CuidAdapter.activityFormClass(linkedActivity.getActivityId()));
}
}
}
formTreeMap = batchFormTreeBuilder.queryTrees(formIds);
if (!linkedActivitiesToFetch.isEmpty()) {
fetchLinkedActivityMetadata(linkedActivitiesToFetch);
linkedFormTreeMap = batchFormTreeBuilder.queryTrees(linkedFormIds);
}
treeTime.stop();
Trace.endSpan(formTreeQueryTrace);
}
Aggregations