-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Showing
15 changed files
with
961 additions
and
10 deletions.
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
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,46 @@ | ||
# | ||
#Copyright (c) 2024 Project CHIP Authors | ||
# | ||
# Licensed 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. | ||
|
||
import("//build_overrides/build.gni") | ||
import("//build_overrides/chip.gni") | ||
|
||
config("tracing") { | ||
include_dirs = [ "include" ] | ||
} | ||
|
||
static_library("backend") { | ||
output_name = "libEsp32DiagnosticsBackend" | ||
output_dir = "${root_out_dir}/lib" | ||
|
||
sources = [ | ||
"Counter.cpp", | ||
"Counter.h", | ||
"DiagnosticStorageManager.h", | ||
"DiagnosticTracing.cpp", | ||
"DiagnosticTracing.h", | ||
"Diagnostics.h", | ||
] | ||
|
||
public_deps = [ | ||
"${chip_root}/src/lib/core", | ||
"${chip_root}/src/tracing", | ||
] | ||
} | ||
|
||
source_set("esp32_diagnostic_tracing") { | ||
public = [ "include/matter/tracing/macros_impl.h" ] | ||
public_configs = [ ":tracing" ] | ||
deps = [ ":backend" ] | ||
} |
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,55 @@ | ||
/* | ||
* | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed 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. | ||
*/ | ||
|
||
#include <string.h> | ||
#include <tracing/esp32_diagnostic_trace/Counter.h> | ||
|
||
namespace chip { | ||
namespace Tracing { | ||
namespace Diagnostics { | ||
|
||
std::map<const char *, uint32_t> ESPDiagnosticCounter::mCounterList; | ||
|
||
void ESPDiagnosticCounter::CountInit(const char * label) | ||
{ | ||
if (mCounterList.find(label) != mCounterList.end()) | ||
{ | ||
mCounterList[label]++; | ||
} | ||
else | ||
{ | ||
mCounterList[label] = 1; | ||
} | ||
} | ||
|
||
uint32_t ESPDiagnosticCounter::GetInstanceCount(const char * label) const | ||
{ | ||
return mCounterList[label]; | ||
} | ||
|
||
void ESPDiagnosticCounter::ReportMetrics(const char * label, DiagnosticStorageInterface & mStorageInstance) | ||
{ | ||
CHIP_ERROR err = CHIP_NO_ERROR; | ||
Counter counter(label, GetInstanceCount(label), esp_log_timestamp()); | ||
err = mStorageInstance.Store(counter); | ||
VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(DeviceLayer, "Failed to store Counter diagnostic data")); | ||
} | ||
|
||
} // namespace Diagnostics | ||
} // namespace Tracing | ||
} // namespace chip |
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,63 @@ | ||
/* | ||
* | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed 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 "tracing/esp32_diagnostic_trace/Diagnostics.h" | ||
#include <esp_diagnostics_metrics.h> | ||
#include <esp_log.h> | ||
#include <lib/support/CHIPMem.h> | ||
#include <lib/support/CHIPMemString.h> | ||
#include <map> | ||
#include <string.h> | ||
|
||
namespace chip { | ||
namespace Tracing { | ||
namespace Diagnostics { | ||
|
||
/** | ||
* This class is used to monotonically increment the counters as per the label of the counter macro | ||
* 'MATTER_TRACE_COUNTER(label)' | ||
* As per the label of the counter macro, it adds the counter in the linked list with the name label if not | ||
* present and returns the same instance and increments the value if the counter is already present | ||
* in the list. | ||
*/ | ||
|
||
class ESPDiagnosticCounter | ||
{ | ||
public: | ||
static ESPDiagnosticCounter & GetInstance(const char * label) | ||
{ | ||
static ESPDiagnosticCounter instance; | ||
CountInit(label); | ||
return instance; | ||
} | ||
|
||
uint32_t GetInstanceCount(const char * label) const; | ||
|
||
void ReportMetrics(const char * label, DiagnosticStorageInterface & mStorageInstance); | ||
|
||
private: | ||
ESPDiagnosticCounter() {} | ||
static std::map<const char *, uint32_t> mCounterList; | ||
static void CountInit(const char * label); | ||
}; | ||
|
||
} // namespace Diagnostics | ||
} // namespace Tracing | ||
} // namespace chip |
Oops, something went wrong.