Skip to content

Commit 981ad8d

Browse files
anush-applepull[bot]
authored andcommitted
[Darwin] Disable metric collector debug logging (#33458)
- The debug logging in metrics collector is very noisy and debug is enabled by default. - Disabling the metrics debug logging since it is not really useful except for developer development mode debugging, which is recompile and test.
1 parent 4ca3c28 commit 981ad8d

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/darwin/Framework/CHIP/MTRMetricsCollector.mm

+13-7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
#include <tracing/metric_event.h>
2626
#include <tracing/registry.h>
2727

28+
/*
29+
* Set this to MTR_LOG_DEBUG(__VA_ARGS__) to enable logging noisy debug logging for metrics events processing
30+
*/
31+
#define MTR_METRICS_LOG_DEBUG(...)
32+
2833
using MetricEvent = chip::Tracing::MetricEvent;
2934

3035
@implementation MTRMetricData {
@@ -74,7 +79,8 @@ - (instancetype)initWithMetricEvent:(const MetricEvent &)event
7479
case ValueType::kUndefined:
7580
break;
7681
}
77-
MTR_LOG_DEBUG("Initializing metric event data %s, type: %d, with time point %llu", event.key(), _type, _timePoint.count());
82+
83+
MTR_METRICS_LOG_DEBUG("Initializing metric event data %s, type: %d, with time point %llu", event.key(), _type, _timePoint.count());
7884
return self;
7985
}
8086

@@ -83,7 +89,7 @@ - (void)setDurationFromMetricData:(MTRMetricData *)fromData
8389
auto duration = _timePoint - fromData->_timePoint;
8490
_duration = [NSNumber numberWithDouble:double(duration.count()) / USEC_PER_SEC];
8591

86-
MTR_LOG_DEBUG("Calculating duration for Matter metric with type %d, from type %d, (%llu - %llu) = %llu us (%llu s)",
92+
MTR_METRICS_LOG_DEBUG("Calculating duration for Matter metric with type %d, from type %d, (%llu - %llu) = %llu us (%llu s)",
8793
_type, fromData->_type, _timePoint.count(), fromData->_timePoint.count(), duration.count(), [_duration unsignedLongLongValue]);
8894
}
8995

@@ -201,19 +207,19 @@ - (void)handleMetricEvent:(MetricEvent)event
201207
using ValueType = MetricEvent::Value::Type;
202208
switch (event.ValueType()) {
203209
case ValueType::kInt32:
204-
MTR_LOG_DEBUG("Received metric event, key: %s, type: %d, value: %d", event.key(), static_cast<int>(event.type()), event.ValueInt32());
210+
MTR_METRICS_LOG_DEBUG("Received metric event, key: %s, type: %d, value: %d", event.key(), static_cast<int>(event.type()), event.ValueInt32());
205211
break;
206212
case ValueType::kUInt32:
207-
MTR_LOG_DEBUG("Received metric event, key: %s, type: %d, value: %u", event.key(), static_cast<int>(event.type()), event.ValueUInt32());
213+
MTR_METRICS_LOG_DEBUG("Received metric event, key: %s, type: %d, value: %u", event.key(), static_cast<int>(event.type()), event.ValueUInt32());
208214
break;
209215
case ValueType::kChipErrorCode:
210-
MTR_LOG_DEBUG("Received metric event, key: %s, type: %d, error value: %u", event.key(), static_cast<int>(event.type()), event.ValueErrorCode());
216+
MTR_METRICS_LOG_DEBUG("Received metric event, key: %s, type: %d, error value: %u", event.key(), static_cast<int>(event.type()), event.ValueErrorCode());
211217
break;
212218
case ValueType::kUndefined:
213-
MTR_LOG_DEBUG("Received metric event, key: %s, type: %d, value: nil", event.key(), static_cast<int>(event.type()));
219+
MTR_METRICS_LOG_DEBUG("Received metric event, key: %s, type: %d, value: nil", event.key(), static_cast<int>(event.type()));
214220
break;
215221
default:
216-
MTR_LOG_DEBUG("Received metric event, key: %s, type: %d, unknown value", event.key(), static_cast<int>(event.type()));
222+
MTR_METRICS_LOG_DEBUG("Received metric event, key: %s, type: %d, unknown value", event.key(), static_cast<int>(event.type()));
217223
return;
218224
}
219225

0 commit comments

Comments
 (0)