final boolean isBySegment = query.getContextBySegment(false);
final boolean shouldFinalize = query.getContextFinalize(true);
final Query<T> queryToRun;
final Function<T, T> finalizerFn;
final MetricManipulationFn metricManipulationFn;
if (shouldFinalize) {
queryToRun = query.withOverriddenContext(ImmutableMap.<String, Object>of("finalize", false));
metricManipulationFn = MetricManipulatorFns.finalizing();