[llvm] [llvm]Add a simple Telemetry framework (PR #102323)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 17 01:40:39 PST 2024


================
@@ -112,71 +108,71 @@ To use Telemetry in your tool, you need to provide a concrete implementation of
       writeHelper(KeyName, Value);
     }
 
-    void write(StringRef KeyName, size_t Value) override {
+    void write(StringRef KeyName, unsigned long long Value) override {
       writeHelper(KeyName, Value);
     }
     void write(StringRef KeyName, StringRef Value) override {
       writeHelper(KeyName, Value);
     }
 
     void write(StringRef KeyName,
-               const std::map<std::string, std::string>& Value) override {
+               const std::map<std::string, std::string> &Value) override {
       json::Object Inner;
-      for (auto kv : Value) {
-        Inner.try_emplace(kv.first, kv.second);
+      for (auto KV : Value) {
+        Inner.try_emplace(KV.first, KV.second);
       }
       writeHelper(KeyName, json::Value(std::move(Inner)));
     }
 
     Error finalize() override {
-      if (!started)
+      if (!Started)
         return createStringError("Serializer not currently in use");
-      started = false;
+      Started = false;
       return Error::success();
     }
 
   private:
     template <typename T> void writeHelper(StringRef Name, T Value) {
       assert(started && "serializer not started");
-      object->try_emplace(Name, Value);
+      Out->try_emplace(Name, Value);
     }
-    bool started = false;
-    std::unique_ptr<json::Object> object;
+    bool Started = false;
+    std::unique_ptr<json::Object> Out;
   };
        
   class MyManager : public telemery::Manager {
   public:
-  static std::unique_ptr<MyManager> createInstatnce(telemetry::Config* config) {
+  static std::unique_ptr<MyManager> createInstatnce(telemetry::Config *config) {
     // If Telemetry is not enabled, then just return null;
     if (!config->EnableTelemetry) return nullptr;
 
     return std::make_unique<MyManager>();
   }
   MyManager() = default;
 
-  Error dispatch(TelemetryInfo* Entry) const override {
+  Error dispatch(TelemetryInfo *Entry) const override {
     Entry->SessionId = SessionId;
     emitToAllDestinations(Entry);
   }
       
-  void addDestination(std::unique_ptr<Destination> dest) override {
-    destinations.push_back(std::move(dest));
+  void addDestination(std::unique_ptr<Destination> Dest) override {
+    destinations.push_back(std::move(Dest));
   }
   
   // You can also define additional instrumentation points.
-  void logStartup(TelemetryInfo* Entry) {
+  void logStartup(TelemetryInfo *Entry) {
     // Add some additional data to entry.
     Entry->Msg = "Some message";
     dispatch(Entry);
   }
   
-  void logAdditionalPoint(TelemetryInfo* Entry) {
+  void logAdditionalPoint(TelemetryInfo  Entry) {
----------------
jh7370 wrote:

Think you made a mistake here?
```suggestion
  void logAdditionalPoint(TelemetryInfo *Entry) {
```

https://github.com/llvm/llvm-project/pull/102323


More information about the llvm-commits mailing list