martinzink commented on a change in pull request #1066:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1066#discussion_r630025298



##########
File path: extensions/pdh/PerformanceDataMonitor.h
##########
@@ -0,0 +1,102 @@
+/**
+ * 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.
+ */
+
+#pragma once
+
+#include <pdh.h>
+#include <string>
+#include <vector>
+#include <memory>
+#include <utility>
+
+#include "core/Processor.h"
+
+#include "rapidjson/stream.h"
+#include "rapidjson/writer.h"
+#include "rapidjson/prettywriter.h"
+
+#include "PerformanceDataCounter.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace processors {
+
+// PerformanceDataMonitor Class
+class PerformanceDataMonitor : public core::Processor {
+ public:
+  static constexpr char const* JSON_FORMAT_STR = "JSON";
+  static constexpr char const* OPEN_TELEMETRY_FORMAT_STR = "OpenTelemetry";
+
+  explicit PerformanceDataMonitor(const std::string& name, utils::Identifier 
uuid = utils::Identifier())
+      : Processor(name, uuid), output_format_(OutputFormat::kJSON),
+      logger_(logging::LoggerFactory<PerformanceDataMonitor>::getLogger()),
+      pdh_query_(nullptr), resource_consumption_counters_() {
+  }
+  ~PerformanceDataMonitor() override;
+  static constexpr char const* ProcessorName = "PerformanceDataMonitor";
+  // Supported Properties
+  static core::Property PredefinedGroups;
+  static core::Property CustomPDHCounters;
+  static core::Property OutputFormatProperty;
+  // Supported Relationships
+  static core::Relationship Success;
+  // Nest Callback Class for write stream
+  class WriteCallback : public OutputStreamCallback {
+   public:
+    explicit WriteCallback(rapidjson::Document&& root) : 
root_(std::move(root)) {
+    }
+    rapidjson::Document root_;
+    int64_t process(const std::shared_ptr<io::BaseStream>& stream) {
+      rapidjson::StringBuffer buffer;
+      rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buffer);
+      root_.Accept(writer);
+      return stream->write(reinterpret_cast<const 
uint8_t*>(buffer.GetString()), gsl::narrow<int>(buffer.GetSize()));
+    }
+  };
+
+ public:
+  void onSchedule(const std::shared_ptr<core::ProcessContext> &context, const 
std::shared_ptr<core::ProcessSessionFactory> &sessionFactory) override;
+  void onTrigger(core::ProcessContext *context, core::ProcessSession *session) 
override;
+  void initialize(void) override;
+
+ protected:
+  enum class OutputFormat {
+    kJSON, kOpenTelemetry

Review comment:
       Its in the the google styleguide (if Im not mistaken k is for constant 
and this kind of usage is from the Hungarian notation)
   https://google.github.io/styleguide/cppguide.html#Enumerator_Names
   
   However now I looked and I dont think the codebase has any consistent naming 
convention regarding enums.
   Somewhere it uses lowerCamelCase and somewhere it uses Upper_Snake_Case, and 
somewhere ALLCAPS.  (some thirdpart (rocksdb) uses the google guideline)
   
   Not sure which one should we follow.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to