forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e6f0134
commit ebd799c
Showing
16 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "counter.h" | ||
|
||
namespace Insights{ | ||
ESPInsightsCounter* ESPInsightsCounter::m_head = nullptr; | ||
|
||
ESPInsightsCounter* ESPInsightsCounter::GetInstance(const char* label, const char* group) { | ||
|
||
ESPInsightsCounter* current = m_head; | ||
ESPInsightsCounter* previous = nullptr; | ||
|
||
while (current != nullptr) { | ||
if (strcmp(current->label, label) == 0 && strcmp(current->group, group) == 0) { | ||
current->instanceCount++; | ||
return current; | ||
} | ||
previous = current; | ||
current = current->m_next; | ||
} | ||
|
||
ESPInsightsCounter* newInstance = new ESPInsightsCounter(label, group); | ||
newInstance->m_next = m_head; | ||
m_head = newInstance; | ||
return newInstance; | ||
} | ||
|
||
int ESPInsightsCounter::GetInstanceCount() const { | ||
return instanceCount; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <esp_diagnostics_metrics.h> | ||
#include <iostream> | ||
#include <lib/support/CHIPCounter.h> | ||
#include <string.h> | ||
|
||
#define PATH1 "sys.cnt" | ||
namespace Insights { | ||
class ESPInsightsCounter | ||
{ | ||
private: | ||
static ESPInsightsCounter * m_head; | ||
char label[50]; | ||
char group[50]; | ||
int instanceCount; | ||
ESPInsightsCounter * m_next; | ||
bool registered = false; | ||
|
||
ESPInsightsCounter(const char * labelParam, const char * groupParam) : instanceCount(1), m_next(nullptr) | ||
{ | ||
strncpy(label, labelParam, sizeof(label)); | ||
strncpy(group, groupParam, sizeof(group)); | ||
} | ||
|
||
public: | ||
static ESPInsightsCounter * GetInstance(const char * label, const char * group); | ||
|
||
int GetInstanceCount() const; | ||
|
||
void ReportMetrics() | ||
{ | ||
std::cout << "Trace instant: Label=" << label << ", Group=" << group << ", Instance Count=" << instanceCount << std::endl; | ||
if (!registered) | ||
{ | ||
esp_diag_metrics_register("SYS_CNT", label, label, PATH1, ESP_DIAG_DATA_TYPE_UINT); | ||
registered = true; | ||
} | ||
std::cout << "Label ------" << label << "Count---" << instanceCount; | ||
esp_diag_metrics_add_uint(label, instanceCount); | ||
} | ||
}; | ||
|
||
} // namespace Insights |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters