chore(#550): instrument CoreScope path for joint E2E diagnosis

Info logs at each step (0xC6 reply match, hash, CoreScope GET url + result,
stored count, message-not-found) so the app debug log shows exactly where the
badge chain breaks. Part of #524.

Agent: QuietSnow (session 31eaba02)
pull/556/head
Strycher 2 months ago
parent 2919329265
commit da322d79d9

@ -4742,6 +4742,10 @@ class MeshCoreConnector extends ChangeNotifier {
}
final key = '${parsed.timestamp}_${parsed.channelIdx}';
final completer = _pendingPktHashCompleters[key];
appLogger.info(
'0xC6 reply hash=${parsed.hashHex} key=$key matched=${completer != null}',
tag: 'CoreScope',
);
if (completer != null && !completer.isCompleted) {
completer.complete(parsed);
}
@ -4756,8 +4760,15 @@ class MeshCoreConnector extends ChangeNotifier {
String messageId,
) async {
try {
appLogger.info(
'start ts=$ts chan=$channelIndex msg=$messageId',
tag: 'CoreScope',
);
final pkt = await _queryPacketHash(ts, channelIndex);
if (pkt == null) return;
if (pkt == null) {
appLogger.info('no hash (0xC6 null/timeout)', tag: 'CoreScope');
return;
}
_updateChannelMessageById(
channelIndex,
messageId,
@ -4770,6 +4781,7 @@ class MeshCoreConnector extends ChangeNotifier {
messageId,
(m) => m.copyWith(coreScopeObserverCount: count),
);
appLogger.info('stored observer count=$count', tag: 'CoreScope');
notifyListeners();
} catch (e) {
appLogger.warn(
@ -4787,7 +4799,14 @@ class MeshCoreConnector extends ChangeNotifier {
final messages = _channelMessages[channelIndex];
if (messages == null) return;
final i = messages.indexWhere((m) => m.messageId == messageId);
if (i >= 0) messages[i] = transform(messages[i]);
if (i >= 0) {
messages[i] = transform(messages[i]);
} else {
appLogger.warn(
'message $messageId not found on chan $channelIndex; count dropped',
tag: 'CoreScope',
);
}
}
/// Called when a BLOCK_LIST dump ends. A truncated dump (early-END) is

@ -39,6 +39,7 @@ class CoreScopeService {
'limit': '1',
},
);
appLogger.info('GET $uri', tag: 'CoreScope');
try {
final resp = await _client.get(uri).timeout(timeout);
if (resp.statusCode != 200) {
@ -51,11 +52,19 @@ class CoreScopeService {
final body = jsonDecode(resp.body);
if (body is! Map) return null;
final packets = body['packets'];
if (packets is! List || packets.isEmpty) return null;
if (packets is! List || packets.isEmpty) {
appLogger.info('no record yet for $packetHash', tag: 'CoreScope');
return null;
}
final first = packets.first;
if (first is! Map) return null;
final count = first['observer_count'];
return count is num ? count.toInt() : null;
final result = count is num ? count.toInt() : null;
appLogger.info(
'observer_count=$result for $packetHash',
tag: 'CoreScope',
);
return result;
} catch (e) {
appLogger.warn('Query failed for $packetHash: $e', tag: 'CoreScope');
return null;

Loading…
Cancel
Save

Powered by TurnKey Linux.