Skip to content

Commit

Permalink
Ensure that metrics are registered when the metricsPoll starts.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarkowsky committed Oct 18, 2021
1 parent 95926c2 commit 3f29a02
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Source/santad/SNTApplication.m
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,6 @@ - (instancetype)init {
if (!_execController) return nil;

if ([configurator exportMetrics]) {
SNTRegisterCoreMetrics();

_metricsConnection = [SNTXPCMetricServiceInterface configuredConnection];
[_metricsConnection resume];

[self startMetricsPoll];
}

Expand Down Expand Up @@ -312,7 +307,14 @@ dispatch_source_t CreateDispatchTimer(uint64_t interval,
*/
- (void)startMetricsPoll {
LOGI(@"starting to export metrics every 30s");

static dispatch_once_t registerMetrics;
dispatch_once(&registerMetrics, ^{
_metricsConnection = [SNTXPCMetricServiceInterface configuredConnection];
[_metricsConnection resume];

SNTRegisterCoreMetrics();
});

void (^exportMetricsBlock)(void) = ^{
[[_metricsConnection remoteObjectProxy] exportForMonitoring: [_metricSet export]];
};
Expand Down

0 comments on commit 3f29a02

Please sign in to comment.