You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2020/07/29 07:53:28 UTC
[GitHub] [skywalking] hanahmily opened a new pull request #5187: Add AvgLabeledFunction to ingest multiple labels
hanahmily opened a new pull request #5187:
URL: https://github.com/apache/skywalking/pull/5187
Related to #5186, to introduce a new meter function.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking] wu-sheng commented on a change in pull request #5187: Add AvgLabeledFunction to ingest multiple labels
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #5187:
URL: https://github.com/apache/skywalking/pull/5187#discussion_r461244567
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/meter/function/AvgLabeledFunction.java
##########
@@ -0,0 +1,215 @@
+/*
+ * 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.meter.function;
+
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.apache.skywalking.oap.server.core.Const;
+import org.apache.skywalking.oap.server.core.UnexpectedException;
+import org.apache.skywalking.oap.server.core.analysis.manual.instance.InstanceTraffic;
+import org.apache.skywalking.oap.server.core.analysis.meter.MeterEntity;
+import org.apache.skywalking.oap.server.core.analysis.metrics.DataTable;
+import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
+import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
+import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
+import org.apache.skywalking.oap.server.core.storage.annotation.Column;
+
+@MeterFunction(functionName = "avgLabeled")
+@ToString
+public abstract class AvgLabeledFunction extends Metrics implements AcceptableValue<DataTable> {
+ protected static final String SUMMATION = "summation";
+ protected static final String COUNT = "count";
+ protected static final String VALUE = "value";
+
+ @Setter
+ @Getter
+ @Column(columnName = ENTITY_ID, length = 512)
+ private String entityId;
+
+ /**
+ * Service ID is required for sort query.
+ */
+ @Setter
+ @Getter
+ @Column(columnName = InstanceTraffic.SERVICE_ID)
+ private String serviceId;
+
+ @Getter
+ @Setter
+ @Column(columnName = SUMMATION, storageOnly = true)
+ protected DataTable summation = new DataTable(30);
+ @Getter
+ @Setter
+ @Column(columnName = COUNT, storageOnly = true)
+ protected DataTable count = new DataTable(30);
+ @Getter
+ @Setter
+ @Column(columnName = VALUE, dataType = Column.ValueDataType.LABELED_VALUE, storageOnly = true)
+ private DataTable value = new DataTable(30);
+
+ @Override
+ public final void combine(Metrics metrics) {
+ AvgLabeledFunction longAvgMetrics = (AvgLabeledFunction) metrics;
+ summation.append(longAvgMetrics.summation);
+ count.append(longAvgMetrics.count);
+ }
+
+ @Override
+ public final void calculate() {
+ List<String> keys = count.sortedKeys(Comparator.naturalOrder());
Review comment:
I think you should add `keys` instead of using `sortedKeys`? I noticed you used `Comparator#naturalOrder`, but base on the `Comparators#NaturalOrderComparator`, you still have to loop and reorder hashmap, it still does this.
```
@Override
public int compare(Comparable<Object> c1, Comparable<Object> c2) {
return c1.compareTo(c2);
}
```
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/meter/function/AvgLabeledFunction.java
##########
@@ -0,0 +1,215 @@
+/*
+ * 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.meter.function;
+
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.apache.skywalking.oap.server.core.Const;
+import org.apache.skywalking.oap.server.core.UnexpectedException;
+import org.apache.skywalking.oap.server.core.analysis.manual.instance.InstanceTraffic;
+import org.apache.skywalking.oap.server.core.analysis.meter.MeterEntity;
+import org.apache.skywalking.oap.server.core.analysis.metrics.DataTable;
+import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
+import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
+import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
+import org.apache.skywalking.oap.server.core.storage.annotation.Column;
+
+@MeterFunction(functionName = "avgLabeled")
+@ToString
+public abstract class AvgLabeledFunction extends Metrics implements AcceptableValue<DataTable> {
+ protected static final String SUMMATION = "summation";
+ protected static final String COUNT = "count";
+ protected static final String VALUE = "value";
+
+ @Setter
+ @Getter
+ @Column(columnName = ENTITY_ID, length = 512)
+ private String entityId;
+
+ /**
+ * Service ID is required for sort query.
+ */
+ @Setter
+ @Getter
+ @Column(columnName = InstanceTraffic.SERVICE_ID)
+ private String serviceId;
+
+ @Getter
+ @Setter
+ @Column(columnName = SUMMATION, storageOnly = true)
+ protected DataTable summation = new DataTable(30);
+ @Getter
+ @Setter
+ @Column(columnName = COUNT, storageOnly = true)
+ protected DataTable count = new DataTable(30);
+ @Getter
+ @Setter
+ @Column(columnName = VALUE, dataType = Column.ValueDataType.LABELED_VALUE, storageOnly = true)
+ private DataTable value = new DataTable(30);
+
+ @Override
+ public final void combine(Metrics metrics) {
+ AvgLabeledFunction longAvgMetrics = (AvgLabeledFunction) metrics;
+ summation.append(longAvgMetrics.summation);
+ count.append(longAvgMetrics.count);
+ }
+
+ @Override
+ public final void calculate() {
+ Set<String> keys = count.keys();
+ for (String key : keys) {
+ Long s = summation.get(key);
+ if (Objects.isNull(s)) {
+ continue;
+ }
+ Long c = count.get(key);
+ if (Objects.isNull(c)) {
+ continue;
+ }
+ long result = s / c;
+ if (result == 0 && s > 0) {
+ result = 1;
+ }
+ value.put(key, result);
+ }
+ }
+
+ @Override
+ public Metrics toHour() {
+ AvgLabeledFunction metrics = (AvgLabeledFunction) createNew();
+ metrics.setEntityId(getEntityId());
+ metrics.setTimeBucket(toTimeBucketInHour());
+ metrics.setServiceId(getServiceId());
+ metrics.setSummation(getSummation());
+ metrics.setCount(getCount());
+ return metrics;
+ }
+
+ @Override
+ public Metrics toDay() {
+ AvgLabeledFunction metrics = (AvgLabeledFunction) createNew();
+ metrics.setEntityId(getEntityId());
+ metrics.setTimeBucket(toTimeBucketInDay());
+ metrics.setServiceId(getServiceId());
+ metrics.setSummation(getSummation());
+ metrics.setCount(getCount());
+ return metrics;
+ }
+
+ @Override
+ public int remoteHashCode() {
+ return entityId.hashCode();
+ }
+
+ @Override
+ public void deserialize(final RemoteData remoteData) {
+ this.setCount(new DataTable(remoteData.getDataObjectStrings(0)));
+ this.setSummation(new DataTable(remoteData.getDataObjectStrings(1)));
+ setTimeBucket(remoteData.getDataLongs(0));
+
+ this.entityId = remoteData.getDataStrings(0);
+ this.serviceId = remoteData.getDataStrings(1);
+ }
+
+ @Override
+ public RemoteData.Builder serialize() {
+ RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
+ remoteBuilder.addDataObjectStrings(count.toStorageData());
+ remoteBuilder.addDataObjectStrings(summation.toStorageData());
+ remoteBuilder.addDataLongs(getTimeBucket());
+
+ remoteBuilder.addDataStrings(entityId);
+ remoteBuilder.addDataStrings(serviceId);
+
+ return remoteBuilder;
+ }
+
+ @Override
+ public String id() {
+ return getTimeBucket() + Const.ID_CONNECTOR + entityId;
+ }
+
+ @Override
+ public void accept(final MeterEntity entity, final DataTable value) {
+ this.entityId = entity.id();
+ this.serviceId = entity.serviceId();
+ this.summation.append(value);
+ DataTable c = new DataTable();
+ value.sortedKeys(Comparator.naturalOrder()).forEach(key -> c.put(key, 1L));
Review comment:
There is another sort.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking] codecov[bot] edited a comment on pull request #5187: Add AvgLabeledFunction to ingest multiple labels
Posted by GitBox <gi...@apache.org>.
codecov[bot] edited a comment on pull request #5187:
URL: https://github.com/apache/skywalking/pull/5187#issuecomment-664685744
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking] hanahmily commented on a change in pull request #5187: Add AvgLabeledFunction to ingest multiple labels
Posted by GitBox <gi...@apache.org>.
hanahmily commented on a change in pull request #5187:
URL: https://github.com/apache/skywalking/pull/5187#discussion_r461322818
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/meter/function/AvgLabeledFunction.java
##########
@@ -0,0 +1,215 @@
+/*
+ * 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.meter.function;
+
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.apache.skywalking.oap.server.core.Const;
+import org.apache.skywalking.oap.server.core.UnexpectedException;
+import org.apache.skywalking.oap.server.core.analysis.manual.instance.InstanceTraffic;
+import org.apache.skywalking.oap.server.core.analysis.meter.MeterEntity;
+import org.apache.skywalking.oap.server.core.analysis.metrics.DataTable;
+import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
+import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
+import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
+import org.apache.skywalking.oap.server.core.storage.annotation.Column;
+
+@MeterFunction(functionName = "avgLabeled")
+@ToString
+public abstract class AvgLabeledFunction extends Metrics implements AcceptableValue<DataTable> {
+ protected static final String SUMMATION = "summation";
+ protected static final String COUNT = "count";
+ protected static final String VALUE = "value";
+
+ @Setter
+ @Getter
+ @Column(columnName = ENTITY_ID, length = 512)
+ private String entityId;
+
+ /**
+ * Service ID is required for sort query.
+ */
+ @Setter
+ @Getter
+ @Column(columnName = InstanceTraffic.SERVICE_ID)
+ private String serviceId;
+
+ @Getter
+ @Setter
+ @Column(columnName = SUMMATION, storageOnly = true)
+ protected DataTable summation = new DataTable(30);
+ @Getter
+ @Setter
+ @Column(columnName = COUNT, storageOnly = true)
+ protected DataTable count = new DataTable(30);
+ @Getter
+ @Setter
+ @Column(columnName = VALUE, dataType = Column.ValueDataType.LABELED_VALUE, storageOnly = true)
+ private DataTable value = new DataTable(30);
+
+ @Override
+ public final void combine(Metrics metrics) {
+ AvgLabeledFunction longAvgMetrics = (AvgLabeledFunction) metrics;
+ summation.append(longAvgMetrics.summation);
+ count.append(longAvgMetrics.count);
+ }
+
+ @Override
+ public final void calculate() {
+ List<String> keys = count.sortedKeys(Comparator.naturalOrder());
Review comment:
yep, for a hashmap, sorting is unnecessary.
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/meter/function/AvgLabeledFunction.java
##########
@@ -0,0 +1,215 @@
+/*
+ * 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.meter.function;
+
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.apache.skywalking.oap.server.core.Const;
+import org.apache.skywalking.oap.server.core.UnexpectedException;
+import org.apache.skywalking.oap.server.core.analysis.manual.instance.InstanceTraffic;
+import org.apache.skywalking.oap.server.core.analysis.meter.MeterEntity;
+import org.apache.skywalking.oap.server.core.analysis.metrics.DataTable;
+import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
+import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
+import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
+import org.apache.skywalking.oap.server.core.storage.annotation.Column;
+
+@MeterFunction(functionName = "avgLabeled")
+@ToString
+public abstract class AvgLabeledFunction extends Metrics implements AcceptableValue<DataTable> {
+ protected static final String SUMMATION = "summation";
+ protected static final String COUNT = "count";
+ protected static final String VALUE = "value";
+
+ @Setter
+ @Getter
+ @Column(columnName = ENTITY_ID, length = 512)
+ private String entityId;
+
+ /**
+ * Service ID is required for sort query.
+ */
+ @Setter
+ @Getter
+ @Column(columnName = InstanceTraffic.SERVICE_ID)
+ private String serviceId;
+
+ @Getter
+ @Setter
+ @Column(columnName = SUMMATION, storageOnly = true)
+ protected DataTable summation = new DataTable(30);
+ @Getter
+ @Setter
+ @Column(columnName = COUNT, storageOnly = true)
+ protected DataTable count = new DataTable(30);
+ @Getter
+ @Setter
+ @Column(columnName = VALUE, dataType = Column.ValueDataType.LABELED_VALUE, storageOnly = true)
+ private DataTable value = new DataTable(30);
+
+ @Override
+ public final void combine(Metrics metrics) {
+ AvgLabeledFunction longAvgMetrics = (AvgLabeledFunction) metrics;
+ summation.append(longAvgMetrics.summation);
+ count.append(longAvgMetrics.count);
+ }
+
+ @Override
+ public final void calculate() {
+ List<String> keys = count.sortedKeys(Comparator.naturalOrder());
Review comment:
done
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking] wu-sheng merged pull request #5187: Add AvgLabeledFunction to ingest multiple labels
Posted by GitBox <gi...@apache.org>.
wu-sheng merged pull request #5187:
URL: https://github.com/apache/skywalking/pull/5187
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking] codecov[bot] commented on pull request #5187: Add AvgLabeledFunction to ingest multiple labels
Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on pull request #5187:
URL: https://github.com/apache/skywalking/pull/5187#issuecomment-664685744
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/5187?src=pr&el=h1) Report
> Merging [#5187](https://codecov.io/gh/apache/skywalking/pull/5187?src=pr&el=desc) into [master](https://codecov.io/gh/apache/skywalking/commit/15b30009d2cb582ad0e1e70a5695a20323701622&el=desc) will **decrease** coverage by `53.26%`.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/skywalking/pull/5187?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #5187 +/- ##
============================================
- Coverage 53.26% 0.00% -53.27%
============================================
Files 1460 150 -1310
Lines 31403 3767 -27636
Branches 3459 452 -3007
============================================
- Hits 16728 0 -16728
+ Misses 13864 3767 -10097
+ Partials 811 0 -811
```
| [Impacted Files](https://codecov.io/gh/apache/skywalking/pull/5187?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [...king/apm/util/RunnableWithExceptionProtection.java](https://codecov.io/gh/apache/skywalking/pull/5187/diff?src=pr&el=tree#diff-YXBtLWNvbW1vbnMvYXBtLXV0aWwvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL3V0aWwvUnVubmFibGVXaXRoRXhjZXB0aW9uUHJvdGVjdGlvbi5qYXZh) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (-2.00%)` | |
| [...ywalking/apm/agent/core/logging/core/LogLevel.java](https://codecov.io/gh/apache/skywalking/pull/5187/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvbG9nZ2luZy9jb3JlL0xvZ0xldmVsLmphdmE=) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (-1.00%)` | |
| [...ywalking/apm/agent/core/plugin/EnhanceContext.java](https://codecov.io/gh/apache/skywalking/pull/5187/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcGx1Z2luL0VuaGFuY2VDb250ZXh0LmphdmE=) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (-5.00%)` | |
| [...ywalking/apm/agent/core/profile/ProfileStatus.java](https://codecov.io/gh/apache/skywalking/pull/5187/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcHJvZmlsZS9Qcm9maWxlU3RhdHVzLmphdmE=) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (-1.00%)` | |
| [...walking/apm/agent/core/context/SW8CarrierItem.java](https://codecov.io/gh/apache/skywalking/pull/5187/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvY29udGV4dC9TVzhDYXJyaWVySXRlbS5qYXZh) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (-2.00%)` | |
| [...walking/apm/agent/core/jvm/cpu/SunCpuAccessor.java](https://codecov.io/gh/apache/skywalking/pull/5187/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvanZtL2NwdS9TdW5DcHVBY2Nlc3Nvci5qYXZh) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (-2.00%)` | |
| [...walking/apm/agent/core/logging/core/LogOutput.java](https://codecov.io/gh/apache/skywalking/pull/5187/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvbG9nZ2luZy9jb3JlL0xvZ091dHB1dC5qYXZh) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (-1.00%)` | |
| [...walking/apm/agent/core/plugin/match/NameMatch.java](https://codecov.io/gh/apache/skywalking/pull/5187/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcGx1Z2luL21hdGNoL05hbWVNYXRjaC5qYXZh) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (-3.00%)` | |
| [...alking/apm/agent/core/context/CarrierItemHead.java](https://codecov.io/gh/apache/skywalking/pull/5187/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvY29udGV4dC9DYXJyaWVySXRlbUhlYWQuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (-1.00%)` | |
| [...lking/apm/agent/core/remote/GRPCChannelStatus.java](https://codecov.io/gh/apache/skywalking/pull/5187/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0dSUENDaGFubmVsU3RhdHVzLmphdmE=) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (-1.00%)` | |
| ... and [1431 more](https://codecov.io/gh/apache/skywalking/pull/5187/diff?src=pr&el=tree-more) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/5187?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/5187?src=pr&el=footer). Last update [15b3000...4e1008e](https://codecov.io/gh/apache/skywalking/pull/5187?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking] hanahmily commented on pull request #5187: Add AvgLabeledFunction to ingest multiple labels
Posted by GitBox <gi...@apache.org>.
hanahmily commented on pull request #5187:
URL: https://github.com/apache/skywalking/pull/5187#issuecomment-664792976
> Question is this Labeled function requires the backend query change for adopting the all uncertain labels?
The changes of query will be in another PR.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking] codecov[bot] edited a comment on pull request #5187: Add AvgLabeledFunction to ingest multiple labels
Posted by GitBox <gi...@apache.org>.
codecov[bot] edited a comment on pull request #5187:
URL: https://github.com/apache/skywalking/pull/5187#issuecomment-664685744
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking] hanahmily commented on a change in pull request #5187: Add AvgLabeledFunction to ingest multiple labels
Posted by GitBox <gi...@apache.org>.
hanahmily commented on a change in pull request #5187:
URL: https://github.com/apache/skywalking/pull/5187#discussion_r462359700
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/meter/function/AvgLabeledFunction.java
##########
@@ -0,0 +1,215 @@
+/*
+ * 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.meter.function;
+
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.apache.skywalking.oap.server.core.Const;
+import org.apache.skywalking.oap.server.core.UnexpectedException;
+import org.apache.skywalking.oap.server.core.analysis.manual.instance.InstanceTraffic;
+import org.apache.skywalking.oap.server.core.analysis.meter.MeterEntity;
+import org.apache.skywalking.oap.server.core.analysis.metrics.DataTable;
+import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
+import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
+import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
+import org.apache.skywalking.oap.server.core.storage.annotation.Column;
+
+@MeterFunction(functionName = "avgLabeled")
+@ToString
+public abstract class AvgLabeledFunction extends Metrics implements AcceptableValue<DataTable> {
+ protected static final String SUMMATION = "summation";
+ protected static final String COUNT = "count";
+ protected static final String VALUE = "value";
+
+ @Setter
+ @Getter
+ @Column(columnName = ENTITY_ID, length = 512)
+ private String entityId;
+
+ /**
+ * Service ID is required for sort query.
+ */
+ @Setter
+ @Getter
+ @Column(columnName = InstanceTraffic.SERVICE_ID)
+ private String serviceId;
+
+ @Getter
+ @Setter
+ @Column(columnName = SUMMATION, storageOnly = true)
+ protected DataTable summation = new DataTable(30);
+ @Getter
+ @Setter
+ @Column(columnName = COUNT, storageOnly = true)
+ protected DataTable count = new DataTable(30);
+ @Getter
+ @Setter
+ @Column(columnName = VALUE, dataType = Column.ValueDataType.LABELED_VALUE, storageOnly = true)
+ private DataTable value = new DataTable(30);
+
+ @Override
+ public final void combine(Metrics metrics) {
+ AvgLabeledFunction longAvgMetrics = (AvgLabeledFunction) metrics;
+ summation.append(longAvgMetrics.summation);
+ count.append(longAvgMetrics.count);
+ }
+
+ @Override
+ public final void calculate() {
+ Set<String> keys = count.keys();
+ for (String key : keys) {
+ Long s = summation.get(key);
+ if (Objects.isNull(s)) {
+ continue;
+ }
+ Long c = count.get(key);
+ if (Objects.isNull(c)) {
+ continue;
+ }
+ long result = s / c;
+ if (result == 0 && s > 0) {
+ result = 1;
+ }
+ value.put(key, result);
+ }
+ }
+
+ @Override
+ public Metrics toHour() {
+ AvgLabeledFunction metrics = (AvgLabeledFunction) createNew();
+ metrics.setEntityId(getEntityId());
+ metrics.setTimeBucket(toTimeBucketInHour());
+ metrics.setServiceId(getServiceId());
+ metrics.setSummation(getSummation());
+ metrics.setCount(getCount());
+ return metrics;
+ }
+
+ @Override
+ public Metrics toDay() {
+ AvgLabeledFunction metrics = (AvgLabeledFunction) createNew();
+ metrics.setEntityId(getEntityId());
+ metrics.setTimeBucket(toTimeBucketInDay());
+ metrics.setServiceId(getServiceId());
+ metrics.setSummation(getSummation());
+ metrics.setCount(getCount());
+ return metrics;
+ }
+
+ @Override
+ public int remoteHashCode() {
+ return entityId.hashCode();
+ }
+
+ @Override
+ public void deserialize(final RemoteData remoteData) {
+ this.setCount(new DataTable(remoteData.getDataObjectStrings(0)));
+ this.setSummation(new DataTable(remoteData.getDataObjectStrings(1)));
+ setTimeBucket(remoteData.getDataLongs(0));
+
+ this.entityId = remoteData.getDataStrings(0);
+ this.serviceId = remoteData.getDataStrings(1);
+ }
+
+ @Override
+ public RemoteData.Builder serialize() {
+ RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
+ remoteBuilder.addDataObjectStrings(count.toStorageData());
+ remoteBuilder.addDataObjectStrings(summation.toStorageData());
+ remoteBuilder.addDataLongs(getTimeBucket());
+
+ remoteBuilder.addDataStrings(entityId);
+ remoteBuilder.addDataStrings(serviceId);
+
+ return remoteBuilder;
+ }
+
+ @Override
+ public String id() {
+ return getTimeBucket() + Const.ID_CONNECTOR + entityId;
+ }
+
+ @Override
+ public void accept(final MeterEntity entity, final DataTable value) {
+ this.entityId = entity.id();
+ this.serviceId = entity.serviceId();
+ this.summation.append(value);
+ DataTable c = new DataTable();
+ value.sortedKeys(Comparator.naturalOrder()).forEach(key -> c.put(key, 1L));
Review comment:
done
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org