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 2022/04/09 03:39:14 UTC

[GitHub] [skywalking] mrproliu opened a new pull request, #8840: Update the eBPF Profiling task as service level

mrproliu opened a new pull request, #8840:
URL: https://github.com/apache/skywalking/pull/8840

   - [x] If this pull request closes/resolves/fixes an existing issue, replace the issue number. Relate https://github.com/apache/skywalking/issues/8833.
   - [x] Update the [`CHANGES` log](https://github.com/apache/skywalking/blob/changelog/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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849660740


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/EBPFProfilingQueryService.java:
##########
@@ -169,6 +217,9 @@ private Process convertProcess(ProcessTraffic traffic) {
                 process.getAttributes().add(new Attribute(key, traffic.getProperties().get(key).getAsString()));
             }
         }
+        if (StringUtil.isNotEmpty(traffic.getLabelsJson())) {
+            process.getLabels().addAll(GSON.<List<String>>fromJson(traffic.getLabelsJson(), ArrayList.class));

Review Comment:
   ignore



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846753178


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/storage/EBPFProfilingTaskRecord.java:
##########
@@ -41,30 +40,20 @@
 @Stream(name = EBPFProfilingTaskRecord.INDEX_NAME, scopeId = EBPF_PROFILING_TASK,
         builder = EBPFProfilingTaskRecord.Builder.class, processor = NoneStreamProcessor.class)
 public class EBPFProfilingTaskRecord extends NoneStream {
-
     public static final String INDEX_NAME = "ebpf_profiling_task";
-    public static final String PROCESS_FIND_TYPE = "process_find_type";
     public static final String SERVICE_ID = "service_id";
-    public static final String INSTANCE_ID = "instance_id";
-    public static final String PROCESS_ID = "process_id";
-    public static final String PROCESS_NAME = "process_name";
+    public static final String PROCESS_LABELS_JSON = "process_labels_json";
     public static final String START_TIME = "start_time";
     public static final String TRIGGER_TYPE = "trigger_type";
     public static final String FIXED_TRIGGER_DURATION = "fixed_trigger_duration";
     public static final String TARGET_TYPE = "target_type";
     public static final String CREATE_TIME = "create_time";
     public static final String LAST_UPDATE_TIME = "last_update_time";
 
-    @Column(columnName = PROCESS_FIND_TYPE)
-    private int processFindType = EBPFProfilingProcessFinderType.UNKNOWN.value();
     @Column(columnName = SERVICE_ID)
     private String serviceId;
-    @Column(columnName = INSTANCE_ID, length = 600)
-    private String instanceId;
-    @Column(columnName = PROCESS_ID, length = 600)
-    private String processId;
-    @Column(columnName = PROCESS_NAME, length = 500)
-    private String processName;
+    @Column(columnName = PROCESS_LABELS_JSON)

Review Comment:
   updated. 



-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846757350


##########
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/ServiceLabelQuery.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.storage.plugin.influxdb.query;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.manual.process.ServiceLabelRecord;
+import org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IServiceLabelDAO;
+import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxClient;
+import org.influxdb.dto.QueryResult;
+import org.influxdb.querybuilder.SelectQueryImpl;
+import org.influxdb.querybuilder.WhereQueryImpl;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
+
+@Slf4j
+@RequiredArgsConstructor
+public class ServiceLabelQuery implements IServiceLabelDAO {
+    private final InfluxClient client;
+
+    @Override
+    public List<String> queryAllLabels(String serviceId) throws IOException {
+        final WhereQueryImpl<SelectQueryImpl> query = select(
+                ServiceLabelRecord.LABEL
+        )
+                .from(client.getDatabase(), ServiceLabelRecord.INDEX_NAME)
+                .where();
+
+        query.and(eq(ServiceLabelRecord.SERVICE_ID, serviceId));
+
+        return parseLabels(query);
+    }
+
+    private List<String> parseLabels(WhereQueryImpl<SelectQueryImpl> query) throws IOException {
+        final QueryResult.Series series = client.queryForSingleSeries(query);
+        if (log.isDebugEnabled()) {
+            log.debug("SQL: {}, result: {}", query.getCommand(), series);
+        }
+
+        if (Objects.isNull(series)) {
+            return Collections.emptyList();
+        }
+
+        return series.getValues().stream().map(v -> (String) v.get(1)).collect(Collectors.toList());

Review Comment:
   *NULL_DEREFERENCE:*  object `series` last assigned on line 57 could be null and is dereferenced at line 66.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)



-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846753002


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/process/ProcessServiceLabelRecord.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.manual.process;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+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.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;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROCESS_SERVICE_LABEL;
+
+/**
+ * Process have multiple labels, such as tag.
+ * {@link ProcessServiceLabelRecord} could combine them in the service level.
+ * It could help to quickly locate the similar process by the service and label.
+ */
+@Setter
+@Getter
+@Stream(name = ProcessServiceLabelRecord.INDEX_NAME, scopeId = PROCESS_SERVICE_LABEL,
+        builder = ProcessServiceLabelRecord.Builder.class, processor = MetricsStreamProcessor.class)
+@MetricsExtension(supportDownSampling = false, supportUpdate = false)
+@EqualsAndHashCode(of = {
+        "serviceId",
+        "label"
+})
+public class ProcessServiceLabelRecord extends Metrics {
+
+    public static final String INDEX_NAME = "process_service_label";
+    public static final String SERVICE_ID = "service_id";
+    public static final String LABEL = "label";
+
+    @Column(columnName = SERVICE_ID)
+    private String serviceId;
+    @Column(columnName = LABEL)

Review Comment:
   I mean less



-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846764996


##########
oap-server/server-receiver-plugin/skywalking-ebpf-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/ebpf/provider/handler/EBPFProfilingServiceHandler.java:
##########
@@ -100,6 +102,35 @@ public void queryTasks(EBPFProfilingTaskQuery request, StreamObserver<Commands>
         responseObserver.onCompleted();
     }
 
+    private List<EBPFProfilingTaskCommand> buildProfilingCommands(EBPFProfilingTask task, List<Process> processes) {
+        final ArrayList<EBPFProfilingTaskCommand> commands = new ArrayList<>(processes.size());
+        for (Process process : processes) {
+            // The service id must matches between process and task
+            if (!Objects.equals(process.getServiceId(), task.getServiceId())) {
+                continue;
+            }
+
+            // If the task haven't labeled requirement, them just add the process
+            boolean shouldAdd = false;
+            if (CollectionUtils.isEmpty(task.getProcessLabels())) {
+                shouldAdd = true;
+            } else {
+                // If the process have matched one of the task label, them need to add the command

Review Comment:
   Do we have a UI preview to show how many processes matched? In most label system, multiple labels are all required, rather than one of, 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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849661079


##########
oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java:
##########
@@ -316,6 +357,11 @@ private List<Process> buildProcesses(ResultSet resultSet) throws SQLException {
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelJsonString = resultSet.getString(ProcessTraffic.LABELS_JSON);
+            if (!Strings.isNullOrEmpty(labelJsonString)) {
+                List<String> labels = GSON.<List<String>>fromJson(labelJsonString, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   ignore



##########
oap-server/server-storage-plugin/storage-iotdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/iotdb/query/IoTDBMetadataQueryDAO.java:
##########
@@ -267,6 +301,11 @@ private List<Process> buildProcesses(List<? super StorageData> storageDataList)
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelsJson = processTraffic.getLabelsJson();
+            if (StringUtil.isNotEmpty(labelsJson)) {
+                final List<String> labels = GSON.<List<String>>fromJson(labelsJson, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   ignore



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849035234


##########
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/ServiceLabelQuery.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.storage.plugin.influxdb.query;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.manual.process.ServiceLabelRecord;
+import org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IServiceLabelDAO;
+import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxClient;
+import org.influxdb.dto.QueryResult;
+import org.influxdb.querybuilder.SelectQueryImpl;
+import org.influxdb.querybuilder.WhereQueryImpl;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
+
+@Slf4j
+@RequiredArgsConstructor
+public class ServiceLabelQuery implements IServiceLabelDAO {
+    private final InfluxClient client;
+
+    @Override
+    public List<String> queryAllLabels(String serviceId) throws IOException {
+        final WhereQueryImpl<SelectQueryImpl> query = select(
+                ServiceLabelRecord.LABEL
+        )
+                .from(client.getDatabase(), ServiceLabelRecord.INDEX_NAME)
+                .where();
+
+        query.and(eq(ServiceLabelRecord.SERVICE_ID, serviceId));
+
+        return parseLabels(query);
+    }
+
+    private List<String> parseLabels(WhereQueryImpl<SelectQueryImpl> query) throws IOException {
+        final QueryResult.Series series = client.queryForSingleSeries(query);
+        if (log.isDebugEnabled()) {
+            log.debug("SQL: {}, result: {}", query.getCommand(), series);
+        }
+
+        if (Objects.isNull(series)) {
+            return Collections.emptyList();
+        }
+
+        return series.getValues().stream().map(v -> (String) v.get(1)).collect(Collectors.toList());

Review Comment:
   ignore



##########
oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java:
##########
@@ -316,6 +355,11 @@ private List<Process> buildProcesses(ResultSet resultSet) throws SQLException {
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelJsonString = resultSet.getString(ProcessTraffic.LABELS_JSON);
+            if (!Strings.isNullOrEmpty(labelJsonString)) {
+                List<String> labels = GSON.<List<String>>fromJson(labelJsonString, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   ignore



-- 
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


[GitHub] [skywalking] mrproliu commented on pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#issuecomment-1094225315

   The service label is used to aggregate all of the labels from the process to the service level. Then, we could do profiling with some similar process from the service level. So we need the `process_service_label` to record them. 
   For now, I flat all the labels to the multiple records, in this way, we don't need to worry about the limit of labels count. 


-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846868573


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/EBPFProfilingMutationService.java:
##########
@@ -113,18 +121,27 @@ private EBPFProfilingTaskCreationResult buildError(String msg) {
     }
 
     private String checkCreateRequest(EBPFProfilingTaskFixedTimeCreationRequest request) throws IOException {
-        String err = "";
+        String err = null;
 
-        // validate process finder
-        if (request.getProcessFinder() == null) {
-            return "The process finder could not be null";
-        }
-        if (request.getProcessFinder().getFinderType() == null) {
-            return "The process find type could not be null";
+        err = requiredNotEmpty(err, "service", request.getServiceId());
+
+        // the service must have processes
+        if (err == null && getMetadataQueryDAO().getProcessesCount(request.getServiceId(), null, null) <= 0) {
+            err = "current service haven't any process";
         }
-        switch (request.getProcessFinder().getFinderType()) {
-            case PROCESS_ID:
-                err = requiredNotEmpty(err, "process id", request.getProcessFinder().getProcessId());
+
+        // the process label must be existed

Review Comment:
   ```suggestion
           // the request label must be legal
   ```



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849621495


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/event/EventQueryCondition.java:
##########
@@ -43,5 +43,7 @@ public class EventQueryCondition {
 
     private Order order;
 
+    private String layer;

Review Comment:
   Sure, I have updated. 



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849647682


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/EBPFProfilingQueryService.java:
##########
@@ -169,6 +217,9 @@ private Process convertProcess(ProcessTraffic traffic) {
                 process.getAttributes().add(new Attribute(key, traffic.getProperties().get(key).getAsString()));
             }
         }
+        if (StringUtil.isNotEmpty(traffic.getLabelsJson())) {
+            process.getLabels().addAll(GSON.<List<String>>fromJson(traffic.getLabelsJson(), ArrayList.class));

Review Comment:
   ignore



##########
oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java:
##########
@@ -316,6 +357,11 @@ private List<Process> buildProcesses(ResultSet resultSet) throws SQLException {
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelJsonString = resultSet.getString(ProcessTraffic.LABELS_JSON);
+            if (!Strings.isNullOrEmpty(labelJsonString)) {
+                List<String> labels = GSON.<List<String>>fromJson(labelJsonString, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   ignore



##########
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/ServiceLabelQuery.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.storage.plugin.influxdb.query;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.manual.process.ServiceLabelRecord;
+import org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IServiceLabelDAO;
+import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxClient;
+import org.influxdb.dto.QueryResult;
+import org.influxdb.querybuilder.SelectQueryImpl;
+import org.influxdb.querybuilder.WhereQueryImpl;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
+
+@Slf4j
+@RequiredArgsConstructor
+public class ServiceLabelQuery implements IServiceLabelDAO {
+    private final InfluxClient client;
+
+    @Override
+    public List<String> queryAllLabels(String serviceId) throws IOException {
+        final WhereQueryImpl<SelectQueryImpl> query = select(
+                ServiceLabelRecord.LABEL
+        )
+                .from(client.getDatabase(), ServiceLabelRecord.INDEX_NAME)
+                .where();
+
+        query.and(eq(ServiceLabelRecord.SERVICE_ID, serviceId));
+
+        return parseLabels(query);
+    }
+
+    private List<String> parseLabels(WhereQueryImpl<SelectQueryImpl> query) throws IOException {
+        final QueryResult.Series series = client.queryForSingleSeries(query);
+        if (log.isDebugEnabled()) {
+            log.debug("SQL: {}, result: {}", query.getCommand(), series);
+        }
+
+        if (Objects.isNull(series)) {
+            return Collections.emptyList();
+        }
+
+        return series.getValues().stream().map(v -> (String) v.get(1)).collect(Collectors.toList());

Review Comment:
   ignore



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849647917


##########
oap-server/server-storage-plugin/storage-iotdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/iotdb/query/IoTDBMetadataQueryDAO.java:
##########
@@ -267,6 +301,11 @@ private List<Process> buildProcesses(List<? super StorageData> storageDataList)
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelsJson = processTraffic.getLabelsJson();
+            if (StringUtil.isNotEmpty(labelsJson)) {
+                final List<String> labels = GSON.<List<String>>fromJson(labelsJson, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   ignore



##########
oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java:
##########
@@ -316,6 +357,11 @@ private List<Process> buildProcesses(ResultSet resultSet) throws SQLException {
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelJsonString = resultSet.getString(ProcessTraffic.LABELS_JSON);
+            if (!Strings.isNullOrEmpty(labelJsonString)) {
+                List<String> labels = GSON.<List<String>>fromJson(labelJsonString, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   ignore



##########
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/ServiceLabelQuery.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.storage.plugin.influxdb.query;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.manual.process.ServiceLabelRecord;
+import org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IServiceLabelDAO;
+import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxClient;
+import org.influxdb.dto.QueryResult;
+import org.influxdb.querybuilder.SelectQueryImpl;
+import org.influxdb.querybuilder.WhereQueryImpl;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
+
+@Slf4j
+@RequiredArgsConstructor
+public class ServiceLabelQuery implements IServiceLabelDAO {
+    private final InfluxClient client;
+
+    @Override
+    public List<String> queryAllLabels(String serviceId) throws IOException {
+        final WhereQueryImpl<SelectQueryImpl> query = select(
+                ServiceLabelRecord.LABEL
+        )
+                .from(client.getDatabase(), ServiceLabelRecord.INDEX_NAME)
+                .where();
+
+        query.and(eq(ServiceLabelRecord.SERVICE_ID, serviceId));
+
+        return parseLabels(query);
+    }
+
+    private List<String> parseLabels(WhereQueryImpl<SelectQueryImpl> query) throws IOException {
+        final QueryResult.Series series = client.queryForSingleSeries(query);
+        if (log.isDebugEnabled()) {
+            log.debug("SQL: {}, result: {}", query.getCommand(), series);
+        }
+
+        if (Objects.isNull(series)) {
+            return Collections.emptyList();
+        }
+
+        return series.getValues().stream().map(v -> (String) v.get(1)).collect(Collectors.toList());

Review Comment:
   ignore



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849661445


##########
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/ServiceLabelQuery.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.storage.plugin.influxdb.query;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.manual.process.ServiceLabelRecord;
+import org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IServiceLabelDAO;
+import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxClient;
+import org.influxdb.dto.QueryResult;
+import org.influxdb.querybuilder.SelectQueryImpl;
+import org.influxdb.querybuilder.WhereQueryImpl;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
+
+@Slf4j
+@RequiredArgsConstructor
+public class ServiceLabelQuery implements IServiceLabelDAO {
+    private final InfluxClient client;
+
+    @Override
+    public List<String> queryAllLabels(String serviceId) throws IOException {
+        final WhereQueryImpl<SelectQueryImpl> query = select(
+                ServiceLabelRecord.LABEL
+        )
+                .from(client.getDatabase(), ServiceLabelRecord.INDEX_NAME)
+                .where();
+
+        query.and(eq(ServiceLabelRecord.SERVICE_ID, serviceId));
+
+        return parseLabels(query);
+    }
+
+    private List<String> parseLabels(WhereQueryImpl<SelectQueryImpl> query) throws IOException {
+        final QueryResult.Series series = client.queryForSingleSeries(query);
+        if (log.isDebugEnabled()) {
+            log.debug("SQL: {}, result: {}", query.getCommand(), series);
+        }
+
+        if (Objects.isNull(series)) {
+            return Collections.emptyList();
+        }
+
+        return series.getValues().stream().map(v -> (String) v.get(1)).collect(Collectors.toList());

Review Comment:
   ignore



-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849645574


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/EBPFProfilingQueryService.java:
##########
@@ -169,6 +217,9 @@ private Process convertProcess(ProcessTraffic traffic) {
                 process.getAttributes().add(new Attribute(key, traffic.getProperties().get(key).getAsString()));
             }
         }
+        if (StringUtil.isNotEmpty(traffic.getLabelsJson())) {
+            process.getLabels().addAll(GSON.<List<String>>fromJson(traffic.getLabelsJson(), ArrayList.class));

Review Comment:
   *NULL_DEREFERENCE:*  object returned by `getLabels(process)` could be null and is dereferenced at line 221.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)
   
   ---
   
   Was this a good recommendation?
   [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=191624642&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=191624642&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191624642&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191624642&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=191624642&lift_comment_rating=5) ]



##########
oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java:
##########
@@ -316,6 +357,11 @@ private List<Process> buildProcesses(ResultSet resultSet) throws SQLException {
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelJsonString = resultSet.getString(ProcessTraffic.LABELS_JSON);
+            if (!Strings.isNullOrEmpty(labelJsonString)) {
+                List<String> labels = GSON.<List<String>>fromJson(labelJsonString, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   *NULL_DEREFERENCE:*  object returned by `getLabels(process)` could be null and is dereferenced at line 363.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)
   
   ---
   
   Was this a good recommendation?
   [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=191624637&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=191624637&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191624637&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191624637&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=191624637&lift_comment_rating=5) ]



##########
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/ServiceLabelQuery.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.storage.plugin.influxdb.query;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.manual.process.ServiceLabelRecord;
+import org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IServiceLabelDAO;
+import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxClient;
+import org.influxdb.dto.QueryResult;
+import org.influxdb.querybuilder.SelectQueryImpl;
+import org.influxdb.querybuilder.WhereQueryImpl;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
+
+@Slf4j
+@RequiredArgsConstructor
+public class ServiceLabelQuery implements IServiceLabelDAO {
+    private final InfluxClient client;
+
+    @Override
+    public List<String> queryAllLabels(String serviceId) throws IOException {
+        final WhereQueryImpl<SelectQueryImpl> query = select(
+                ServiceLabelRecord.LABEL
+        )
+                .from(client.getDatabase(), ServiceLabelRecord.INDEX_NAME)
+                .where();
+
+        query.and(eq(ServiceLabelRecord.SERVICE_ID, serviceId));
+
+        return parseLabels(query);
+    }
+
+    private List<String> parseLabels(WhereQueryImpl<SelectQueryImpl> query) throws IOException {
+        final QueryResult.Series series = client.queryForSingleSeries(query);
+        if (log.isDebugEnabled()) {
+            log.debug("SQL: {}, result: {}", query.getCommand(), series);
+        }
+
+        if (Objects.isNull(series)) {
+            return Collections.emptyList();
+        }
+
+        return series.getValues().stream().map(v -> (String) v.get(1)).collect(Collectors.toList());

Review Comment:
   *NULL_DEREFERENCE:*  object `series` last assigned on line 57 could be null and is dereferenced at line 66.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)
   
   ---
   
   Was this a good recommendation?
   [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=191624634&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=191624634&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191624634&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191624634&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=191624634&lift_comment_rating=5) ]



##########
oap-server/server-storage-plugin/storage-iotdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/iotdb/query/IoTDBMetadataQueryDAO.java:
##########
@@ -267,6 +301,11 @@ private List<Process> buildProcesses(List<? super StorageData> storageDataList)
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelsJson = processTraffic.getLabelsJson();
+            if (StringUtil.isNotEmpty(labelsJson)) {
+                final List<String> labels = GSON.<List<String>>fromJson(labelsJson, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   *NULL_DEREFERENCE:*  object returned by `getLabels(process)` could be null and is dereferenced at line 307.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)
   
   ---
   
   Was this a good recommendation?
   [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=191624676&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=191624676&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191624676&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191624676&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=191624676&lift_comment_rating=5) ]



-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846763907


##########
oap-server/server-receiver-plugin/skywalking-ebpf-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/ebpf/provider/handler/EBPFProfilingServiceHandler.java:
##########
@@ -100,6 +102,35 @@ public void queryTasks(EBPFProfilingTaskQuery request, StreamObserver<Commands>
         responseObserver.onCompleted();
     }
 
+    private List<EBPFProfilingTaskCommand> buildProfilingCommands(EBPFProfilingTask task, List<Process> processes) {
+        final ArrayList<EBPFProfilingTaskCommand> commands = new ArrayList<>(processes.size());
+        for (Process process : processes) {
+            // The service id must matches between process and task
+            if (!Objects.equals(process.getServiceId(), task.getServiceId())) {
+                continue;
+            }
+
+            // If the task haven't labeled requirement, them just add the process

Review Comment:
   ```suggestion
               // If the task doesn't require a label, them just add the process
   ```



-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846763830


##########
oap-server/server-receiver-plugin/skywalking-ebpf-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/ebpf/provider/handler/EBPFProfilingServiceHandler.java:
##########
@@ -100,6 +102,35 @@ public void queryTasks(EBPFProfilingTaskQuery request, StreamObserver<Commands>
         responseObserver.onCompleted();
     }
 
+    private List<EBPFProfilingTaskCommand> buildProfilingCommands(EBPFProfilingTask task, List<Process> processes) {
+        final ArrayList<EBPFProfilingTaskCommand> commands = new ArrayList<>(processes.size());
+        for (Process process : processes) {
+            // The service id must matches between process and task

Review Comment:
   ```suggestion
               // The service id must match between process and task
   ```



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846778143


##########
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/ServiceLabelQuery.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.storage.plugin.influxdb.query;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.manual.process.ServiceLabelRecord;
+import org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IServiceLabelDAO;
+import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxClient;
+import org.influxdb.dto.QueryResult;
+import org.influxdb.querybuilder.SelectQueryImpl;
+import org.influxdb.querybuilder.WhereQueryImpl;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
+
+@Slf4j
+@RequiredArgsConstructor
+public class ServiceLabelQuery implements IServiceLabelDAO {
+    private final InfluxClient client;
+
+    @Override
+    public List<String> queryAllLabels(String serviceId) throws IOException {
+        final WhereQueryImpl<SelectQueryImpl> query = select(
+                ServiceLabelRecord.LABEL
+        )
+                .from(client.getDatabase(), ServiceLabelRecord.INDEX_NAME)
+                .where();
+
+        query.and(eq(ServiceLabelRecord.SERVICE_ID, serviceId));
+
+        return parseLabels(query);
+    }
+
+    private List<String> parseLabels(WhereQueryImpl<SelectQueryImpl> query) throws IOException {
+        final QueryResult.Series series = client.queryForSingleSeries(query);
+        if (log.isDebugEnabled()) {
+            log.debug("SQL: {}, result: {}", query.getCommand(), series);
+        }
+
+        if (Objects.isNull(series)) {
+            return Collections.emptyList();
+        }
+
+        return series.getValues().stream().map(v -> (String) v.get(1)).collect(Collectors.toList());

Review Comment:
   ignore



-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846734836


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/storage/EBPFProfilingTaskRecord.java:
##########
@@ -41,30 +40,20 @@
 @Stream(name = EBPFProfilingTaskRecord.INDEX_NAME, scopeId = EBPF_PROFILING_TASK,
         builder = EBPFProfilingTaskRecord.Builder.class, processor = NoneStreamProcessor.class)
 public class EBPFProfilingTaskRecord extends NoneStream {
-
     public static final String INDEX_NAME = "ebpf_profiling_task";
-    public static final String PROCESS_FIND_TYPE = "process_find_type";
     public static final String SERVICE_ID = "service_id";
-    public static final String INSTANCE_ID = "instance_id";
-    public static final String PROCESS_ID = "process_id";
-    public static final String PROCESS_NAME = "process_name";
+    public static final String PROCESS_LABELS_JSON = "process_labels_json";
     public static final String START_TIME = "start_time";
     public static final String TRIGGER_TYPE = "trigger_type";
     public static final String FIXED_TRIGGER_DURATION = "fixed_trigger_duration";
     public static final String TARGET_TYPE = "target_type";
     public static final String CREATE_TIME = "create_time";
     public static final String LAST_UPDATE_TIME = "last_update_time";
 
-    @Column(columnName = PROCESS_FIND_TYPE)
-    private int processFindType = EBPFProfilingProcessFinderType.UNKNOWN.value();
     @Column(columnName = SERVICE_ID)
     private String serviceId;
-    @Column(columnName = INSTANCE_ID, length = 600)
-    private String instanceId;
-    @Column(columnName = PROCESS_ID, length = 600)
-    private String processId;
-    @Column(columnName = PROCESS_NAME, length = 500)
-    private String processName;
+    @Column(columnName = PROCESS_LABELS_JSON)

Review Comment:
   I think we should have the length of the label?



-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849252601


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IMetadataQueryDAO.java:
##########
@@ -64,7 +64,17 @@ List<ServiceInstance> listInstances(final long startTimestamp, final long endTim
      * @param agentId the agent id which reports the process.
      * @return list of processes matching the given conditions.
      */
-    List<Process> listProcesses(final String serviceId, final String instanceId, final String agentId) throws IOException;
+    List<Process> listProcesses(final String serviceId, final String instanceId, final String agentId,
+                                final long lastPingStartTimeBucket, final long lastPingEndTimeBucket) throws IOException;
+
+    /**
+     * get the count of processes
+     * @param serviceId the service of the processes.
+     * @param instanceId the service instance of the process.
+     * @param agentId the agent id which reports the process.
+     * @return the size of processes
+     */
+    long getProcessesCount(final String serviceId, final String instanceId, final String agentId) throws IOException;

Review Comment:
   Whether these two should be merged? I am feeling these are the same thing?



-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849274387


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IMetadataQueryDAO.java:
##########
@@ -64,7 +64,17 @@ List<ServiceInstance> listInstances(final long startTimestamp, final long endTim
      * @param agentId the agent id which reports the process.
      * @return list of processes matching the given conditions.
      */
-    List<Process> listProcesses(final String serviceId, final String instanceId, final String agentId) throws IOException;
+    List<Process> listProcesses(final String serviceId, final String instanceId, final String agentId,
+                                final long lastPingStartTimeBucket, final long lastPingEndTimeBucket) throws IOException;
+
+    /**
+     * get the count of processes
+     * @param serviceId the service of the processes.
+     * @param instanceId the service instance of the process.
+     * @param agentId the agent id which reports the process.
+     * @return the size of processes
+     */
+    long getProcessesCount(final String serviceId, final String instanceId, final String agentId) throws IOException;

Review Comment:
   OK, from a performance perspective, this makes sense with two methods. But, to get the number of processes, the time range is important. Then 



-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849644396


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/EBPFProfilingQueryService.java:
##########
@@ -169,6 +217,9 @@ private Process convertProcess(ProcessTraffic traffic) {
                 process.getAttributes().add(new Attribute(key, traffic.getProperties().get(key).getAsString()));
             }
         }
+        if (StringUtil.isNotEmpty(traffic.getLabelsJson())) {
+            process.getLabels().addAll(GSON.<List<String>>fromJson(traffic.getLabelsJson(), ArrayList.class));

Review Comment:
   *NULL_DEREFERENCE:*  object returned by `getLabels(process)` could be null and is dereferenced at line 221.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)
   
   ---
   
   Was this a good recommendation?
   [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=191623857&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=191623857&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191623857&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191623857&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=191623857&lift_comment_rating=5) ]



##########
oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java:
##########
@@ -316,6 +357,11 @@ private List<Process> buildProcesses(ResultSet resultSet) throws SQLException {
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelJsonString = resultSet.getString(ProcessTraffic.LABELS_JSON);
+            if (!Strings.isNullOrEmpty(labelJsonString)) {
+                List<String> labels = GSON.<List<String>>fromJson(labelJsonString, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   *NULL_DEREFERENCE:*  object returned by `getLabels(process)` could be null and is dereferenced at line 363.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)
   
   ---
   
   Was this a good recommendation?
   [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=191623871&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=191623871&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191623871&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191623871&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=191623871&lift_comment_rating=5) ]



##########
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/ServiceLabelQuery.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.storage.plugin.influxdb.query;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.manual.process.ServiceLabelRecord;
+import org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IServiceLabelDAO;
+import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxClient;
+import org.influxdb.dto.QueryResult;
+import org.influxdb.querybuilder.SelectQueryImpl;
+import org.influxdb.querybuilder.WhereQueryImpl;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
+
+@Slf4j
+@RequiredArgsConstructor
+public class ServiceLabelQuery implements IServiceLabelDAO {
+    private final InfluxClient client;
+
+    @Override
+    public List<String> queryAllLabels(String serviceId) throws IOException {
+        final WhereQueryImpl<SelectQueryImpl> query = select(
+                ServiceLabelRecord.LABEL
+        )
+                .from(client.getDatabase(), ServiceLabelRecord.INDEX_NAME)
+                .where();
+
+        query.and(eq(ServiceLabelRecord.SERVICE_ID, serviceId));
+
+        return parseLabels(query);
+    }
+
+    private List<String> parseLabels(WhereQueryImpl<SelectQueryImpl> query) throws IOException {
+        final QueryResult.Series series = client.queryForSingleSeries(query);
+        if (log.isDebugEnabled()) {
+            log.debug("SQL: {}, result: {}", query.getCommand(), series);
+        }
+
+        if (Objects.isNull(series)) {
+            return Collections.emptyList();
+        }
+
+        return series.getValues().stream().map(v -> (String) v.get(1)).collect(Collectors.toList());

Review Comment:
   *NULL_DEREFERENCE:*  object `series` last assigned on line 57 could be null and is dereferenced at line 66.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)
   
   ---
   
   Was this a good recommendation?
   [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=191623902&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=191623902&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191623902&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191623902&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=191623902&lift_comment_rating=5) ]



##########
oap-server/server-storage-plugin/storage-iotdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/iotdb/query/IoTDBMetadataQueryDAO.java:
##########
@@ -267,6 +301,11 @@ private List<Process> buildProcesses(List<? super StorageData> storageDataList)
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelsJson = processTraffic.getLabelsJson();
+            if (StringUtil.isNotEmpty(labelsJson)) {
+                final List<String> labels = GSON.<List<String>>fromJson(labelsJson, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   *NULL_DEREFERENCE:*  object returned by `getLabels(process)` could be null and is dereferenced at line 307.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)
   
   ---
   
   Was this a good recommendation?
   [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=191623880&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=191623880&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191623880&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191623880&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=191623880&lift_comment_rating=5) ]



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846777515


##########
oap-server/server-receiver-plugin/skywalking-ebpf-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/ebpf/provider/handler/EBPFProfilingServiceHandler.java:
##########
@@ -100,6 +102,35 @@ public void queryTasks(EBPFProfilingTaskQuery request, StreamObserver<Commands>
         responseObserver.onCompleted();
     }
 
+    private List<EBPFProfilingTaskCommand> buildProfilingCommands(EBPFProfilingTask task, List<Process> processes) {
+        final ArrayList<EBPFProfilingTaskCommand> commands = new ArrayList<>(processes.size());
+        for (Process process : processes) {
+            // The service id must matches between process and task
+            if (!Objects.equals(process.getServiceId(), task.getServiceId())) {
+                continue;
+            }
+
+            // If the task haven't labeled requirement, them just add the process
+            boolean shouldAdd = false;
+            if (CollectionUtils.isEmpty(task.getProcessLabels())) {
+                shouldAdd = true;
+            } else {
+                // If the process have matched one of the task label, them need to add the command

Review Comment:
   Understand. For now, we haven't a UI to show how many processes matched. But I think matching all labels is more make sense. 



-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846742520


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ProcessServiceLabel.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.source;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+import org.apache.skywalking.oap.server.core.analysis.IDManager;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROCESS_SERVICE_LABEL;
+
+@ScopeDeclaration(id = PROCESS_SERVICE_LABEL, name = "ProcessServiceLabel")
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
+public class ProcessServiceLabel extends Source {
+    private volatile String entityId;
+
+    @Override
+    public int scope() {
+        return PROCESS_SERVICE_LABEL;
+    }
+
+    @Override
+    public String getEntityId() {
+        if (entityId == null) {
+            entityId = serviceId + Const.ID_CONNECTOR + new String(Base64.getEncoder()
+                    .encode(label.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8);
+        }
+        return entityId;
+    }
+
+    @Getter
+    private String serviceId;
+    @Setter
+    @Getter
+    private boolean isServiceNormal;
+    @Setter
+    @Getter
+    private String serviceName;
+    @Setter
+    @Getter
+    private String label;

Review Comment:
   label or labels? 



-- 
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


[GitHub] [skywalking] wu-sheng commented on pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#issuecomment-1094227698

   So, we have 
   1. ProcessTraffic with JSON-ed labels
   2. ProcessServiceLabel is service's all labels
   
   Then, when a task is created, all processes are read out and filtered in the memory?


-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846782745


##########
oap-server/server-receiver-plugin/skywalking-ebpf-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/ebpf/provider/handler/EBPFProfilingServiceHandler.java:
##########
@@ -100,6 +102,35 @@ public void queryTasks(EBPFProfilingTaskQuery request, StreamObserver<Commands>
         responseObserver.onCompleted();
     }
 
+    private List<EBPFProfilingTaskCommand> buildProfilingCommands(EBPFProfilingTask task, List<Process> processes) {
+        final ArrayList<EBPFProfilingTaskCommand> commands = new ArrayList<>(processes.size());
+        for (Process process : processes) {
+            // The service id must matches between process and task
+            if (!Objects.equals(process.getServiceId(), task.getServiceId())) {
+                continue;
+            }
+
+            // If the task haven't labeled requirement, them just add the process
+            boolean shouldAdd = false;
+            if (CollectionUtils.isEmpty(task.getProcessLabels())) {
+                shouldAdd = true;
+            } else {
+                // If the process have matched one of the task label, them need to add the command

Review Comment:
   Sure, please make sure this is considered as a part of the visualization design. After all, listing all is working, but no one is really going to read them one by one.



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849009732


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/storage/EBPFProfilingTaskRecord.java:
##########
@@ -41,30 +40,20 @@
 @Stream(name = EBPFProfilingTaskRecord.INDEX_NAME, scopeId = EBPF_PROFILING_TASK,
         builder = EBPFProfilingTaskRecord.Builder.class, processor = NoneStreamProcessor.class)
 public class EBPFProfilingTaskRecord extends NoneStream {
-
     public static final String INDEX_NAME = "ebpf_profiling_task";
-    public static final String PROCESS_FIND_TYPE = "process_find_type";
     public static final String SERVICE_ID = "service_id";
-    public static final String INSTANCE_ID = "instance_id";
-    public static final String PROCESS_ID = "process_id";
-    public static final String PROCESS_NAME = "process_name";
+    public static final String PROCESS_LABELS_JSON = "process_labels_json";
     public static final String START_TIME = "start_time";
     public static final String TRIGGER_TYPE = "trigger_type";
     public static final String FIXED_TRIGGER_DURATION = "fixed_trigger_duration";
     public static final String TARGET_TYPE = "target_type";
     public static final String CREATE_TIME = "create_time";
     public static final String LAST_UPDATE_TIME = "last_update_time";
 
-    @Column(columnName = PROCESS_FIND_TYPE)
-    private int processFindType = EBPFProfilingProcessFinderType.UNKNOWN.value();
     @Column(columnName = SERVICE_ID)
     private String serviceId;
-    @Column(columnName = INSTANCE_ID, length = 600)
-    private String instanceId;
-    @Column(columnName = PROCESS_ID, length = 600)
-    private String processId;
-    @Column(columnName = PROCESS_NAME, length = 500)
-    private String processName;
+    @Column(columnName = PROCESS_LABELS_JSON, length = 1000)

Review Comment:
   Updated. Check on the GraphQL.



##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ProcessLabel.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.source;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+import org.apache.skywalking.oap.server.core.analysis.IDManager;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SERVICE_LABEL;
+
+@ScopeDeclaration(id = SERVICE_LABEL, name = "ServiceLabel")
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
+public class ProcessLabel extends Source {

Review Comment:
   Updated.



-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849035260


##########
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/ServiceLabelQuery.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.storage.plugin.influxdb.query;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.manual.process.ServiceLabelRecord;
+import org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IServiceLabelDAO;
+import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxClient;
+import org.influxdb.dto.QueryResult;
+import org.influxdb.querybuilder.SelectQueryImpl;
+import org.influxdb.querybuilder.WhereQueryImpl;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
+
+@Slf4j
+@RequiredArgsConstructor
+public class ServiceLabelQuery implements IServiceLabelDAO {
+    private final InfluxClient client;
+
+    @Override
+    public List<String> queryAllLabels(String serviceId) throws IOException {
+        final WhereQueryImpl<SelectQueryImpl> query = select(
+                ServiceLabelRecord.LABEL
+        )
+                .from(client.getDatabase(), ServiceLabelRecord.INDEX_NAME)
+                .where();
+
+        query.and(eq(ServiceLabelRecord.SERVICE_ID, serviceId));
+
+        return parseLabels(query);
+    }
+
+    private List<String> parseLabels(WhereQueryImpl<SelectQueryImpl> query) throws IOException {
+        final QueryResult.Series series = client.queryForSingleSeries(query);
+        if (log.isDebugEnabled()) {
+            log.debug("SQL: {}, result: {}", query.getCommand(), series);
+        }
+
+        if (Objects.isNull(series)) {
+            return Collections.emptyList();
+        }
+
+        return series.getValues().stream().map(v -> (String) v.get(1)).collect(Collectors.toList());

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846697914


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/process/ProcessServiceLabelRecord.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.manual.process;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+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.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;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROCESS_SERVICE_LABEL;
+
+/**
+ * Process have multiple labels, such as tag.
+ * {@link ProcessServiceLabelRecord} could combine them in the service level.
+ * It could help to quickly locate the similar process by the service and label.
+ */
+@Setter
+@Getter
+@Stream(name = ProcessServiceLabelRecord.INDEX_NAME, scopeId = PROCESS_SERVICE_LABEL,
+        builder = ProcessServiceLabelRecord.Builder.class, processor = MetricsStreamProcessor.class)
+@MetricsExtension(supportDownSampling = false, supportUpdate = false)
+@EqualsAndHashCode(of = {

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846753416


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ProcessServiceLabel.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.source;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+import org.apache.skywalking.oap.server.core.analysis.IDManager;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROCESS_SERVICE_LABEL;
+
+@ScopeDeclaration(id = PROCESS_SERVICE_LABEL, name = "ProcessServiceLabel")
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
+public class ProcessServiceLabel extends Source {

Review Comment:
   > Also, I think ServiceLabels is a better name? ProcessServiceLabel makes me feeling strange whether this is a service or process's label.
   
   Updated. 



-- 
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


[GitHub] [skywalking] mrproliu commented on pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#issuecomment-1094234297

   > Then, when a task is created, all processes are read out and filtered in the memory?
   
   Yes. When a task is created, the OAP side read all the processes from the rover side and matches the same labels between process and task. 
   Here is the filter logical: https://github.com/apache/skywalking/pull/8840/files#diff-d2a3c28709c4f0350cd39a3c53bc401b7a5e7f1c73d4f08a6a2457529c28010fR105-R132


-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846744259


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/process/ProcessServiceLabelRecord.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.manual.process;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+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.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;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROCESS_SERVICE_LABEL;
+
+/**
+ * Process have multiple labels, such as tag.
+ * {@link ProcessServiceLabelRecord} could combine them in the service level.
+ * It could help to quickly locate the similar process by the service and label.
+ */
+@Setter
+@Getter
+@Stream(name = ProcessServiceLabelRecord.INDEX_NAME, scopeId = PROCESS_SERVICE_LABEL,
+        builder = ProcessServiceLabelRecord.Builder.class, processor = MetricsStreamProcessor.class)
+@MetricsExtension(supportDownSampling = false, supportUpdate = false)
+@EqualsAndHashCode(of = {
+        "serviceId",
+        "label"
+})
+public class ProcessServiceLabelRecord extends Metrics {
+
+    public static final String INDEX_NAME = "process_service_label";
+    public static final String SERVICE_ID = "service_id";
+    public static final String LABEL = "label";
+
+    @Column(columnName = SERVICE_ID)
+    private String serviceId;
+    @Column(columnName = LABEL)
+    private String label;

Review Comment:
   I just flat the labels to multiple records(If there have two labels in the service, there would have two records). Do you think we need to combine them as a single record? 



-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846869468


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ProcessLabel.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.source;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+import org.apache.skywalking.oap.server.core.analysis.IDManager;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SERVICE_LABEL;
+
+@ScopeDeclaration(id = SERVICE_LABEL, name = "ServiceLabel")
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
+public class ProcessLabel extends Source {

Review Comment:
   Forget to change? `ScopeDeclaration=ServiceLabel`, but class name is `ProcessLabel`



-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849647707


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/EBPFProfilingQueryService.java:
##########
@@ -169,6 +217,9 @@ private Process convertProcess(ProcessTraffic traffic) {
                 process.getAttributes().add(new Attribute(key, traffic.getProperties().get(key).getAsString()));
             }
         }
+        if (StringUtil.isNotEmpty(traffic.getLabelsJson())) {
+            process.getLabels().addAll(GSON.<List<String>>fromJson(traffic.getLabelsJson(), ArrayList.class));

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



##########
oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java:
##########
@@ -316,6 +357,11 @@ private List<Process> buildProcesses(ResultSet resultSet) throws SQLException {
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelJsonString = resultSet.getString(ProcessTraffic.LABELS_JSON);
+            if (!Strings.isNullOrEmpty(labelJsonString)) {
+                List<String> labels = GSON.<List<String>>fromJson(labelJsonString, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



##########
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/ServiceLabelQuery.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.storage.plugin.influxdb.query;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.manual.process.ServiceLabelRecord;
+import org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IServiceLabelDAO;
+import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxClient;
+import org.influxdb.dto.QueryResult;
+import org.influxdb.querybuilder.SelectQueryImpl;
+import org.influxdb.querybuilder.WhereQueryImpl;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
+
+@Slf4j
+@RequiredArgsConstructor
+public class ServiceLabelQuery implements IServiceLabelDAO {
+    private final InfluxClient client;
+
+    @Override
+    public List<String> queryAllLabels(String serviceId) throws IOException {
+        final WhereQueryImpl<SelectQueryImpl> query = select(
+                ServiceLabelRecord.LABEL
+        )
+                .from(client.getDatabase(), ServiceLabelRecord.INDEX_NAME)
+                .where();
+
+        query.and(eq(ServiceLabelRecord.SERVICE_ID, serviceId));
+
+        return parseLabels(query);
+    }
+
+    private List<String> parseLabels(WhereQueryImpl<SelectQueryImpl> query) throws IOException {
+        final QueryResult.Series series = client.queryForSingleSeries(query);
+        if (log.isDebugEnabled()) {
+            log.debug("SQL: {}, result: {}", query.getCommand(), series);
+        }
+
+        if (Objects.isNull(series)) {
+            return Collections.emptyList();
+        }
+
+        return series.getValues().stream().map(v -> (String) v.get(1)).collect(Collectors.toList());

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849268038


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IMetadataQueryDAO.java:
##########
@@ -64,7 +64,17 @@ List<ServiceInstance> listInstances(final long startTimestamp, final long endTim
      * @param agentId the agent id which reports the process.
      * @return list of processes matching the given conditions.
      */
-    List<Process> listProcesses(final String serviceId, final String instanceId, final String agentId) throws IOException;
+    List<Process> listProcesses(final String serviceId, final String instanceId, final String agentId,
+                                final long lastPingStartTimeBucket, final long lastPingEndTimeBucket) throws IOException;
+
+    /**
+     * get the count of processes
+     * @param serviceId the service of the processes.
+     * @param instanceId the service instance of the process.
+     * @param agentId the agent id which reports the process.
+     * @return the size of processes
+     */
+    long getProcessesCount(final String serviceId, final String instanceId, final String agentId) throws IOException;

Review Comment:
   I also thought about this. the `listProcesses` just list all the processes, including the metadata of the processes. 
   But `getProcesses` is a quick way to query the count of simple metadata, doesn't need the metadata from the storage, and it could speed up the query time. 



-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846652314


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/process/ProcessServiceLabelRecord.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.manual.process;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+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.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;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROCESS_SERVICE_LABEL;
+
+/**
+ * Process have multiple labels, such as tag.
+ * {@link ProcessServiceLabelRecord} could combine them in the service level.
+ * It could help to quickly locate the similar process by the service and label.
+ */
+@Setter
+@Getter
+@Stream(name = ProcessServiceLabelRecord.INDEX_NAME, scopeId = PROCESS_SERVICE_LABEL,
+        builder = ProcessServiceLabelRecord.Builder.class, processor = MetricsStreamProcessor.class)
+@MetricsExtension(supportDownSampling = false, supportUpdate = false)
+@EqualsAndHashCode(of = {

Review Comment:
   *MissingOverride:*  canEqual overrides method in Metrics; expected @Override [(details)](https://errorprone.info/bugpattern/MissingOverride)
   ```suggestion
   @Override @EqualsAndHashCode(of = {
   ```
   
   
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846697912


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/process/ProcessServiceLabelRecord.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.manual.process;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+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.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;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROCESS_SERVICE_LABEL;
+
+/**
+ * Process have multiple labels, such as tag.
+ * {@link ProcessServiceLabelRecord} could combine them in the service level.
+ * It could help to quickly locate the similar process by the service and label.
+ */
+@Setter
+@Getter
+@Stream(name = ProcessServiceLabelRecord.INDEX_NAME, scopeId = PROCESS_SERVICE_LABEL,
+        builder = ProcessServiceLabelRecord.Builder.class, processor = MetricsStreamProcessor.class)
+@MetricsExtension(supportDownSampling = false, supportUpdate = false)
+@EqualsAndHashCode(of = {

Review Comment:
   ignore



-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846742397


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/process/ProcessServiceLabelRecord.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.manual.process;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+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.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;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROCESS_SERVICE_LABEL;
+
+/**
+ * Process have multiple labels, such as tag.
+ * {@link ProcessServiceLabelRecord} could combine them in the service level.
+ * It could help to quickly locate the similar process by the service and label.
+ */
+@Setter
+@Getter
+@Stream(name = ProcessServiceLabelRecord.INDEX_NAME, scopeId = PROCESS_SERVICE_LABEL,
+        builder = ProcessServiceLabelRecord.Builder.class, processor = MetricsStreamProcessor.class)
+@MetricsExtension(supportDownSampling = false, supportUpdate = false)
+@EqualsAndHashCode(of = {
+        "serviceId",
+        "label"
+})
+public class ProcessServiceLabelRecord extends Metrics {
+
+    public static final String INDEX_NAME = "process_service_label";
+    public static final String SERVICE_ID = "service_id";
+    public static final String LABEL = "label";
+
+    @Column(columnName = SERVICE_ID)
+    private String serviceId;
+    @Column(columnName = LABEL)
+    private String label;

Review Comment:
   label or labels?



##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/process/ProcessServiceLabelRecord.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.manual.process;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+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.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;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROCESS_SERVICE_LABEL;
+
+/**
+ * Process have multiple labels, such as tag.
+ * {@link ProcessServiceLabelRecord} could combine them in the service level.
+ * It could help to quickly locate the similar process by the service and label.
+ */
+@Setter
+@Getter
+@Stream(name = ProcessServiceLabelRecord.INDEX_NAME, scopeId = PROCESS_SERVICE_LABEL,
+        builder = ProcessServiceLabelRecord.Builder.class, processor = MetricsStreamProcessor.class)
+@MetricsExtension(supportDownSampling = false, supportUpdate = false)
+@EqualsAndHashCode(of = {
+        "serviceId",
+        "label"
+})
+public class ProcessServiceLabelRecord extends Metrics {
+
+    public static final String INDEX_NAME = "process_service_label";
+    public static final String SERVICE_ID = "service_id";
+    public static final String LABEL = "label";
+
+    @Column(columnName = SERVICE_ID)
+    private String serviceId;
+    @Column(columnName = LABEL)

Review Comment:
   Require length.



-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846764003


##########
oap-server/server-receiver-plugin/skywalking-ebpf-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/ebpf/provider/handler/EBPFProfilingServiceHandler.java:
##########
@@ -100,6 +102,35 @@ public void queryTasks(EBPFProfilingTaskQuery request, StreamObserver<Commands>
         responseObserver.onCompleted();
     }
 
+    private List<EBPFProfilingTaskCommand> buildProfilingCommands(EBPFProfilingTask task, List<Process> processes) {
+        final ArrayList<EBPFProfilingTaskCommand> commands = new ArrayList<>(processes.size());
+        for (Process process : processes) {
+            // The service id must matches between process and task
+            if (!Objects.equals(process.getServiceId(), task.getServiceId())) {
+                continue;
+            }
+
+            // If the task haven't labeled requirement, them just add the process
+            boolean shouldAdd = false;
+            if (CollectionUtils.isEmpty(task.getProcessLabels())) {
+                shouldAdd = true;
+            } else {
+                // If the process have matched one of the task label, them need to add the command

Review Comment:
   I think need to match all labels, not one of them.



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846752126


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/process/ProcessServiceLabelRecord.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.manual.process;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+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.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;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROCESS_SERVICE_LABEL;
+
+/**
+ * Process have multiple labels, such as tag.
+ * {@link ProcessServiceLabelRecord} could combine them in the service level.
+ * It could help to quickly locate the similar process by the service and label.
+ */
+@Setter
+@Getter
+@Stream(name = ProcessServiceLabelRecord.INDEX_NAME, scopeId = PROCESS_SERVICE_LABEL,
+        builder = ProcessServiceLabelRecord.Builder.class, processor = MetricsStreamProcessor.class)
+@MetricsExtension(supportDownSampling = false, supportUpdate = false)
+@EqualsAndHashCode(of = {
+        "serviceId",
+        "label"
+})
+public class ProcessServiceLabelRecord extends Metrics {
+
+    public static final String INDEX_NAME = "process_service_label";
+    public static final String SERVICE_ID = "service_id";
+    public static final String LABEL = "label";
+
+    @Column(columnName = SERVICE_ID)
+    private String serviceId;
+    @Column(columnName = LABEL)

Review Comment:
   I think the default length for the per label is enough. 



-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849035333


##########
oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java:
##########
@@ -316,6 +355,11 @@ private List<Process> buildProcesses(ResultSet resultSet) throws SQLException {
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelJsonString = resultSet.getString(ProcessTraffic.LABELS_JSON);
+            if (!Strings.isNullOrEmpty(labelJsonString)) {
+                List<String> labels = GSON.<List<String>>fromJson(labelJsonString, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849035415


##########
oap-server/server-storage-plugin/storage-iotdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/iotdb/query/IoTDBMetadataQueryDAO.java:
##########
@@ -267,6 +298,11 @@ private List<Process> buildProcesses(List<? super StorageData> storageDataList)
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelsJson = processTraffic.getLabelsJson();
+            if (StringUtil.isNotEmpty(labelsJson)) {
+                final List<String> labels = GSON.<List<String>>fromJson(labelsJson, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849613391


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/event/EventQueryCondition.java:
##########
@@ -43,5 +43,7 @@ public class EventQueryCondition {
 
     private Order order;
 
+    private String layer;

Review Comment:
   I think you should hard code Layer.UNDEFINED in here, which means minimal changes in irrelevant things, and help @fgksgf to avoid conflicts as much as possible. WDYT?



-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849662397


##########
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/ServiceLabelQuery.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.storage.plugin.influxdb.query;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.manual.process.ServiceLabelRecord;
+import org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IServiceLabelDAO;
+import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxClient;
+import org.influxdb.dto.QueryResult;
+import org.influxdb.querybuilder.SelectQueryImpl;
+import org.influxdb.querybuilder.WhereQueryImpl;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
+
+@Slf4j
+@RequiredArgsConstructor
+public class ServiceLabelQuery implements IServiceLabelDAO {
+    private final InfluxClient client;
+
+    @Override
+    public List<String> queryAllLabels(String serviceId) throws IOException {
+        final WhereQueryImpl<SelectQueryImpl> query = select(
+                ServiceLabelRecord.LABEL
+        )
+                .from(client.getDatabase(), ServiceLabelRecord.INDEX_NAME)
+                .where();
+
+        query.and(eq(ServiceLabelRecord.SERVICE_ID, serviceId));
+
+        return parseLabels(query);
+    }
+
+    private List<String> parseLabels(WhereQueryImpl<SelectQueryImpl> query) throws IOException {
+        final QueryResult.Series series = client.queryForSingleSeries(query);
+        if (log.isDebugEnabled()) {
+            log.debug("SQL: {}, result: {}", query.getCommand(), series);
+        }
+
+        if (Objects.isNull(series)) {
+            return Collections.emptyList();
+        }
+
+        return series.getValues().stream().map(v -> (String) v.get(1)).collect(Collectors.toList());

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849035156


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/EBPFProfilingQueryService.java:
##########
@@ -169,6 +209,9 @@ private Process convertProcess(ProcessTraffic traffic) {
                 process.getAttributes().add(new Attribute(key, traffic.getProperties().get(key).getAsString()));
             }
         }
+        if (StringUtil.isNotEmpty(traffic.getLabelsJson())) {
+            process.getLabels().addAll(GSON.<List<String>>fromJson(traffic.getLabelsJson(), ArrayList.class));

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849388221


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IMetadataQueryDAO.java:
##########
@@ -64,7 +64,17 @@ List<ServiceInstance> listInstances(final long startTimestamp, final long endTim
      * @param agentId the agent id which reports the process.
      * @return list of processes matching the given conditions.
      */
-    List<Process> listProcesses(final String serviceId, final String instanceId, final String agentId) throws IOException;
+    List<Process> listProcesses(final String serviceId, final String instanceId, final String agentId,
+                                final long lastPingStartTimeBucket, final long lastPingEndTimeBucket) throws IOException;
+
+    /**
+     * get the count of processes
+     * @param serviceId the service of the processes.
+     * @param instanceId the service instance of the process.
+     * @param agentId the agent id which reports the process.
+     * @return the size of processes
+     */
+    long getProcessesCount(final String serviceId, final String instanceId, final String agentId) throws IOException;

Review Comment:
   Updated. 



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846753381


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/process/ProcessServiceLabelRecord.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.manual.process;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+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.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;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROCESS_SERVICE_LABEL;
+
+/**
+ * Process have multiple labels, such as tag.
+ * {@link ProcessServiceLabelRecord} could combine them in the service level.
+ * It could help to quickly locate the similar process by the service and label.
+ */
+@Setter
+@Getter
+@Stream(name = ProcessServiceLabelRecord.INDEX_NAME, scopeId = PROCESS_SERVICE_LABEL,
+        builder = ProcessServiceLabelRecord.Builder.class, processor = MetricsStreamProcessor.class)
+@MetricsExtension(supportDownSampling = false, supportUpdate = false)
+@EqualsAndHashCode(of = {
+        "serviceId",
+        "label"
+})
+public class ProcessServiceLabelRecord extends Metrics {
+
+    public static final String INDEX_NAME = "process_service_label";
+    public static final String SERVICE_ID = "service_id";
+    public static final String LABEL = "label";
+
+    @Column(columnName = SERVICE_ID)
+    private String serviceId;
+    @Column(columnName = LABEL)

Review Comment:
   Updated to `50`.



-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846572097


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/EBPFProfilingQueryService.java:
##########
@@ -169,6 +204,9 @@ private Process convertProcess(ProcessTraffic traffic) {
                 process.getAttributes().add(new Attribute(key, traffic.getProperties().get(key).getAsString()));
             }
         }
+        if (StringUtil.isNotEmpty(traffic.getLabelsJson())) {
+            process.getLabels().addAll(GSON.<List<String>>fromJson(traffic.getLabelsJson(), ArrayList.class));

Review Comment:
   *NULL_DEREFERENCE:*  object returned by `getLabels(process)` could be null and is dereferenced at line 208.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)



##########
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/ProcessServiceLabelQuery.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.storage.plugin.influxdb.query;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.manual.process.ProcessServiceLabelRecord;
+import org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IProcessServiceLabelDAO;
+import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxClient;
+import org.influxdb.dto.QueryResult;
+import org.influxdb.querybuilder.SelectQueryImpl;
+import org.influxdb.querybuilder.WhereQueryImpl;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
+
+@Slf4j
+@RequiredArgsConstructor
+public class ProcessServiceLabelQuery implements IProcessServiceLabelDAO {
+    private final InfluxClient client;
+
+    @Override
+    public List<String> queryAllLabels(String serviceId) throws IOException {
+        final WhereQueryImpl<SelectQueryImpl> query = select(
+                ProcessServiceLabelRecord.LABEL
+        )
+                .from(client.getDatabase(), ProcessServiceLabelRecord.INDEX_NAME)
+                .where();
+
+        query.and(eq(ProcessServiceLabelRecord.SERVICE_ID, serviceId));
+
+        return parseLabels(query);
+    }
+
+    private List<String> parseLabels(WhereQueryImpl<SelectQueryImpl> query) throws IOException {
+        final QueryResult.Series series = client.queryForSingleSeries(query);
+        if (log.isDebugEnabled()) {
+            log.debug("SQL: {}, result: {}", query.getCommand(), series);
+        }
+
+        if (Objects.isNull(series)) {
+            return Collections.emptyList();
+        }
+
+        return series.getValues().stream().map(v -> (String) v.get(1)).collect(Collectors.toList());

Review Comment:
   *NULL_DEREFERENCE:*  object `series` last assigned on line 57 could be null and is dereferenced at line 66.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)



##########
oap-server/server-storage-plugin/storage-iotdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/iotdb/query/IoTDBMetadataQueryDAO.java:
##########
@@ -267,6 +284,11 @@ public Process getProcess(String processId) throws IOException {
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelsJson = processTraffic.getLabelsJson();
+            if (StringUtil.isNotEmpty(labelsJson)) {
+                final List<String> labels = GSON.<List<String>>fromJson(labelsJson, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   *NULL_DEREFERENCE:*  object returned by `getLabels(process)` could be null and is dereferenced at line 290.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)



##########
oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java:
##########
@@ -316,6 +339,11 @@ public Process getProcess(String processId) throws IOException {
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelJsonString = resultSet.getString(ProcessTraffic.LABELS_JSON);
+            if (!Strings.isNullOrEmpty(labelJsonString)) {
+                List<String> labels = GSON.<List<String>>fromJson(labelJsonString, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   *NULL_DEREFERENCE:*  object returned by `getLabels(process)` could be null and is dereferenced at line 345.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846572712


##########
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/ProcessServiceLabelQuery.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.storage.plugin.influxdb.query;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.manual.process.ProcessServiceLabelRecord;
+import org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IProcessServiceLabelDAO;
+import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxClient;
+import org.influxdb.dto.QueryResult;
+import org.influxdb.querybuilder.SelectQueryImpl;
+import org.influxdb.querybuilder.WhereQueryImpl;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
+
+@Slf4j
+@RequiredArgsConstructor
+public class ProcessServiceLabelQuery implements IProcessServiceLabelDAO {
+    private final InfluxClient client;
+
+    @Override
+    public List<String> queryAllLabels(String serviceId) throws IOException {
+        final WhereQueryImpl<SelectQueryImpl> query = select(
+                ProcessServiceLabelRecord.LABEL
+        )
+                .from(client.getDatabase(), ProcessServiceLabelRecord.INDEX_NAME)
+                .where();
+
+        query.and(eq(ProcessServiceLabelRecord.SERVICE_ID, serviceId));
+
+        return parseLabels(query);
+    }
+
+    private List<String> parseLabels(WhereQueryImpl<SelectQueryImpl> query) throws IOException {
+        final QueryResult.Series series = client.queryForSingleSeries(query);
+        if (log.isDebugEnabled()) {
+            log.debug("SQL: {}, result: {}", query.getCommand(), series);
+        }
+
+        if (Objects.isNull(series)) {
+            return Collections.emptyList();
+        }
+
+        return series.getValues().stream().map(v -> (String) v.get(1)).collect(Collectors.toList());

Review Comment:
   ignore



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846752510


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ProcessServiceLabel.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.source;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+import org.apache.skywalking.oap.server.core.analysis.IDManager;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROCESS_SERVICE_LABEL;
+
+@ScopeDeclaration(id = PROCESS_SERVICE_LABEL, name = "ProcessServiceLabel")
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
+public class ProcessServiceLabel extends Source {

Review Comment:
   > Where is the label data's timestamp? I think label should have TTL too, right?
   
   Yes, the `timeBucket` is already in the `Source`, so I just use this field. 



-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846742699


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ProcessServiceLabel.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.source;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+import org.apache.skywalking.oap.server.core.analysis.IDManager;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROCESS_SERVICE_LABEL;
+
+@ScopeDeclaration(id = PROCESS_SERVICE_LABEL, name = "ProcessServiceLabel")
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
+public class ProcessServiceLabel extends Source {
+    private volatile String entityId;
+
+    @Override
+    public int scope() {
+        return PROCESS_SERVICE_LABEL;
+    }
+
+    @Override
+    public String getEntityId() {
+        if (entityId == null) {
+            entityId = serviceId + Const.ID_CONNECTOR + new String(Base64.getEncoder()
+                    .encode(label.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8);
+        }
+        return entityId;
+    }
+
+    @Getter
+    private String serviceId;
+    @Setter
+    @Getter
+    private boolean isServiceNormal;
+    @Setter
+    @Getter
+    private String serviceName;
+    @Setter
+    @Getter
+    private String label;

Review Comment:
   queryAllLabels makes me feel, one label per row?



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846572811


##########
oap-server/server-storage-plugin/storage-iotdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/iotdb/query/IoTDBMetadataQueryDAO.java:
##########
@@ -267,6 +284,11 @@ public Process getProcess(String processId) throws IOException {
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelsJson = processTraffic.getLabelsJson();
+            if (StringUtil.isNotEmpty(labelsJson)) {
+                final List<String> labels = GSON.<List<String>>fromJson(labelsJson, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   ignore



##########
oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java:
##########
@@ -316,6 +339,11 @@ public Process getProcess(String processId) throws IOException {
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelJsonString = resultSet.getString(ProcessTraffic.LABELS_JSON);
+            if (!Strings.isNullOrEmpty(labelJsonString)) {
+                List<String> labels = GSON.<List<String>>fromJson(labelJsonString, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   ignore



-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846572713


##########
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/ProcessServiceLabelQuery.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.storage.plugin.influxdb.query;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.manual.process.ProcessServiceLabelRecord;
+import org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IProcessServiceLabelDAO;
+import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxClient;
+import org.influxdb.dto.QueryResult;
+import org.influxdb.querybuilder.SelectQueryImpl;
+import org.influxdb.querybuilder.WhereQueryImpl;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
+
+@Slf4j
+@RequiredArgsConstructor
+public class ProcessServiceLabelQuery implements IProcessServiceLabelDAO {
+    private final InfluxClient client;
+
+    @Override
+    public List<String> queryAllLabels(String serviceId) throws IOException {
+        final WhereQueryImpl<SelectQueryImpl> query = select(
+                ProcessServiceLabelRecord.LABEL
+        )
+                .from(client.getDatabase(), ProcessServiceLabelRecord.INDEX_NAME)
+                .where();
+
+        query.and(eq(ProcessServiceLabelRecord.SERVICE_ID, serviceId));
+
+        return parseLabels(query);
+    }
+
+    private List<String> parseLabels(WhereQueryImpl<SelectQueryImpl> query) throws IOException {
+        final QueryResult.Series series = client.queryForSingleSeries(query);
+        if (log.isDebugEnabled()) {
+            log.debug("SQL: {}, result: {}", query.getCommand(), series);
+        }
+
+        if (Objects.isNull(series)) {
+            return Collections.emptyList();
+        }
+
+        return series.getValues().stream().map(v -> (String) v.get(1)).collect(Collectors.toList());

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849009623


##########
oap-server/server-receiver-plugin/skywalking-ebpf-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/ebpf/provider/handler/EBPFProfilingServiceHandler.java:
##########
@@ -100,6 +102,35 @@ public void queryTasks(EBPFProfilingTaskQuery request, StreamObserver<Commands>
         responseObserver.onCompleted();
     }
 
+    private List<EBPFProfilingTaskCommand> buildProfilingCommands(EBPFProfilingTask task, List<Process> processes) {
+        final ArrayList<EBPFProfilingTaskCommand> commands = new ArrayList<>(processes.size());
+        for (Process process : processes) {
+            // The service id must matches between process and task
+            if (!Objects.equals(process.getServiceId(), task.getServiceId())) {
+                continue;
+            }
+
+            // If the task haven't labeled requirement, them just add the process
+            boolean shouldAdd = false;
+            if (CollectionUtils.isEmpty(task.getProcessLabels())) {
+                shouldAdd = true;
+            } else {
+                // If the process have matched one of the task label, them need to add the command

Review Comment:
   Updated. Add the `etimateProcessScale` for it. Update the GraphQL and E2E for testing it.



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849648495


##########
oap-server/server-storage-plugin/storage-iotdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/iotdb/query/IoTDBMetadataQueryDAO.java:
##########
@@ -267,6 +301,11 @@ private List<Process> buildProcesses(List<? super StorageData> storageDataList)
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelsJson = processTraffic.getLabelsJson();
+            if (StringUtil.isNotEmpty(labelsJson)) {
+                final List<String> labels = GSON.<List<String>>fromJson(labelsJson, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   ignore



##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/EBPFProfilingQueryService.java:
##########
@@ -169,6 +217,9 @@ private Process convertProcess(ProcessTraffic traffic) {
                 process.getAttributes().add(new Attribute(key, traffic.getProperties().get(key).getAsString()));
             }
         }
+        if (StringUtil.isNotEmpty(traffic.getLabelsJson())) {
+            process.getLabels().addAll(GSON.<List<String>>fromJson(traffic.getLabelsJson(), ArrayList.class));

Review Comment:
   ignore



-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849648534


##########
oap-server/server-storage-plugin/storage-iotdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/iotdb/query/IoTDBMetadataQueryDAO.java:
##########
@@ -267,6 +301,11 @@ private List<Process> buildProcesses(List<? super StorageData> storageDataList)
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelsJson = processTraffic.getLabelsJson();
+            if (StringUtil.isNotEmpty(labelsJson)) {
+                final List<String> labels = GSON.<List<String>>fromJson(labelsJson, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/EBPFProfilingQueryService.java:
##########
@@ -169,6 +217,9 @@ private Process convertProcess(ProcessTraffic traffic) {
                 process.getAttributes().add(new Attribute(key, traffic.getProperties().get(key).getAsString()));
             }
         }
+        if (StringUtil.isNotEmpty(traffic.getLabelsJson())) {
+            process.getLabels().addAll(GSON.<List<String>>fromJson(traffic.getLabelsJson(), ArrayList.class));

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849008633


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/process/ServiceLabelRecord.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.manual.process;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+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.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;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SERVICE_LABEL;
+
+/**
+ * Process have multiple labels, such as tag.
+ * {@link ServiceLabelRecord} could combine them in the service level.
+ * It could help to quickly locate the similar process by the service and label.
+ */
+@Setter
+@Getter
+@Stream(name = ServiceLabelRecord.INDEX_NAME, scopeId = SERVICE_LABEL,
+        builder = ServiceLabelRecord.Builder.class, processor = MetricsStreamProcessor.class)
+@MetricsExtension(supportDownSampling = false, supportUpdate = false)
+@EqualsAndHashCode(of = {
+        "serviceId",
+        "label"
+})
+public class ServiceLabelRecord extends Metrics {
+
+    public static final String INDEX_NAME = "service_label";
+    public static final String SERVICE_ID = "service_id";
+    public static final String LABEL = "label";
+
+    @Column(columnName = SERVICE_ID)
+    private String serviceId;
+    @Column(columnName = LABEL, length = 50)
+    private String label;
+
+    @Override
+    public boolean combine(Metrics metrics) {
+        return true;
+    }
+
+    @Override
+    public void calculate() {
+    }
+
+    @Override
+    public Metrics toHour() {
+        return null;
+    }
+
+    @Override
+    public Metrics toDay() {
+        return null;
+    }
+
+    @Override
+    protected String id0() {
+        return this.serviceId + Const.ID_CONNECTOR + new String(Base64.getEncoder()
+                .encode(label.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8);
+    }
+
+    @Override
+    public void deserialize(RemoteData remoteData) {
+        setServiceId(remoteData.getDataStrings(0));
+        setLabel(remoteData.getDataStrings(1));
+        setTimeBucket(remoteData.getDataLongs(0));
+    }
+
+    @Override
+    public RemoteData.Builder serialize() {
+        final RemoteData.Builder builder = RemoteData.newBuilder();
+        builder.addDataStrings(serviceId);
+        builder.addDataStrings(label);
+        builder.addDataLongs(getTimeBucket());
+        return builder;
+    }
+
+    @Override
+    public int remoteHashCode() {
+        return this.hashCode();
+    }
+
+    public static class Builder implements StorageBuilder<ServiceLabelRecord> {
+
+        @Override
+        public ServiceLabelRecord storage2Entity(Convert2Entity converter) {
+            final ServiceLabelRecord record = new ServiceLabelRecord();
+            record.setServiceId((String) converter.get(SERVICE_ID));
+            record.setLabel((String) converter.get(LABEL));
+            return record;
+        }
+
+        @Override
+        public void entity2Storage(ServiceLabelRecord entity, Convert2Storage converter) {
+            converter.accept(SERVICE_ID, entity.getServiceId());
+            converter.accept(LABEL, entity.getLabel());

Review Comment:
   Add the `time_bucket` to the column.



-- 
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


[GitHub] [skywalking] wu-sheng commented on pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#issuecomment-1098053349

   Hold a little, I and @mrproliu had a discussion, and query protocol needs some polish first.


-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849647963


##########
oap-server/server-storage-plugin/storage-iotdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/iotdb/query/IoTDBMetadataQueryDAO.java:
##########
@@ -267,6 +301,11 @@ private List<Process> buildProcesses(List<? super StorageData> storageDataList)
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelsJson = processTraffic.getLabelsJson();
+            if (StringUtil.isNotEmpty(labelsJson)) {
+                final List<String> labels = GSON.<List<String>>fromJson(labelsJson, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



##########
oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java:
##########
@@ -316,6 +357,11 @@ private List<Process> buildProcesses(ResultSet resultSet) throws SQLException {
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelJsonString = resultSet.getString(ProcessTraffic.LABELS_JSON);
+            if (!Strings.isNullOrEmpty(labelJsonString)) {
+                List<String> labels = GSON.<List<String>>fromJson(labelJsonString, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



##########
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/ServiceLabelQuery.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.storage.plugin.influxdb.query;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.manual.process.ServiceLabelRecord;
+import org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IServiceLabelDAO;
+import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxClient;
+import org.influxdb.dto.QueryResult;
+import org.influxdb.querybuilder.SelectQueryImpl;
+import org.influxdb.querybuilder.WhereQueryImpl;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
+
+@Slf4j
+@RequiredArgsConstructor
+public class ServiceLabelQuery implements IServiceLabelDAO {
+    private final InfluxClient client;
+
+    @Override
+    public List<String> queryAllLabels(String serviceId) throws IOException {
+        final WhereQueryImpl<SelectQueryImpl> query = select(
+                ServiceLabelRecord.LABEL
+        )
+                .from(client.getDatabase(), ServiceLabelRecord.INDEX_NAME)
+                .where();
+
+        query.and(eq(ServiceLabelRecord.SERVICE_ID, serviceId));
+
+        return parseLabels(query);
+    }
+
+    private List<String> parseLabels(WhereQueryImpl<SelectQueryImpl> query) throws IOException {
+        final QueryResult.Series series = client.queryForSingleSeries(query);
+        if (log.isDebugEnabled()) {
+            log.debug("SQL: {}, result: {}", query.getCommand(), series);
+        }
+
+        if (Objects.isNull(series)) {
+            return Collections.emptyList();
+        }
+
+        return series.getValues().stream().map(v -> (String) v.get(1)).collect(Collectors.toList());

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846572665


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/EBPFProfilingQueryService.java:
##########
@@ -169,6 +204,9 @@ private Process convertProcess(ProcessTraffic traffic) {
                 process.getAttributes().add(new Attribute(key, traffic.getProperties().get(key).getAsString()));
             }
         }
+        if (StringUtil.isNotEmpty(traffic.getLabelsJson())) {
+            process.getLabels().addAll(GSON.<List<String>>fromJson(traffic.getLabelsJson(), ArrayList.class));

Review Comment:
   ignore



-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846866574


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/process/ServiceLabelRecord.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.manual.process;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+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.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;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SERVICE_LABEL;
+
+/**
+ * Process have multiple labels, such as tag.
+ * {@link ServiceLabelRecord} could combine them in the service level.
+ * It could help to quickly locate the similar process by the service and label.
+ */
+@Setter
+@Getter
+@Stream(name = ServiceLabelRecord.INDEX_NAME, scopeId = SERVICE_LABEL,
+        builder = ServiceLabelRecord.Builder.class, processor = MetricsStreamProcessor.class)
+@MetricsExtension(supportDownSampling = false, supportUpdate = false)
+@EqualsAndHashCode(of = {
+        "serviceId",
+        "label"
+})
+public class ServiceLabelRecord extends Metrics {
+
+    public static final String INDEX_NAME = "service_label";
+    public static final String SERVICE_ID = "service_id";
+    public static final String LABEL = "label";
+
+    @Column(columnName = SERVICE_ID)
+    private String serviceId;
+    @Column(columnName = LABEL, length = 50)
+    private String label;
+
+    @Override
+    public boolean combine(Metrics metrics) {
+        return true;
+    }
+
+    @Override
+    public void calculate() {
+    }
+
+    @Override
+    public Metrics toHour() {
+        return null;
+    }
+
+    @Override
+    public Metrics toDay() {
+        return null;
+    }
+
+    @Override
+    protected String id0() {
+        return this.serviceId + Const.ID_CONNECTOR + new String(Base64.getEncoder()
+                .encode(label.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8);
+    }
+
+    @Override
+    public void deserialize(RemoteData remoteData) {
+        setServiceId(remoteData.getDataStrings(0));
+        setLabel(remoteData.getDataStrings(1));
+        setTimeBucket(remoteData.getDataLongs(0));
+    }
+
+    @Override
+    public RemoteData.Builder serialize() {
+        final RemoteData.Builder builder = RemoteData.newBuilder();
+        builder.addDataStrings(serviceId);
+        builder.addDataStrings(label);
+        builder.addDataLongs(getTimeBucket());
+        return builder;
+    }
+
+    @Override
+    public int remoteHashCode() {
+        return this.hashCode();
+    }
+
+    public static class Builder implements StorageBuilder<ServiceLabelRecord> {
+
+        @Override
+        public ServiceLabelRecord storage2Entity(Convert2Entity converter) {
+            final ServiceLabelRecord record = new ServiceLabelRecord();
+            record.setServiceId((String) converter.get(SERVICE_ID));
+            record.setLabel((String) converter.get(LABEL));
+            return record;
+        }
+
+        @Override
+        public void entity2Storage(ServiceLabelRecord entity, Convert2Storage converter) {
+            converter.accept(SERVICE_ID, entity.getServiceId());
+            converter.accept(LABEL, entity.getLabel());

Review Comment:
   No time bucket to the database, I assume this makes TTL fails. Was mentioned in https://github.com/apache/skywalking/pull/8840#discussion_r846746815



-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846868729


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/EBPFProfilingMutationService.java:
##########
@@ -113,18 +121,27 @@ private EBPFProfilingTaskCreationResult buildError(String msg) {
     }
 
     private String checkCreateRequest(EBPFProfilingTaskFixedTimeCreationRequest request) throws IOException {
-        String err = "";
+        String err = null;
 
-        // validate process finder
-        if (request.getProcessFinder() == null) {
-            return "The process finder could not be null";
-        }
-        if (request.getProcessFinder().getFinderType() == null) {
-            return "The process find type could not be null";
+        err = requiredNotEmpty(err, "service", request.getServiceId());
+
+        // the service must have processes
+        if (err == null && getMetadataQueryDAO().getProcessesCount(request.getServiceId(), null, null) <= 0) {
+            err = "current service haven't any process";
         }
-        switch (request.getProcessFinder().getFinderType()) {
-            case PROCESS_ID:
-                err = requiredNotEmpty(err, "process id", request.getProcessFinder().getProcessId());
+
+        // the process label must be existed
+        if (err == null && CollectionUtils.isNotEmpty(request.getProcessLabels())) {
+            final List<String> existingLabels = getServiceLabelDAO().queryAllLabels(request.getServiceId());
+            List<String> notExistLabels = new ArrayList<>(existingLabels.size());
+            for (String processLabel : request.getProcessLabels()) {
+                if (!existingLabels.contains(processLabel)) {
+                    notExistLabels.add(processLabel);
+                }
+            }
+            if (notExistLabels.size() > 0) {
+                err = String.format("The label %s are not exist", Joiner.on(", ").join(notExistLabels));

Review Comment:
   ```suggestion
                   err = String.format("The service doesn't have processes with label(s) %s.", Joiner.on(", ").join(notExistLabels));
   ```
   
   Trying to make the statement more clear.



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846752273


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/process/ProcessServiceLabelRecord.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.manual.process;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+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.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;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROCESS_SERVICE_LABEL;
+
+/**
+ * Process have multiple labels, such as tag.
+ * {@link ProcessServiceLabelRecord} could combine them in the service level.
+ * It could help to quickly locate the similar process by the service and label.
+ */
+@Setter
+@Getter
+@Stream(name = ProcessServiceLabelRecord.INDEX_NAME, scopeId = PROCESS_SERVICE_LABEL,
+        builder = ProcessServiceLabelRecord.Builder.class, processor = MetricsStreamProcessor.class)
+@MetricsExtension(supportDownSampling = false, supportUpdate = false)
+@EqualsAndHashCode(of = {
+        "serviceId",
+        "label"
+})
+public class ProcessServiceLabelRecord extends Metrics {
+
+    public static final String INDEX_NAME = "process_service_label";
+    public static final String SERVICE_ID = "service_id";
+    public static final String LABEL = "label";
+
+    @Column(columnName = SERVICE_ID)
+    private String serviceId;
+    @Column(columnName = LABEL)

Review Comment:
   Usually, the length of the label is not too long. I think `200` is enough. 



-- 
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


[GitHub] [skywalking] wu-sheng commented on pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#issuecomment-1094222112

   Could you update the new entity design and describe logic here? 


-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849660941


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/EBPFProfilingQueryService.java:
##########
@@ -169,6 +217,9 @@ private Process convertProcess(ProcessTraffic traffic) {
                 process.getAttributes().add(new Attribute(key, traffic.getProperties().get(key).getAsString()));
             }
         }
+        if (StringUtil.isNotEmpty(traffic.getLabelsJson())) {
+            process.getLabels().addAll(GSON.<List<String>>fromJson(traffic.getLabelsJson(), ArrayList.class));

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



##########
oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java:
##########
@@ -316,6 +357,11 @@ private List<Process> buildProcesses(ResultSet resultSet) throws SQLException {
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelJsonString = resultSet.getString(ProcessTraffic.LABELS_JSON);
+            if (!Strings.isNullOrEmpty(labelJsonString)) {
+                List<String> labels = GSON.<List<String>>fromJson(labelJsonString, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849023336


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/EBPFProfilingQueryService.java:
##########
@@ -169,6 +209,9 @@ private Process convertProcess(ProcessTraffic traffic) {
                 process.getAttributes().add(new Attribute(key, traffic.getProperties().get(key).getAsString()));
             }
         }
+        if (StringUtil.isNotEmpty(traffic.getLabelsJson())) {
+            process.getLabels().addAll(GSON.<List<String>>fromJson(traffic.getLabelsJson(), ArrayList.class));

Review Comment:
   *NULL_DEREFERENCE:*  object returned by `getLabels(process)` could be null and is dereferenced at line 213.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)
   
   ---
   
   Was this a good recommendation?
   [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=191270919&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=191270919&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191270919&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191270919&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=191270919&lift_comment_rating=5) ]



##########
oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java:
##########
@@ -316,6 +355,11 @@ private List<Process> buildProcesses(ResultSet resultSet) throws SQLException {
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelJsonString = resultSet.getString(ProcessTraffic.LABELS_JSON);
+            if (!Strings.isNullOrEmpty(labelJsonString)) {
+                List<String> labels = GSON.<List<String>>fromJson(labelJsonString, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   *NULL_DEREFERENCE:*  object returned by `getLabels(process)` could be null and is dereferenced at line 361.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)
   
   ---
   
   Was this a good recommendation?
   [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=191270796&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=191270796&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191270796&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191270796&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=191270796&lift_comment_rating=5) ]



##########
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/ServiceLabelQuery.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.storage.plugin.influxdb.query;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.manual.process.ServiceLabelRecord;
+import org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IServiceLabelDAO;
+import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxClient;
+import org.influxdb.dto.QueryResult;
+import org.influxdb.querybuilder.SelectQueryImpl;
+import org.influxdb.querybuilder.WhereQueryImpl;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
+
+@Slf4j
+@RequiredArgsConstructor
+public class ServiceLabelQuery implements IServiceLabelDAO {
+    private final InfluxClient client;
+
+    @Override
+    public List<String> queryAllLabels(String serviceId) throws IOException {
+        final WhereQueryImpl<SelectQueryImpl> query = select(
+                ServiceLabelRecord.LABEL
+        )
+                .from(client.getDatabase(), ServiceLabelRecord.INDEX_NAME)
+                .where();
+
+        query.and(eq(ServiceLabelRecord.SERVICE_ID, serviceId));
+
+        return parseLabels(query);
+    }
+
+    private List<String> parseLabels(WhereQueryImpl<SelectQueryImpl> query) throws IOException {
+        final QueryResult.Series series = client.queryForSingleSeries(query);
+        if (log.isDebugEnabled()) {
+            log.debug("SQL: {}, result: {}", query.getCommand(), series);
+        }
+
+        if (Objects.isNull(series)) {
+            return Collections.emptyList();
+        }
+
+        return series.getValues().stream().map(v -> (String) v.get(1)).collect(Collectors.toList());

Review Comment:
   *NULL_DEREFERENCE:*  object `series` last assigned on line 57 could be null and is dereferenced at line 66.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)
   
   ---
   
   Was this a good recommendation?
   [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=191270835&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=191270835&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191270835&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191270835&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=191270835&lift_comment_rating=5) ]



##########
oap-server/server-storage-plugin/storage-iotdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/iotdb/query/IoTDBMetadataQueryDAO.java:
##########
@@ -267,6 +298,11 @@ private List<Process> buildProcesses(List<? super StorageData> storageDataList)
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelsJson = processTraffic.getLabelsJson();
+            if (StringUtil.isNotEmpty(labelsJson)) {
+                final List<String> labels = GSON.<List<String>>fromJson(labelsJson, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   *NULL_DEREFERENCE:*  object returned by `getLabels(process)` could be null and is dereferenced at line 304.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)
   
   ---
   
   Was this a good recommendation?
   [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=191270917&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=191270917&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191270917&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191270917&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=191270917&lift_comment_rating=5) ]



-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849628625


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/event/Event.java:
##########
@@ -47,6 +48,8 @@ public class Event {
 
     private long endTime;
 
+    private String layer = Layer.UNDEFINED.name();

Review Comment:
   FYI @fgksgf @kezhenxu94 This is for temp only. Remove this when you are ready.



-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849656772


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/EBPFProfilingQueryService.java:
##########
@@ -169,6 +217,9 @@ private Process convertProcess(ProcessTraffic traffic) {
                 process.getAttributes().add(new Attribute(key, traffic.getProperties().get(key).getAsString()));
             }
         }
+        if (StringUtil.isNotEmpty(traffic.getLabelsJson())) {
+            process.getLabels().addAll(GSON.<List<String>>fromJson(traffic.getLabelsJson(), ArrayList.class));

Review Comment:
   *NULL_DEREFERENCE:*  object returned by `getLabels(process)` could be null and is dereferenced at line 221.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)
   
   ---
   
   Was this a good recommendation?
   [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=191631282&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=191631282&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191631282&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191631282&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=191631282&lift_comment_rating=5) ]



##########
oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java:
##########
@@ -316,6 +357,11 @@ private List<Process> buildProcesses(ResultSet resultSet) throws SQLException {
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelJsonString = resultSet.getString(ProcessTraffic.LABELS_JSON);
+            if (!Strings.isNullOrEmpty(labelJsonString)) {
+                List<String> labels = GSON.<List<String>>fromJson(labelJsonString, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   *NULL_DEREFERENCE:*  object returned by `getLabels(process)` could be null and is dereferenced at line 363.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)
   
   ---
   
   Was this a good recommendation?
   [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=191631328&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=191631328&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191631328&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191631328&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=191631328&lift_comment_rating=5) ]



##########
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/ServiceLabelQuery.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.storage.plugin.influxdb.query;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.manual.process.ServiceLabelRecord;
+import org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IServiceLabelDAO;
+import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxClient;
+import org.influxdb.dto.QueryResult;
+import org.influxdb.querybuilder.SelectQueryImpl;
+import org.influxdb.querybuilder.WhereQueryImpl;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
+
+@Slf4j
+@RequiredArgsConstructor
+public class ServiceLabelQuery implements IServiceLabelDAO {
+    private final InfluxClient client;
+
+    @Override
+    public List<String> queryAllLabels(String serviceId) throws IOException {
+        final WhereQueryImpl<SelectQueryImpl> query = select(
+                ServiceLabelRecord.LABEL
+        )
+                .from(client.getDatabase(), ServiceLabelRecord.INDEX_NAME)
+                .where();
+
+        query.and(eq(ServiceLabelRecord.SERVICE_ID, serviceId));
+
+        return parseLabels(query);
+    }
+
+    private List<String> parseLabels(WhereQueryImpl<SelectQueryImpl> query) throws IOException {
+        final QueryResult.Series series = client.queryForSingleSeries(query);
+        if (log.isDebugEnabled()) {
+            log.debug("SQL: {}, result: {}", query.getCommand(), series);
+        }
+
+        if (Objects.isNull(series)) {
+            return Collections.emptyList();
+        }
+
+        return series.getValues().stream().map(v -> (String) v.get(1)).collect(Collectors.toList());

Review Comment:
   *NULL_DEREFERENCE:*  object `series` last assigned on line 57 could be null and is dereferenced at line 66.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)
   
   ---
   
   Was this a good recommendation?
   [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=191631267&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=191631267&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191631267&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191631267&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=191631267&lift_comment_rating=5) ]



##########
oap-server/server-storage-plugin/storage-iotdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/iotdb/query/IoTDBMetadataQueryDAO.java:
##########
@@ -267,6 +301,11 @@ private List<Process> buildProcesses(List<? super StorageData> storageDataList)
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelsJson = processTraffic.getLabelsJson();
+            if (StringUtil.isNotEmpty(labelsJson)) {
+                final List<String> labels = GSON.<List<String>>fromJson(labelsJson, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   *NULL_DEREFERENCE:*  object returned by `getLabels(process)` could be null and is dereferenced at line 307.
   
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)
   
   ---
   
   Was this a good recommendation?
   [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=191631266&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=191631266&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191631266&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=191631266&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=191631266&lift_comment_rating=5) ]



-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846869088


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/storage/EBPFProfilingTaskRecord.java:
##########
@@ -41,30 +40,20 @@
 @Stream(name = EBPFProfilingTaskRecord.INDEX_NAME, scopeId = EBPF_PROFILING_TASK,
         builder = EBPFProfilingTaskRecord.Builder.class, processor = NoneStreamProcessor.class)
 public class EBPFProfilingTaskRecord extends NoneStream {
-
     public static final String INDEX_NAME = "ebpf_profiling_task";
-    public static final String PROCESS_FIND_TYPE = "process_find_type";
     public static final String SERVICE_ID = "service_id";
-    public static final String INSTANCE_ID = "instance_id";
-    public static final String PROCESS_ID = "process_id";
-    public static final String PROCESS_NAME = "process_name";
+    public static final String PROCESS_LABELS_JSON = "process_labels_json";
     public static final String START_TIME = "start_time";
     public static final String TRIGGER_TYPE = "trigger_type";
     public static final String FIXED_TRIGGER_DURATION = "fixed_trigger_duration";
     public static final String TARGET_TYPE = "target_type";
     public static final String CREATE_TIME = "create_time";
     public static final String LAST_UPDATE_TIME = "last_update_time";
 
-    @Column(columnName = PROCESS_FIND_TYPE)
-    private int processFindType = EBPFProfilingProcessFinderType.UNKNOWN.value();
     @Column(columnName = SERVICE_ID)
     private String serviceId;
-    @Column(columnName = INSTANCE_ID, length = 600)
-    private String instanceId;
-    @Column(columnName = PROCESS_ID, length = 600)
-    private String processId;
-    @Column(columnName = PROCESS_NAME, length = 500)
-    private String processName;
+    @Column(columnName = PROCESS_LABELS_JSON, length = 1000)

Review Comment:
   Please set up checks for UI



-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846572815


##########
oap-server/server-storage-plugin/storage-iotdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/iotdb/query/IoTDBMetadataQueryDAO.java:
##########
@@ -267,6 +284,11 @@ public Process getProcess(String processId) throws IOException {
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelsJson = processTraffic.getLabelsJson();
+            if (StringUtil.isNotEmpty(labelsJson)) {
+                final List<String> labels = GSON.<List<String>>fromJson(labelsJson, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



##########
oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java:
##########
@@ -316,6 +339,11 @@ public Process getProcess(String processId) throws IOException {
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelJsonString = resultSet.getString(ProcessTraffic.LABELS_JSON);
+            if (!Strings.isNullOrEmpty(labelJsonString)) {
+                List<String> labels = GSON.<List<String>>fromJson(labelJsonString, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846572670


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/EBPFProfilingQueryService.java:
##########
@@ -169,6 +204,9 @@ private Process convertProcess(ProcessTraffic traffic) {
                 process.getAttributes().add(new Attribute(key, traffic.getProperties().get(key).getAsString()));
             }
         }
+        if (StringUtil.isNotEmpty(traffic.getLabelsJson())) {
+            process.getLabels().addAll(GSON.<List<String>>fromJson(traffic.getLabelsJson(), ArrayList.class));

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



-- 
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


[GitHub] [skywalking] sonatype-lift[bot] commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846778151


##########
oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/ServiceLabelQuery.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.storage.plugin.influxdb.query;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.manual.process.ServiceLabelRecord;
+import org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IServiceLabelDAO;
+import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxClient;
+import org.influxdb.dto.QueryResult;
+import org.influxdb.querybuilder.SelectQueryImpl;
+import org.influxdb.querybuilder.WhereQueryImpl;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
+import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
+
+@Slf4j
+@RequiredArgsConstructor
+public class ServiceLabelQuery implements IServiceLabelDAO {
+    private final InfluxClient client;
+
+    @Override
+    public List<String> queryAllLabels(String serviceId) throws IOException {
+        final WhereQueryImpl<SelectQueryImpl> query = select(
+                ServiceLabelRecord.LABEL
+        )
+                .from(client.getDatabase(), ServiceLabelRecord.INDEX_NAME)
+                .where();
+
+        query.and(eq(ServiceLabelRecord.SERVICE_ID, serviceId));
+
+        return parseLabels(query);
+    }
+
+    private List<String> parseLabels(WhereQueryImpl<SelectQueryImpl> query) throws IOException {
+        final QueryResult.Series series = client.queryForSingleSeries(query);
+        if (log.isDebugEnabled()) {
+            log.debug("SQL: {}, result: {}", query.getCommand(), series);
+        }
+
+        if (Objects.isNull(series)) {
+            return Collections.emptyList();
+        }
+
+        return series.getValues().stream().map(v -> (String) v.get(1)).collect(Collectors.toList());

Review Comment:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846745122


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/process/ProcessServiceLabelRecord.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.manual.process;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+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.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;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROCESS_SERVICE_LABEL;
+
+/**
+ * Process have multiple labels, such as tag.
+ * {@link ProcessServiceLabelRecord} could combine them in the service level.
+ * It could help to quickly locate the similar process by the service and label.
+ */
+@Setter
+@Getter
+@Stream(name = ProcessServiceLabelRecord.INDEX_NAME, scopeId = PROCESS_SERVICE_LABEL,
+        builder = ProcessServiceLabelRecord.Builder.class, processor = MetricsStreamProcessor.class)
+@MetricsExtension(supportDownSampling = false, supportUpdate = false)
+@EqualsAndHashCode(of = {
+        "serviceId",
+        "label"
+})
+public class ProcessServiceLabelRecord extends Metrics {
+
+    public static final String INDEX_NAME = "process_service_label";
+    public static final String SERVICE_ID = "service_id";
+    public static final String LABEL = "label";
+
+    @Column(columnName = SERVICE_ID)
+    private String serviceId;
+    @Column(columnName = LABEL)
+    private String label;

Review Comment:
   It is fine with multiple rows, I just want you to be clear about this in the PR. Make sure my further reviews follow your design.



-- 
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


[GitHub] [skywalking] wu-sheng commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r846746905


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ProcessServiceLabel.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.source;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+import org.apache.skywalking.oap.server.core.analysis.IDManager;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROCESS_SERVICE_LABEL;
+
+@ScopeDeclaration(id = PROCESS_SERVICE_LABEL, name = "ProcessServiceLabel")
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
+public class ProcessServiceLabel extends Source {

Review Comment:
   Also, I think ServiceLabels is a better name? ProcessServiceLabel makes me feeling strange whether this is a service or process's label.



##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ProcessServiceLabel.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.source;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.Const;
+import org.apache.skywalking.oap.server.core.analysis.IDManager;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROCESS_SERVICE_LABEL;
+
+@ScopeDeclaration(id = PROCESS_SERVICE_LABEL, name = "ProcessServiceLabel")
+@ScopeDefaultColumn.VirtualColumnDefinition(fieldName = "entityId", columnName = "entity_id", isID = true, type = String.class)
+public class ProcessServiceLabel extends Source {

Review Comment:
   Where is the label data's timestamp? I think label should have TTL too, 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


[GitHub] [skywalking] wu-sheng merged pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
wu-sheng merged PR #8840:
URL: https://github.com/apache/skywalking/pull/8840


-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849035387


##########
oap-server/server-storage-plugin/storage-iotdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/iotdb/query/IoTDBMetadataQueryDAO.java:
##########
@@ -267,6 +298,11 @@ private List<Process> buildProcesses(List<? super StorageData> storageDataList)
                     process.getAttributes().add(new Attribute(key, value));
                 }
             }
+            final String labelsJson = processTraffic.getLabelsJson();
+            if (StringUtil.isNotEmpty(labelsJson)) {
+                final List<String> labels = GSON.<List<String>>fromJson(labelsJson, ArrayList.class);
+                process.getLabels().addAll(labels);

Review Comment:
   ignore



-- 
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


[GitHub] [skywalking] mrproliu commented on a diff in pull request #8840: Update the eBPF Profiling task as service level

Posted by GitBox <gi...@apache.org>.
mrproliu commented on code in PR #8840:
URL: https://github.com/apache/skywalking/pull/8840#discussion_r849035141


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/ebpf/EBPFProfilingQueryService.java:
##########
@@ -169,6 +209,9 @@ private Process convertProcess(ProcessTraffic traffic) {
                 process.getAttributes().add(new Attribute(key, traffic.getProperties().get(key).getAsString()));
             }
         }
+        if (StringUtil.isNotEmpty(traffic.getLabelsJson())) {
+            process.getLabels().addAll(GSON.<List<String>>fromJson(traffic.getLabelsJson(), ArrayList.class));

Review Comment:
   ignore



-- 
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