Skip to content

Commit

Permalink
Optimize metrics of minute dimensionality persistence, don't save met…
Browse files Browse the repository at this point in the history
…ric of being default value. (#8066)

Optimize metrics of minute dimensionality persistence.
- The value of metrics, which has declaration of the default value and current value equals the default value logically, the whole row wouldn't be pushed into database.
- Add self-observability `metrics_persistence_skipped` metric to measure the number of skipped metrics.
- SLA(percent function), Apdex, AvgLong(MAL mostly) metrics are mostly optimized because of this. Such as a full-failing error(0% successful rate) and unhealthy(apdex=0) are not costing the storage.
- Hour/Day dimensionalities metrics are not changed, as they cover long duration.
- Fix `max` function in OAL doesn't support negative long.
  • Loading branch information
wu-sheng authored Nov 4, 2021
1 parent 4cd39b3 commit c0994ee
Show file tree
Hide file tree
Showing 20 changed files with 247 additions and 14 deletions.
9 changes: 6 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ Release Notes.
* Fix ElasticSearch implementation of `queryMetricsValues` and `readLabeledMetricsValues` doesn't fill default values
when no available data in the ElasticSearch server.
* Fix config yaml data type conversion bug when meets special character like !.
* Optimize metrics of minute dimensionality persistence. The value of metrics, which has declaration of the default
value and current value equals the default value logically, the whole row wouldn't be pushed into database.
* Fix `max` function in OAL doesn't support negative long.

#### UI

Expand All @@ -62,9 +65,9 @@ Release Notes.
#### Documentation

* Enhance documents about the data report and query protocols.
* Restructure documents about receivers and fetchers.
1. Remove general receiver and fetcher docs
2. Add more specific menu with docs to help users to find documents easier.
* Restructure documents about receivers and fetchers.
1. Remove general receiver and fetcher docs
2. Add more specific menu with docs to help users to find documents easier.

All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/101?closed=1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,14 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(entityId, getTimeBucket());
}

@Override
public boolean haveDefault() {
return true;
}

@Override
public boolean isDefaultValue() {
return value == 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,14 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(entityId, getTimeBucket());
}

@Override
public boolean haveDefault() {
return true;
}

@Override
public boolean isDefaultValue() {
return value == 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,14 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(getEntityId(), getTimeBucket());
}

@Override
public boolean haveDefault() {
return true;
}

@Override
public boolean isDefaultValue() {
return value == 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,14 @@ public void calculate() {
public int getValue() {
return value;
}

@Override
public boolean haveDefault() {
return true;
}

@Override
public boolean isDefaultValue() {
return value == 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,15 @@ public final boolean combine(Metrics metrics) {
public void calculate() {
this.value = total / getDurationInMinute();
}

@Override
public boolean haveDefault() {
return true;
}

@Override
public boolean isDefaultValue() {
return value == 0;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,14 @@ public final boolean combine(Metrics metrics) {
@Override
public void calculate() {
}

@Override
public boolean haveDefault() {
return true;
}

@Override
public boolean isDefaultValue() {
return value == 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,15 @@ public final boolean combine(Metrics metrics) {
public final void calculate() {
this.value = this.summation / this.count;
}

@Override
public boolean haveDefault() {
return true;
}

@Override
public boolean isDefaultValue() {
// Value in the query stage will ignore decimal places after a decimal point
return Double.valueOf(value).longValue() == 0;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.oap.server.core.analysis.metrics;

/**
* HavingDefaultValue interface defines a capability for the metric implementations, which has the declaration of the
* default value.
*
* For the declared metrics, the OAP server would skip the persistence of minute dimensionality metrics to reduce
* resource costs for the database, when the value of the metric is the default.
*/
public interface HavingDefaultValue {
/**
* @return true if the implementation of this metric has the definition of default value.
*/
default boolean haveDefault() {
return false;
}

/**
* @return true when the latest value equals the default value.
*/
default boolean isDefaultValue() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,14 @@ public final boolean combine(Metrics metrics) {
public final void calculate() {
this.value = this.summation / this.count;
}

@Override
public boolean haveDefault() {
return true;
}

@Override
public boolean isDefaultValue() {
return value == 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,15 @@ public final boolean combine(Metrics metrics) {
@Override
public void calculate() {
}

@Override
public boolean haveDefault() {
return true;
}

@Override
public boolean isDefaultValue() {
// Value in the query stage will ignore decimal places after a decimal point
return Double.valueOf(value).longValue() == 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.SourceFrom;
import org.apache.skywalking.oap.server.core.storage.annotation.Column;

/**
*
**/
@MetricsFunction(functionName = "max")
public abstract class MaxLongMetrics extends Metrics implements LongValueHolder {

Expand All @@ -36,7 +33,7 @@ public abstract class MaxLongMetrics extends Metrics implements LongValueHolder
@Getter
@Setter
@Column(columnName = VALUE, dataType = Column.ValueDataType.COMMON_VALUE)
private long value;
private long value = Long.MIN_VALUE;

@Entrance
public final void combine(@SourceFrom long count) {
Expand All @@ -55,4 +52,14 @@ public final boolean combine(Metrics metrics) {
@Override
public void calculate() {
}

@Override
public boolean haveDefault() {
return true;
}

@Override
public boolean isDefaultValue() {
return value == 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@EqualsAndHashCode(of = {
"timeBucket"
})
public abstract class Metrics extends StreamData implements StorageData {
public abstract class Metrics extends StreamData implements StorageData, HavingDefaultValue {

public static final String TIME_BUCKET = "time_bucket";
public static final String ENTITY_ID = "entity_id";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,15 @@ public final boolean combine(Metrics metrics) {
@Override
public void calculate() {
}

@Override
public boolean haveDefault() {
return true;
}

@Override
public boolean isDefaultValue() {
// Value in the query stage will ignore decimal places after a decimal point
return Double.valueOf(value).longValue() == 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,14 @@ public final boolean combine(Metrics metrics) {
@Override
public void calculate() {
}

@Override
public boolean haveDefault() {
return true;
}

@Override
public boolean isDefaultValue() {
return value == 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,14 @@ public void calculate() {
public int getValue() {
return percentage;
}

@Override
public boolean haveDefault() {
return true;
}

@Override
public boolean isDefaultValue() {
return percentage == 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,14 @@ public final void calculate() {
}
}
}

@Override
public boolean haveDefault() {
return true;
}

@Override
public boolean isDefaultValue() {
return value == 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,14 @@ public void calculate() {
public int getValue() {
return percentage;
}

@Override
public boolean haveDefault() {
return true;
}

@Override
public boolean isDefaultValue() {
return percentage == 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,14 @@ public final boolean combine(Metrics metrics) {
@Override
public void calculate() {
}

@Override
public boolean haveDefault() {
return true;
}

@Override
public boolean isDefaultValue() {
return value == 0;
}
}
Loading

0 comments on commit c0994ee

Please sign in to comment.