You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "wankai123 (via GitHub)" <gi...@apache.org> on 2023/12/26 07:11:16 UTC
[PR] Support build Service/Instance Hierarchy and query. [skywalking]
wankai123 opened a new pull request, #11698:
URL: https://github.com/apache/skywalking/pull/11698
relate to https://github.com/apache/skywalking/discussions/11669
Topology query will be provided in the next PR.
- [ ] If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #<issue number>.
- [X] Update the [`CHANGES` log](https://github.com/apache/skywalking/blob/master/docs/en/changes/changes.md).
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support build Service/Instance Hierarchy and query. [skywalking]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #11698:
URL: https://github.com/apache/skywalking/pull/11698#discussion_r1436425138
##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/IDManager.java:
##########
@@ -175,6 +203,16 @@ public static class ServiceInstanceRelationDefine {
*/
private final String destId;
}
+
+ @RequiredArgsConstructor
+ @Getter
+ @EqualsAndHashCode
+ public static class InstanceHierarchyRelationDefine {
+ private final String instanceId;
+ private final Layer serviceLayer;
+ private final String relateInstanceId;
+ private final Layer relateServiceLayer;
Review Comment:
```suggestion
private final String relatedInstanceId;
private final Layer relatedServiceLayer;
```
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support build Service/Instance Hierarchy and query. [skywalking]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #11698:
URL: https://github.com/apache/skywalking/pull/11698#discussion_r1436424784
##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/IDManager.java:
##########
@@ -100,6 +109,16 @@ public static class ServiceRelationDefine {
private final String sourceId;
private final String destId;
}
+
+ @RequiredArgsConstructor
+ @Getter
+ @EqualsAndHashCode
+ public static class ServiceHierarchyRelationDefine {
+ private final String serviceId;
+ private final Layer serviceLayer;
+ private final String relateServiceId;
+ private final Layer relateServiceLayer;
Review Comment:
```suggestion
private final String relatedServiceId;
private final Layer relatedServiceLayer;
```
`relate` is a verb.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support build Service/Instance Hierarchy and query. [skywalking]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #11698:
URL: https://github.com/apache/skywalking/pull/11698#discussion_r1436428504
##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/IDManager.java:
##########
@@ -140,6 +159,15 @@ public static String buildRelationId(ServiceInstanceRelationDefine define) {
return define.sourceId + Const.RELATION_ID_CONNECTOR + define.destId;
}
+ /**
+ * @return encoded instance hierarchy relation id
+ */
+ public static String buildInstanceHierarchyRelationId(InstanceHierarchyRelationDefine define) {
+ return define.instanceId + Const.POINT + define.serviceLayer.value() +
Review Comment:
This is different from `define.serviceId + Const.SERVICE_ID_CONNECTOR + define.serviceLayer.value()`. Could we use a consistent connector? And due to the requirement of https://github.com/apache/skywalking/pull/11698#discussion_r1436427487, a consistent connector should be better for decoding.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support build Service/Instance Hierarchy and query. [skywalking]
Posted by "wankai123 (via GitHub)" <gi...@apache.org>.
wankai123 merged PR #11698:
URL: https://github.com/apache/skywalking/pull/11698
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support build Service/Instance Hierarchy and query. [skywalking]
Posted by "kezhenxu94 (via GitHub)" <gi...@apache.org>.
kezhenxu94 commented on code in PR #11698:
URL: https://github.com/apache/skywalking/pull/11698#discussion_r1436335194
##########
oap-server/server-starter/src/main/resources/hierarchy-definition.yml:
##########
@@ -0,0 +1,44 @@
+# 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.
+
+# Define the hierarchy of layers, the layers under the specific layer are lower of the layer.
+# All the layers are defined in the file `org.apache.skywalking.oap.server.core.analysis.Layers.java`.
+
+MESH:
+ - MESH_DP
+ - K8S_SERVICE
+ - K8S
+
+MESH_DP:
+ - K8S_SERVICE
+ - K8S
+
+K8S_SERVICE:
+ - K8S
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Review Comment:
```suggestion
```
##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/hierarchy/instance/InstanceHierarchyRelationTraffic.java:
##########
@@ -0,0 +1,165 @@
+/*
+ * 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.hierarchy.instance;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.analysis.Layer;
+import org.apache.skywalking.oap.server.core.analysis.MetricsExtension;
+import org.apache.skywalking.oap.server.core.analysis.Stream;
+import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
+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.source.DefaultScopeDefine;
+import org.apache.skywalking.oap.server.core.storage.StorageID;
+import org.apache.skywalking.oap.server.core.storage.annotation.BanyanDB;
+import org.apache.skywalking.oap.server.core.storage.annotation.Column;
+import org.apache.skywalking.oap.server.core.storage.type.Convert2Entity;
+import org.apache.skywalking.oap.server.core.storage.type.Convert2Storage;
+import org.apache.skywalking.oap.server.core.storage.type.StorageBuilder;
+
+@Stream(name = InstanceHierarchyRelationTraffic.INDEX_NAME, scopeId = DefaultScopeDefine.INSTANCE_HIERARCHY_RELATION,
+ builder = InstanceHierarchyRelationTraffic.Builder.class, processor = MetricsStreamProcessor.class)
+@MetricsExtension(supportDownSampling = false, supportUpdate = false)
+@EqualsAndHashCode(of = {
+ "entityId"
+}, callSuper = true)
+public class InstanceHierarchyRelationTraffic extends Metrics {
+ public static final String INDEX_NAME = "instance_hierarchy_relation";
+ public static final String SERVICE_LAYER = "service_layer";
+ public static final String INSTANCE_ID = "instance_id";
+ public static final String RELATED_SERVICE_LAYER = "related_service_layer";
+ public static final String RELATED_INSTANCE_ID = "related_instance_id";
+
+ @Setter
+ @Getter
+ @Column(name = ENTITY_ID, length = 512)
+ @BanyanDB.SeriesID(index = 0)
+ private String entityId;
+
+ @Setter
+
+
Review Comment:
```suggestion
```
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support build Service/Instance Hierarchy and query. [skywalking]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #11698:
URL: https://github.com/apache/skywalking/pull/11698#discussion_r1436438566
##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/hierarchy/instance/InstanceHierarchyRelationTraffic.java:
##########
@@ -0,0 +1,165 @@
+/*
+ * 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.hierarchy.instance;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.analysis.Layer;
+import org.apache.skywalking.oap.server.core.analysis.MetricsExtension;
+import org.apache.skywalking.oap.server.core.analysis.Stream;
+import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
+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.source.DefaultScopeDefine;
+import org.apache.skywalking.oap.server.core.storage.StorageID;
+import org.apache.skywalking.oap.server.core.storage.annotation.BanyanDB;
+import org.apache.skywalking.oap.server.core.storage.annotation.Column;
+import org.apache.skywalking.oap.server.core.storage.type.Convert2Entity;
+import org.apache.skywalking.oap.server.core.storage.type.Convert2Storage;
+import org.apache.skywalking.oap.server.core.storage.type.StorageBuilder;
+
+@Stream(name = InstanceHierarchyRelationTraffic.INDEX_NAME, scopeId = DefaultScopeDefine.INSTANCE_HIERARCHY_RELATION,
+ builder = InstanceHierarchyRelationTraffic.Builder.class, processor = MetricsStreamProcessor.class)
+@MetricsExtension(supportDownSampling = false, supportUpdate = false)
+@EqualsAndHashCode(of = {
+ "entityId"
+}, callSuper = true)
+public class InstanceHierarchyRelationTraffic extends Metrics {
+ public static final String INDEX_NAME = "instance_hierarchy_relation";
+ public static final String SERVICE_LAYER = "service_layer";
+ public static final String INSTANCE_ID = "instance_id";
+ public static final String RELATED_SERVICE_LAYER = "related_service_layer";
+ public static final String RELATED_INSTANCE_ID = "related_instance_id";
+
+ @Setter
+ @Getter
+ @Column(name = ENTITY_ID, length = 512)
+ @BanyanDB.SeriesID(index = 0)
+ private String entityId;
+
+ @Setter
+
+
+ @Getter
+ @Column(name = INSTANCE_ID, length = 250)
+ private String instanceId;
+
+ @Setter
+ @Getter
+ @Column(name = SERVICE_LAYER)
+ private Layer servicelayer = Layer.UNDEFINED;
+
+ @Setter
+ @Getter
+ @Column(name = RELATED_INSTANCE_ID, length = 250)
+ private String relatedInstanceId;
+
+ @Setter
+ @Getter
+ @Column(name = RELATED_SERVICE_LAYER)
+ private Layer relatedServiceLayer = Layer.UNDEFINED;
Review Comment:
Once you have ID decoder, I think you don't need layer fields, because instance ID can't cross layer, right?
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support build Service/Instance Hierarchy and query. [skywalking]
Posted by "wankai123 (via GitHub)" <gi...@apache.org>.
wankai123 commented on code in PR #11698:
URL: https://github.com/apache/skywalking/pull/11698#discussion_r1436443135
##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/hierarchy/instance/InstanceHierarchyRelationTraffic.java:
##########
@@ -0,0 +1,165 @@
+/*
+ * 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.hierarchy.instance;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.analysis.Layer;
+import org.apache.skywalking.oap.server.core.analysis.MetricsExtension;
+import org.apache.skywalking.oap.server.core.analysis.Stream;
+import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
+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.source.DefaultScopeDefine;
+import org.apache.skywalking.oap.server.core.storage.StorageID;
+import org.apache.skywalking.oap.server.core.storage.annotation.BanyanDB;
+import org.apache.skywalking.oap.server.core.storage.annotation.Column;
+import org.apache.skywalking.oap.server.core.storage.type.Convert2Entity;
+import org.apache.skywalking.oap.server.core.storage.type.Convert2Storage;
+import org.apache.skywalking.oap.server.core.storage.type.StorageBuilder;
+
+@Stream(name = InstanceHierarchyRelationTraffic.INDEX_NAME, scopeId = DefaultScopeDefine.INSTANCE_HIERARCHY_RELATION,
+ builder = InstanceHierarchyRelationTraffic.Builder.class, processor = MetricsStreamProcessor.class)
+@MetricsExtension(supportDownSampling = false, supportUpdate = false)
+@EqualsAndHashCode(of = {
+ "entityId"
+}, callSuper = true)
+public class InstanceHierarchyRelationTraffic extends Metrics {
+ public static final String INDEX_NAME = "instance_hierarchy_relation";
+ public static final String SERVICE_LAYER = "service_layer";
+ public static final String INSTANCE_ID = "instance_id";
+ public static final String RELATED_SERVICE_LAYER = "related_service_layer";
+ public static final String RELATED_INSTANCE_ID = "related_instance_id";
+
+ @Setter
+ @Getter
+ @Column(name = ENTITY_ID, length = 512)
+ @BanyanDB.SeriesID(index = 0)
+ private String entityId;
+
+ @Setter
+
+
+ @Getter
+ @Column(name = INSTANCE_ID, length = 250)
+ private String instanceId;
+
+ @Setter
+ @Getter
+ @Column(name = SERVICE_LAYER)
+ private Layer servicelayer = Layer.UNDEFINED;
+
+ @Setter
+ @Getter
+ @Column(name = RELATED_INSTANCE_ID, length = 250)
+ private String relatedInstanceId;
+
+ @Setter
+ @Getter
+ @Column(name = RELATED_SERVICE_LAYER)
+ private Layer relatedServiceLayer = Layer.UNDEFINED;
Review Comment:
we need the service layer for query because 2 instances could belong to 1 service with 2 layers.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support build Service/Instance Hierarchy and query. [skywalking]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #11698:
URL: https://github.com/apache/skywalking/pull/11698#discussion_r1436430711
##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/HierarchyQueryService.java:
##########
@@ -0,0 +1,189 @@
+/*
+ * 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.query;
+
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.CoreModule;
+import org.apache.skywalking.oap.server.core.CoreModuleConfig;
+import org.apache.skywalking.oap.server.core.analysis.IDManager;
+import org.apache.skywalking.oap.server.core.config.HierarchyDefinitionService;
+import org.apache.skywalking.oap.server.core.hierarchy.instance.InstanceHierarchyRelationTraffic;
+import org.apache.skywalking.oap.server.core.hierarchy.service.ServiceHierarchyRelationTraffic;
+import org.apache.skywalking.oap.server.core.query.type.HierarchyInstanceRelation;
+import org.apache.skywalking.oap.server.core.query.type.HierarchyRelatedInstance;
+import org.apache.skywalking.oap.server.core.query.type.HierarchyRelatedService;
+import org.apache.skywalking.oap.server.core.query.type.HierarchyServiceRelation;
+import org.apache.skywalking.oap.server.core.query.type.InstanceHierarchy;
+import org.apache.skywalking.oap.server.core.query.type.ServiceHierarchy;
+import org.apache.skywalking.oap.server.core.storage.StorageModule;
+import org.apache.skywalking.oap.server.core.storage.query.IHierarchyQueryDAO;
+import org.apache.skywalking.oap.server.library.module.ModuleManager;
+import org.apache.skywalking.oap.server.library.module.Service;
+
+@Slf4j
+public class HierarchyQueryService implements Service {
+ private final ModuleManager moduleManager;
+ private final boolean isEnableHierarchy;
+ private IHierarchyQueryDAO hierarchyQueryDAO;
+ private Map<String, List<String>> hierarchyDefinition;
+ private LoadingCache<Boolean, Map<HierarchyRelatedService, ServiceRelations>> serviceHierarchyCache;
+
+ public HierarchyQueryService(ModuleManager moduleManager, CoreModuleConfig moduleConfig) {
+ this.moduleManager = moduleManager;
+ this.isEnableHierarchy = moduleConfig.isEnableHierarchy();
+ if (moduleConfig.isEnableHierarchy()) {
+ this.serviceHierarchyCache =
+ CacheBuilder.newBuilder()
+ .maximumSize(1)
+ .refreshAfterWrite(moduleConfig.getServiceCacheRefreshInterval(), TimeUnit.SECONDS)
+ .build(
+ new CacheLoader<>() {
+ @Override
+ public Map<HierarchyRelatedService, ServiceRelations> load(final Boolean key) throws Exception {
+ return mapServiceHierarchy();
+ }
+ });
+ }
+ }
+
+ private IHierarchyQueryDAO getHierarchyQueryDAO() {
+ if (hierarchyQueryDAO == null) {
+ this.hierarchyQueryDAO = moduleManager.find(StorageModule.NAME)
+ .provider()
+ .getService(IHierarchyQueryDAO.class);
+ }
+ return hierarchyQueryDAO;
+ }
+
+ private Map<String, List<String>> getHierarchyDefinition() {
+ if (hierarchyDefinition == null) {
+ hierarchyDefinition = moduleManager.find(CoreModule.NAME)
+ .provider()
+ .getService(HierarchyDefinitionService.class).getHierarchyDefinition();
+ }
+ return hierarchyDefinition;
+ }
+
+ private Map<HierarchyRelatedService, ServiceRelations> mapServiceHierarchy() throws Exception {
+ List<ServiceHierarchyRelationTraffic> traffics = getHierarchyQueryDAO().readAllServiceHierarchyRelations();
+ Map<HierarchyRelatedService, ServiceRelations> serviceRelationsMap = new HashMap<>();
+
+ for (ServiceHierarchyRelationTraffic traffic : traffics) {
+ HierarchyRelatedService service = new HierarchyRelatedService();
+ service.setId(traffic.getServiceId());
+ service.setName(IDManager.ServiceID.analysisId(traffic.getServiceId()).getName());
+ service.setLayer(traffic.getServicelayer().name());
+ HierarchyRelatedService relatedService = new HierarchyRelatedService();
+ relatedService.setId(traffic.getRelatedServiceId());
+ relatedService.setName(IDManager.ServiceID.analysisId(traffic.getRelatedServiceId()).getName());
+ relatedService.setLayer(traffic.getRelatedServiceLayer().name());
+
+ ServiceRelations serviceRelations = serviceRelationsMap.computeIfAbsent(
+ service, k -> new ServiceRelations());
+ ServiceRelations relationServiceRelations = serviceRelationsMap.computeIfAbsent(
+ relatedService, k -> new ServiceRelations());
+ List<String> lowerLayers = getHierarchyDefinition().getOrDefault(
+ traffic.getServicelayer().name(), new ArrayList<>());
+ List<String> relatedLowerLayers = getHierarchyDefinition().getOrDefault(
+ traffic.getRelatedServiceLayer().name(), new ArrayList<>());
+
+ //should build the relations in 2 direction
Review Comment:
```suggestion
// Build the relations in 2 directions
```
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support build Service/Instance Hierarchy and query. [skywalking]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #11698:
URL: https://github.com/apache/skywalking/pull/11698#discussion_r1436427487
##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/hierarchy/service/ServiceHierarchyRelationTraffic.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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.hierarchy.service;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.analysis.Layer;
+import org.apache.skywalking.oap.server.core.analysis.MetricsExtension;
+import org.apache.skywalking.oap.server.core.analysis.Stream;
+import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
+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.source.DefaultScopeDefine;
+import org.apache.skywalking.oap.server.core.storage.StorageID;
+import org.apache.skywalking.oap.server.core.storage.annotation.BanyanDB;
+import org.apache.skywalking.oap.server.core.storage.annotation.Column;
+import org.apache.skywalking.oap.server.core.storage.type.Convert2Entity;
+import org.apache.skywalking.oap.server.core.storage.type.Convert2Storage;
+import org.apache.skywalking.oap.server.core.storage.type.StorageBuilder;
+
+@Stream(name = ServiceHierarchyRelationTraffic.INDEX_NAME, scopeId = DefaultScopeDefine.SERVICE_HIERARCHY_RELATION,
+ builder = ServiceHierarchyRelationTraffic.Builder.class, processor = MetricsStreamProcessor.class)
+@MetricsExtension(supportDownSampling = false, supportUpdate = false)
+@EqualsAndHashCode(of = {
+ "entityId"
+}, callSuper = true)
+public class ServiceHierarchyRelationTraffic extends Metrics {
+ public static final String INDEX_NAME = "service_hierarchy_relation";
+ public static final String SERVICE_ID = "service_id";
+ public static final String SERVICE_LAYER = "service_layer";
+ public static final String RELATED_SERVICE_ID = "related_service_id";
+ public static final String RELATED_SERVICE_LAYER = "related_service_layer";
+
+ @Setter
+ @Getter
+ @Column(name = ENTITY_ID, length = 512)
+ @BanyanDB.SeriesID(index = 0)
+ private String entityId;
+
+ @Setter
+ @Getter
+ @Column(name = SERVICE_ID, length = 250)
+ private String serviceId;
+
+ @Setter
+ @Getter
+ @Column(name = SERVICE_LAYER)
+ private Layer servicelayer = Layer.UNDEFINED;
+
+ @Setter
+ @Getter
+ @Column(name = RELATED_SERVICE_ID, length = 250)
+ private String relatedServiceId;
+
+ @Setter
+ @Getter
+ @Column(name = RELATED_SERVICE_LAYER)
+ private Layer relatedServiceLayer = Layer.UNDEFINED;
Review Comment:
I think for `ServiceHierarchyRelationTraffic`, we could skip all these fields, as ID of the relationship should be able to be decoded, right? You don't add the decoding in IDManager, I believe it is possible.
By that, and service hierarchy would be loaded in the memory, so, we should be able to optimize the storage?
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org