![JAR search and dependency download from the Maven repository](/logo.png)
org.glowroot.local.store.TracePointQueryBase Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2013-2015 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.local.store;
import java.util.List;
import java.util.Locale;
import javax.annotation.Nullable;
import org.glowroot.shaded.google.common.base.Strings;
import org.glowroot.shaded.google.common.collect.Lists;
import org.checkerframework.checker.tainting.qual.Untainted;
import org.immutables.value.Value;
@Value.Immutable
public abstract class TracePointQueryBase {
public abstract long from();
public abstract long to();
public abstract long durationLow(); // nanoseconds
public abstract @Nullable Long durationHigh(); // nanoseconds
public abstract @Nullable String transactionType();
public abstract @Nullable StringComparator transactionNameComparator();
public abstract @Nullable String transactionName();
public abstract @Nullable StringComparator headlineComparator();
public abstract @Nullable String headline();
public abstract @Nullable StringComparator errorComparator();
public abstract @Nullable String error();
public abstract @Nullable StringComparator userComparator();
public abstract @Nullable String user();
public abstract @Nullable String customAttributeName();
public abstract @Nullable StringComparator customAttributeValueComparator();
public abstract @Nullable String customAttributeValue();
@Value.Default
public boolean slowOnly() {
return false;
}
@Value.Default
public boolean errorOnly() {
return false;
}
public abstract int 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, trace.error from trace");
ParameterizedSql criteria = getCustomAttributeCriteria();
if (criteria == null) {
builder.appendText(" where");
} else {
builder.appendText(", trace_custom_attribute attr where attr.trace_id = trace.id and"
+ " attr.capture_time > ? and attr.capture_time <= ? and" + criteria.sql());
builder.addArg(from());
builder.addArg(to());
builder.addArgs(criteria.args());
}
builder.appendText(" trace.capture_time > ? and trace.capture_time <= ?");
builder.addArg(from());
builder.addArg(to());
appendDurationCriteria(builder);
appendTransactionTypeCriteria(builder);
appendSlowOnlyCriteria(builder);
appendErrorOnlyCriteria(builder);
appendTransactionNameCriteria(builder);
appendHeadlineCriteria(builder);
appendErrorCriteria(builder);
appendUserCriteria(builder);
appendOrderByAndLimit(builder);
return builder.build();
}
private @Nullable ParameterizedSql getCustomAttributeCriteria() {
String sql = "";
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy