diff --git a/oap-server/oal-rt/src/test/resources/expectedFiles/MetricsImplementorExpected.java b/oap-server/oal-rt/src/test/resources/expectedFiles/MetricsImplementorExpected.java deleted file mode 100644 index 75a82c31d..000000000 --- a/oap-server/oal-rt/src/test/resources/expectedFiles/MetricsImplementorExpected.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * 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.generated.service.serviceavg; - -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; -import lombok.Setter; -import org.apache.skywalking.oap.server.core.Const; -import org.apache.skywalking.oap.server.core.analysis.Stream; -import org.apache.skywalking.oap.server.core.analysis.metrics.LongAvgMetrics; -import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; -import org.apache.skywalking.oap.server.core.analysis.metrics.MetricsMetaInfo; -import org.apache.skywalking.oap.server.core.analysis.metrics.WithMetadata; -import org.apache.skywalking.oap.server.core.analysis.worker.MetricsStreamProcessor; -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; - -/** - * This class is auto generated. Please don't change this class manually. - */ -@Stream(name = "service_avg", scopeId = 1, builder = ServiceAvgMetrics.Builder.class, processor = MetricsStreamProcessor.class) -public class ServiceAvgMetrics extends LongAvgMetrics implements WithMetadata { - - @Setter - @Getter - @Column(columnName = "entity_id") - private java.lang.String entityId; - - @Override - public String id() { - String splitJointId = String.valueOf(getTimeBucket()); - splitJointId += Const.ID_CONNECTOR + entityId; - return splitJointId; - } - - @Override - public int hashCode() { - int result = 17; - result = 31 * result + entityId.hashCode(); - result = 31 * result + (int) getTimeBucket(); - return result; - } - - @Override - public int remoteHashCode() { - int result = 17; - result = 31 * result + entityId.hashCode(); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - - ServiceAvgMetrics metrics = (ServiceAvgMetrics) obj; - if (!entityId.equals(metrics.entityId)) - return false; - - if (getTimeBucket() != metrics.getTimeBucket()) - return false; - - return true; - } - - @Override - public RemoteData.Builder serialize() { - RemoteData.Builder remoteBuilder = RemoteData.newBuilder(); - remoteBuilder.addDataStrings(getEntityId()); - remoteBuilder.addDataStrings(getStringField()); - - remoteBuilder.addDataLongs(getSummation()); - remoteBuilder.addDataLongs(getValue()); - remoteBuilder.addDataLongs(getTimeBucket()); - - remoteBuilder.addDataIntegers(getCount()); - - return remoteBuilder; - } - - @Override - public void deserialize(RemoteData remoteData) { - setEntityId(remoteData.getDataStrings(0)); - setStringField(remoteData.getDataStrings(1)); - - setSummation(remoteData.getDataLongs(0)); - setValue(remoteData.getDataLongs(1)); - setTimeBucket(remoteData.getDataLongs(2)); - - setCount(remoteData.getDataIntegers(0)); - - } - - @Override - public MetricsMetaInfo getMeta() { - return new MetricsMetaInfo("generate_metrics", 1, entityId); - } - - @Override - public Metrics toHour() { - ServiceAvgMetrics metrics = new ServiceAvgMetrics(); - metrics.setEntityId(this.getEntityId()); - metrics.setSummation(this.getSummation()); - metrics.setCount(this.getCount()); - metrics.setValue(this.getValue()); - metrics.setTimeBucket(toTimeBucketInHour()); - metrics.setStringField(this.getStringField()); - return metrics; - } - - @Override - public Metrics toDay() { - ServiceAvgMetrics metrics = new ServiceAvgMetrics(); - metrics.setEntityId(this.getEntityId()); - metrics.setSummation(this.getSummation()); - metrics.setCount(this.getCount()); - metrics.setValue(this.getValue()); - metrics.setTimeBucket(toTimeBucketInDay()); - metrics.setStringField(this.getStringField()); - return metrics; - } - - @Override - public Metrics toMonth() { - ServiceAvgMetrics metrics = new ServiceAvgMetrics(); - metrics.setEntityId(this.getEntityId()); - metrics.setSummation(this.getSummation()); - metrics.setCount(this.getCount()); - metrics.setValue(this.getValue()); - metrics.setTimeBucket(toTimeBucketInMonth()); - metrics.setStringField(this.getStringField()); - return metrics; - } - - public static class Builder implements StorageBuilder { - - @Override - public Map data2Map(ServiceAvgMetrics storageData) { - Map map = new HashMap<>(); - map.put("entity_id", storageData.getEntityId()); - map.put("summation", storageData.getSummation()); - map.put("count", storageData.getCount()); - map.put("value", storageData.getValue()); - map.put("time_bucket", storageData.getTimeBucket()); - map.put("string_field", storageData.getStringField()); - return map; - } - - @Override - public ServiceAvgMetrics map2Data(Map dbMap) { - ServiceAvgMetrics metrics = new ServiceAvgMetrics(); - metrics.setEntityId((String) dbMap.get("entity_id")); - metrics.setSummation(((Number) dbMap.get("summation")).longValue()); - metrics.setCount(((Number) dbMap.get("count")).intValue()); - metrics.setValue(((Number) dbMap.get("value")).longValue()); - metrics.setTimeBucket(((Number) dbMap.get("time_bucket")).longValue()); - metrics.setStringField((String) dbMap.get("string_field")); - return metrics; - } - } -} \ No newline at end of file diff --git a/oap-server/oal-rt/src/test/resources/expectedFiles/ServiceDispatcherExpected.java b/oap-server/oal-rt/src/test/resources/expectedFiles/ServiceDispatcherExpected.java deleted file mode 100644 index 20969c29b..000000000 --- a/oap-server/oal-rt/src/test/resources/expectedFiles/ServiceDispatcherExpected.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.generated.service; - -import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher; -import org.apache.skywalking.oap.server.core.analysis.metrics.expression.EqualMatch; -import org.apache.skywalking.oap.server.core.analysis.metrics.expression.GreaterMatch; -import org.apache.skywalking.oap.server.core.analysis.worker.MetricsStreamProcessor; -import org.apache.skywalking.oap.server.core.source.Service; - -/** - * This class is auto generated. Please don't change this class manually. - */ -public class ServiceDispatcher implements SourceDispatcher { - - @Override - public void dispatch(Service source) { - doServiceAvg(source); - } - - private void doServiceAvg(Service source) { - ServiceAvgMetrics metrics = new ServiceAvgMetrics(); - - if (!new EqualMatch().setLeft(source.getName()).setRight("/service/prod/save").match()) { - return; - } - if (!new GreaterMatch().match(source.getLatency(), 1000)) { - return; - } - - metrics.setTimeBucket(source.getTimeBucket()); - metrics.setEntityId(source.getEntityId()); - metrics.combine(source.getLatency(), 1); - - MetricsStreamProcessor.getInstance().in(metrics); - } -} diff --git a/oap-server/oal-rt/src/test/resources/oal_test.oal b/oap-server/oal-rt/src/test/resources/oal_test.oal deleted file mode 100644 index a7f7deeef..000000000 --- a/oap-server/oal-rt/src/test/resources/oal_test.oal +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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. - * - */ - -// All scope metrics -all_p99 = from(All.latency).p99(10); -all_p95 = from(All.latency).p95(10); -all_p90 = from(All.latency).p90(10); -all_p75 = from(All.latency).p75(10); -all_p50 = from(All.latency).p50(10); -all_heatmap = from(All.latency).thermodynamic(100, 20); - -// Service scope metrics -service_resp_time = from(Service.latency).longAvg(); -service_sla = from(Service.*).percent(status == true); -service_cpm = from(Service.*).cpm(); -service_p99 = from(Service.latency).p99(10); -service_p95 = from(Service.latency).p95(10); -service_p90 = from(Service.latency).p90(10); -service_p75 = from(Service.latency).p75(10); -service_p50 = from(Service.latency).p50(10); - -// Service relation scope metrics for topology -service_relation_client_cpm = from(ServiceRelation.*).filter(detectPoint == DetectPoint.CLIENT).cpm(); -service_relation_server_cpm = from(ServiceRelation.*).filter(detectPoint == DetectPoint.SERVER).cpm(); -service_relation_client_call_sla = from(ServiceRelation.*).filter(detectPoint == DetectPoint.CLIENT).percent(status == true); -service_relation_server_call_sla = from(ServiceRelation.*).filter(detectPoint == DetectPoint.SERVER).percent(status == true); -service_relation_client_resp_time = from(ServiceRelation.latency).filter(detectPoint == DetectPoint.CLIENT).longAvg(); -service_relation_server_resp_time = from(ServiceRelation.latency).filter(detectPoint == DetectPoint.SERVER).longAvg(); - -// Service Instance Scope metrics -service_instance_sla = from(ServiceInstance.*).percent(status == true); -service_instance_resp_time= from(ServiceInstance.latency).longAvg(); -service_instance_cpm = from(ServiceInstance.*).cpm(); - -// Endpoint scope metrics -endpoint_cpm = from(Endpoint.*).cpm(); -endpoint_avg = from(Endpoint.latency).longAvg(); -endpoint_sla = from(Endpoint.*).percent(status == true); -endpoint_p99 = from(Endpoint.latency).p99(10); -endpoint_p95 = from(Endpoint.latency).p95(10); -endpoint_p90 = from(Endpoint.latency).p90(10); -endpoint_p75 = from(Endpoint.latency).p75(10); -endpoint_p50 = from(Endpoint.latency).p50(10); - -// Endpoint relation scope metrics -endpoint_relation_cpm = from(EndpointRelation.*).filter(detectPoint == DetectPoint.SERVER).cpm(); -endpoint_relation_resp_time = from(EndpointRelation.rpcLatency).filter(detectPoint == DetectPoint.SERVER).longAvg(); - -// JVM instance metrics -instance_jvm_cpu = from(ServiceInstanceJVMCPU.usePercent).doubleAvg(); -instance_jvm_memory_heap = from(ServiceInstanceJVMMemory.used).filter(heapStatus == true).longAvg(); -instance_jvm_memory_noheap = from(ServiceInstanceJVMMemory.used).filter(heapStatus == false).longAvg(); -instance_jvm_memory_heap_max = from(ServiceInstanceJVMMemory.max).filter(heapStatus == true).longAvg(); -instance_jvm_memory_noheap_max = from(ServiceInstanceJVMMemory.max).filter(heapStatus == false).longAvg(); -instance_jvm_young_gc_time = from(ServiceInstanceJVMGC.time).filter(phrase == GCPhrase.NEW).longAvg(); -instance_jvm_old_gc_time = from(ServiceInstanceJVMGC.time).filter(phrase == GCPhrase.OLD).longAvg(); -instance_jvm_young_gc_count = from(ServiceInstanceJVMGC.count).filter(phrase == GCPhrase.NEW).sum(); -instance_jvm_old_gc_count = from(ServiceInstanceJVMGC.count).filter(phrase == GCPhrase.OLD).sum(); -instance_jvm_thread_live_count = from(ServiceInstanceJVMThread.liveCount).longAvg(); -instance_jvm_thread_daemon_count = from(ServiceInstanceJVMThread.daemonCount).longAvg(); -instance_jvm_thread_peak_count = from(ServiceInstanceJVMThread.peakCount).longAvg(); - -// endpoint_Avg_for_prod_serv = from(Endpoint.latency).filter(name == "/product/service").longAvg(); \ No newline at end of file