use of com.google.cloud.trace.core.TraceContext in project activityinfo by bedatadriven.
the class GetSitesHandler method executeBatch.
private void executeBatch() {
TraceContext batchExecutionTrace = Trace.startSpan("ai/cmd/GetSites/executeBatch");
try {
queryExecTime.start();
TraceContext fetchTrace = Trace.startSpan("ai/cmd/GetSites/executeBatch/fetchColumns");
queryFetchTime.start();
builder.execute(batch);
linkedBuilder.execute(linkedBatch);
queryFetchTime.stop();
Trace.endSpan(fetchTrace);
} catch (Exception excp) {
throw new RuntimeException("Failed to execute query batch", excp);
}
TraceContext dataExtractionTrace = Trace.startSpan("ai/cmd/GetSites/executeBatch/extractColumnData");
queryExtractTime.start();
for (Runnable handler : queryResultHandlers) {
handler.run();
}
queryExtractTime.stop();
Trace.endSpan(dataExtractionTrace);
queryExecTime.stop();
Trace.endSpan(batchExecutionTrace);
}
use of com.google.cloud.trace.core.TraceContext in project activityinfo by bedatadriven.
the class GetSitesHandler method sort.
private void sort() {
if (sortInfo != null && !siteList.isEmpty()) {
TraceContext sortTrace = Trace.startSpan("ai/cmd/GetSites/executeBatch/sortSites");
SiteComparator comparator = new SiteComparator(sortInfo);
Collections.sort(siteList, comparator);
Trace.endSpan(sortTrace);
}
}
use of com.google.cloud.trace.core.TraceContext in project activityinfo by bedatadriven.
the class GetSyncRegionUpdatesHandler method execute.
@Override
public CommandResult execute(GetSyncRegionUpdates cmd, User user) throws CommandException {
Log.info("Fetching updates for " + cmd.getRegionPath() + ", localVersion = " + cmd.getLocalVersion());
UpdateBuilder builder;
if (cmd.getRegionType().equals(DbUpdateBuilder.REGION_TYPE)) {
builder = injector.getInstance(DbUpdateBuilder.class);
} else if (cmd.getRegionType().equals(AdminUpdateBuilder.REGION_TYPE)) {
builder = injector.getInstance(AdminUpdateBuilder.class);
} else if (cmd.getRegionType().equals(LocationUpdateBuilder.REGION_TYPE)) {
builder = injector.getInstance(LocationUpdateBuilder.class);
} else if (cmd.getRegionType().equals(SiteUpdateBuilder.REGION_TYPE)) {
builder = injector.getInstance(SiteUpdateBuilder.class);
} else if (cmd.getRegionType().equals(TableDefinitionUpdateBuilder.REGION_TYPE)) {
builder = injector.getInstance(TableDefinitionUpdateBuilder.class);
} else if (cmd.getRegionType().equals(CountryUpdateBuilder.REGION_TYPE)) {
builder = injector.getInstance(CountryUpdateBuilder.class);
} else {
throw new CommandException("Unknown sync region: " + cmd.getRegionPath());
}
TraceContext traceContext = Trace.startSpan("/ai/cmd/sync/" + prefix(cmd.getRegionPath()));
try {
return builder.build(user, cmd);
} catch (Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
throw new RuntimeException(e);
} finally {
Trace.endSpan(traceContext);
}
}
Aggregations