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 04:14:27 UTC

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

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