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



##########
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:
       I see, thanks for the info I did not know about this recommendation in 
the google guideline. Personally I'm not a fan of it, but if we do not have any 
specific guideline for this, I'm okay with it. My only argument against it 
would be that since we already have multiple styles for the enums in the 
codebase, it may not be a good idea to introduce one more.




-- 
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:
us...@infra.apache.org


Reply via email to