Skip to content

Commit

Permalink
[Darwin] Disable metric collector debug logging (#33458)
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
anush-apple authored May 15, 2024
1 parent 8224308 commit 42c0aa5
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/darwin/Framework/CHIP/MTRMetricsCollector.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
#include <tracing/metric_event.h>
#include <tracing/registry.h>

/*
* Set this to MTR_LOG_DEBUG(__VA_ARGS__) to enable logging noisy debug logging for metrics events processing
*/
#define MTR_METRICS_LOG_DEBUG(...)

using MetricEvent = chip::Tracing::MetricEvent;

@implementation MTRMetricData {
Expand Down Expand Up @@ -74,7 +79,8 @@ - (instancetype)initWithMetricEvent:(const MetricEvent &)event
case ValueType::kUndefined:
break;
}
MTR_LOG_DEBUG("Initializing metric event data %s, type: %d, with time point %llu", event.key(), _type, _timePoint.count());

MTR_METRICS_LOG_DEBUG("Initializing metric event data %s, type: %d, with time point %llu", event.key(), _type, _timePoint.count());
return self;
}

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

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

Expand Down Expand Up @@ -201,19 +207,19 @@ - (void)handleMetricEvent:(MetricEvent)event
using ValueType = MetricEvent::Value::Type;
switch (event.ValueType()) {
case ValueType::kInt32:
MTR_LOG_DEBUG("Received metric event, key: %s, type: %d, value: %d", event.key(), static_cast<int>(event.type()), event.ValueInt32());
MTR_METRICS_LOG_DEBUG("Received metric event, key: %s, type: %d, value: %d", event.key(), static_cast<int>(event.type()), event.ValueInt32());
break;
case ValueType::kUInt32:
MTR_LOG_DEBUG("Received metric event, key: %s, type: %d, value: %u", event.key(), static_cast<int>(event.type()), event.ValueUInt32());
MTR_METRICS_LOG_DEBUG("Received metric event, key: %s, type: %d, value: %u", event.key(), static_cast<int>(event.type()), event.ValueUInt32());
break;
case ValueType::kChipErrorCode:
MTR_LOG_DEBUG("Received metric event, key: %s, type: %d, error value: %u", event.key(), static_cast<int>(event.type()), event.ValueErrorCode());
MTR_METRICS_LOG_DEBUG("Received metric event, key: %s, type: %d, error value: %u", event.key(), static_cast<int>(event.type()), event.ValueErrorCode());
break;
case ValueType::kUndefined:
MTR_LOG_DEBUG("Received metric event, key: %s, type: %d, value: nil", event.key(), static_cast<int>(event.type()));
MTR_METRICS_LOG_DEBUG("Received metric event, key: %s, type: %d, value: nil", event.key(), static_cast<int>(event.type()));
break;
default:
MTR_LOG_DEBUG("Received metric event, key: %s, type: %d, unknown value", event.key(), static_cast<int>(event.type()));
MTR_METRICS_LOG_DEBUG("Received metric event, key: %s, type: %d, unknown value", event.key(), static_cast<int>(event.type()));
return;
}

Expand Down

0 comments on commit 42c0aa5

Please sign in to comment.