
org.glowroot.agent.fat.storage.TracePointQueryBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of glowroot-agent-it-harness Show documentation
Show all versions of glowroot-agent-it-harness Show documentation
Glowroot Agent Integration Test Harness
/*
* Copyright 2013-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.glowroot.agent.fat.storage;
import java.util.List;
import java.util.Locale;
import javax.annotation.Nullable;
import org.glowroot.agent.shaded.google.common.base.Strings;
import org.glowroot.agent.shaded.google.common.collect.ImmutableList;
import org.glowroot.agent.shaded.google.common.collect.Lists;
import org.checkerframework.checker.tainting.qual.Untainted;
import org.immutables.value.Value;
import org.glowroot.agent.shaded.glowroot.common.live.LiveTraceRepository.TraceKind;
import org.glowroot.agent.shaded.glowroot.common.live.LiveTraceRepository.TracePointFilter;
import org.glowroot.agent.shaded.glowroot.common.live.StringComparator;
import org.glowroot.agent.shaded.glowroot.common.util.Styles;
import org.glowroot.agent.shaded.glowroot.storage.repo.TraceRepository.TraceQuery;
class TracePointQueryBuilder {
private final TraceKind traceKind;
private final TraceQuery query;
private final TracePointFilter filter;
private final int limit;
TracePointQueryBuilder(TraceKind traceKind, TraceQuery query, TracePointFilter filter,
int limit) {
this.traceKind = traceKind;
this.query = query;
this.filter = filter;
this.limit = limit;
}
// capture time lower bound is non-inclusive so that aggregate data intervals can be mapped
// to their trace points (aggregate data intervals are non-inclusive on lower bound and
// inclusive on upper bound)
ParameterizedSql getParameterizedSql() {
ParameterizedSqlBuilder builder = new ParameterizedSqlBuilder();
builder.appendText("select trace.id, trace.capture_time, trace.duration_nanos, trace.error"
+ " from trace");
ParameterizedSql criteria = getAttributeCriteria();
if (criteria == null) {
builder.appendText(" where");
} else {
builder.appendText(", trace_attribute attr where attr.trace_id = trace.id"
+ " and attr.capture_time > ? and attr.capture_time <= ? and" + criteria.sql());
builder.addArg(query.from());
builder.addArg(query.to());
builder.addArgs(criteria.args());
}
builder.appendText(" trace.capture_time > ? and trace.capture_time <= ?");
builder.addArg(query.from());
builder.addArg(query.to());
appendTraceKindCriteria(builder);
appendTransactionTypeCriteria(builder);
appendTransactionNameCriteria(builder);
appendDurationNanosCriteria(builder);
appendHeadlineCriteria(builder);
appendErrorCriteria(builder);
appendUserCriteria(builder);
appendOrderByAndLimit(builder);
return builder.build();
}
private @Nullable ParameterizedSql getAttributeCriteria() {
String sql = "";
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy