-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add buckets to DistributionSummary & Timer api * change bucket tag to low-high
- Loading branch information
1 parent
191a005
commit 44c68b1
Showing
27 changed files
with
489 additions
and
55 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
client/lookout-api/src/main/java/com/alipay/lookout/api/BucketCounter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* 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 com.alipay.lookout.api; | ||
|
||
/** | ||
* | ||
* @author zhangzhuo | ||
* @version $Id: BucketCounter.java, v 0.1 2018年09月11日 下午1:37 zhangzhuo Exp $ | ||
*/ | ||
public interface BucketCounter extends Metric { | ||
|
||
/** | ||
* enable recording bucket counts | ||
* @param buckets | ||
*/ | ||
void buckets(long[] buckets); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,9 @@ | |
* hitting and http server. | ||
* Created by [email protected] on 2017/2/14. | ||
*/ | ||
public interface DistributionSummary extends Metric { | ||
public interface DistributionSummary extends BucketCounter { | ||
|
||
String BUCKET_TAG_NAME = "_bucket"; | ||
|
||
/** | ||
* Updates the statistics with the specified amount. | ||
|
@@ -45,4 +47,5 @@ public interface DistributionSummary extends Metric { | |
* @return total | ||
*/ | ||
long totalAmount(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,7 @@ | |
package com.alipay.lookout.api; | ||
|
||
/** | ||
* Measurement type | ||
* Created by [email protected] on 2017/2/14. | ||
* Measurement type Created by [email protected] on 2017/2/14. | ||
*/ | ||
public enum Statistic { | ||
rate, | ||
|
@@ -37,6 +36,11 @@ public enum Statistic { | |
*/ | ||
totalAmount, | ||
|
||
/** | ||
* buckets of the amounts recorded | ||
*/ | ||
buckets, | ||
|
||
// /** | ||
// * The sum of the squares of the amounts recorded. | ||
// */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ | |
* A timer metric | ||
* Created by [email protected] on 2017/2/14. | ||
*/ | ||
public interface Timer extends Metric { | ||
public interface Timer extends BucketCounter { | ||
/** | ||
* @param amount Duration of a single event | ||
* @param unit time unit | ||
|
@@ -52,4 +52,5 @@ public interface Timer extends Metric { | |
* @return The total time of recorded events | ||
*/ | ||
long totalTime(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
client/lookout-core/src/main/java/com/alipay/lookout/core/MetricIterable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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 com.alipay.lookout.core; | ||
|
||
import com.alipay.lookout.api.Metric; | ||
|
||
/** | ||
* @author zhangzhuo | ||
* @version $Id: MetricIterable.java, v 0.1 2018年09月17日 下午2:33 zhangzhuo Exp $ | ||
*/ | ||
public interface MetricIterable extends Iterable<Metric> { | ||
} |
62 changes: 62 additions & 0 deletions
62
client/lookout-core/src/main/java/com/alipay/lookout/core/MetricIterator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* 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 com.alipay.lookout.core; | ||
|
||
import com.alipay.lookout.api.Metric; | ||
|
||
import java.util.Iterator; | ||
|
||
/** | ||
* @author zhangzhuo | ||
* @version $Id: MetricIterator.java, v 0.1 2018年09月17日 下午2:29 zhangzhuo Exp $ | ||
*/ | ||
public class MetricIterator implements Iterator<Metric> { | ||
|
||
private final Iterator<Metric> baseIterator; | ||
|
||
private Iterator<Metric> extendIterator; | ||
|
||
public MetricIterator(Iterator<Metric> baseIterator) { | ||
this.baseIterator = baseIterator; | ||
} | ||
|
||
@Override | ||
public boolean hasNext() { | ||
if (extendIterator != null && extendIterator.hasNext()) { | ||
return true; | ||
} | ||
return baseIterator.hasNext(); | ||
} | ||
|
||
@Override | ||
public Metric next() { | ||
if (extendIterator != null && extendIterator.hasNext()) { | ||
return extendIterator.next(); | ||
} | ||
Metric metric = baseIterator.next(); | ||
if (metric instanceof MetricIterable) { | ||
MetricIterable bucketCounter = (MetricIterable) metric; | ||
extendIterator = bucketCounter.iterator(); | ||
} | ||
return metric; | ||
} | ||
|
||
@Override | ||
public void remove() { | ||
baseIterator.remove(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.