IServiceReferenceMetricUIDAO.java 5.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.apache.skywalking.apm.collector.storage.dao.ui;

21
import java.util.List;
22
import org.apache.skywalking.apm.collector.storage.base.dao.DAO;
23 24
import org.apache.skywalking.apm.collector.storage.table.MetricSource;
import org.apache.skywalking.apm.collector.storage.ui.common.Step;
25 26

/**
彭勇升 pengys 已提交
27 28 29
 * Interface to be implemented for execute database query operation
 * from {@link org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable#TABLE}.
 *
30
 * @author peng-yongsheng
彭勇升 pengys 已提交
31 32
 * @see org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable
 * @see org.apache.skywalking.apm.collector.storage.StorageModule
33
 */
34 35
public interface IServiceReferenceMetricUIDAO extends DAO {

彭勇升 pengys 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
    /**
     * Returns the service reference metrics which call the given service id
     * that collected between start time bucket and end time bucket.
     *
     * <p>SQL as: select FRONT_SERVICE_ID, sum(TRANSACTION_CALLS), sum(TRANSACTION_ERROR_CALLS),
     * sum(TRANSACTION_DURATION_SUM), sum(TRANSACTION_ERROR_DURATION_SUM)
     * from SERVICE_REFERENCE_METRIC
     * where TIME_BUCKET ge ${startTimeBucket} and TIME_BUCKET le ${endTimeBucket}
     * and SOURCE_VALUE = ${metricSource}
     * and BEHIND_SERVICE_ID = ${behindServiceId}
     * group by FRONT_SERVICE_ID
     *
     * <p>Use {@link org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder#build(Step, String)}
     * to generate table name which mixed with step name.
     *
     * @param step the step which represent time formats
     * @param startTimeBucket start time bucket
     * @param endTimeBucket end time bucket
     * @param metricSource source of this metric, server side or client side
     * @param behindServiceId the callee service id
     * @return not nullable result list
     */
58
    List<ServiceReferenceMetric> getFrontServices(Step step, long startTimeBucket, long endTimeBucket,
59 60
        MetricSource metricSource, int behindServiceId);

彭勇升 pengys 已提交
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
    /**
     * Returns the service reference metrics which call from the given service id
     * that collected between start time bucket and end time bucket.
     *
     * <p>SQL as: select FRONT_SERVICE_ID, sum(TRANSACTION_CALLS), sum(TRANSACTION_ERROR_CALLS),
     * sum(TRANSACTION_DURATION_SUM), sum(TRANSACTION_ERROR_DURATION_SUM)
     * from SERVICE_REFERENCE_METRIC
     * where TIME_BUCKET ge ${startTimeBucket} and TIME_BUCKET le ${endTimeBucket}
     * and SOURCE_VALUE = ${metricSource}
     * and BEHIND_SERVICE_ID = ${frontServiceId}
     * group by BEHIND_SERVICE_ID
     *
     * <p>Use {@link org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder#build(Step, String)}
     * to generate table name which mixed with step name.
     *
     * @param step the step which represent time formats
     * @param startTimeBucket start time bucket
     * @param endTimeBucket end time bucket
     * @param metricSource source of this metric, server side or client side
     * @param frontServiceId the caller service id
     * @return not nullable result list
     */
83
    List<ServiceReferenceMetric> getBehindServices(Step step, long startTimeBucket, long endTimeBucket,
84 85
        MetricSource metricSource, int frontServiceId);

86 87 88 89 90 91 92
    class ServiceReferenceMetric {
        private int source;
        private int target;
        private long calls;
        private long errorCalls;
        private long durations;
        private long errorDurations;
93

94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
        public int getSource() {
            return source;
        }

        public void setSource(int source) {
            this.source = source;
        }

        public int getTarget() {
            return target;
        }

        public void setTarget(int target) {
            this.target = target;
        }

        public long getCalls() {
            return calls;
        }

        public void setCalls(long calls) {
            this.calls = calls;
        }

        public long getErrorCalls() {
            return errorCalls;
        }

        public void setErrorCalls(long errorCalls) {
            this.errorCalls = errorCalls;
        }

        public long getDurations() {
            return durations;
        }

        public void setDurations(long durations) {
            this.durations = durations;
        }

        public long getErrorDurations() {
            return errorDurations;
        }

        public void setErrorDurations(long errorDurations) {
            this.errorDurations = errorDurations;
        }
    }
142
}