-
Notifications
You must be signed in to change notification settings - Fork 4
Introduce debugs logs for ease the troubleshooting efforts #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| common:SystemStateSnapshot stateSnapshot = { | ||
| topics: getTopics(), | ||
| subscriptions: getSubscriptions() | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 1
| }; | |
| }; | |
| log:printInfo("State snapshot retrieved successfully", topicCount = stateSnapshot.topics.length(), subscriptionCount = stateSnapshot.subscriptions.length()); |
| kafka:BytesConsumerRecord[] records = check conn:websubEventConsumer->poll(config:kafka.consumer.pollingInterval); | ||
| log:printDebug("Polled Kafka records for state consolidation", recordCount = records.length(), pollingInterval = config:kafka.consumer.pollingInterval); | ||
|
|
||
| if records.length() > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 3
| if records.length() > 0 { | |
| if records.length() > 0 { | |
| log:printInfo("Processing batch of Kafka records", batchSize = records.length()); |
| log:printDebug("Processing event based on hub mode", hubMode = hubMode); | ||
|
|
||
| match hubMode { | ||
| "register" => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 4
| "register" => { | |
| match hubMode { | |
| "register" => { | |
| log:printInfo("Processing topic registration event"); |
| check processTopicRegistration(payload); | ||
| log:printDebug("Topic registration event processed successfully"); | ||
| } | ||
| "deregister" => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 5
| "deregister" => { | |
| "deregister" => { | |
| log:printInfo("Processing topic deregistration event"); |
| check processTopicDeregistration(payload); | ||
| log:printDebug("Topic deregistration event processed successfully"); | ||
| } | ||
| "subscribe" => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 6
| "subscribe" => { | |
| "subscribe" => { | |
| log:printInfo("Processing subscription event"); |
| check processSubscription(payload); | ||
| log:printDebug("Subscription event processed successfully"); | ||
| } | ||
| "unsubscribe" => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 7
| "unsubscribe" => { | |
| "unsubscribe" => { | |
| log:printInfo("Processing unsubscription event"); |
| } | ||
| } | ||
| log:printDebug("Completed processing persisted data", hubMode = hubMode); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 8
| } | |
| isolated function processStateUpdate() returns error? { | |
| log:printInfo("Processing state update - gathering current system state"); |
| common:SystemStateSnapshot stateSnapshot = { | ||
| topics: getTopics(), | ||
| subscriptions: getSubscriptions() | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 9
| }; | |
| check persist:persistWebsubEventsSnapshot(stateSnapshot); | |
| log:printInfo("State snapshot persisted successfully", topicCount = stateSnapshot.topics.length(), subscriptionCount = stateSnapshot.subscriptions.length()); |
| public isolated function persistWebsubEventsSnapshot(common:SystemStateSnapshot systemStateSnapshot) returns error? { | ||
| log:printDebug("Persisting system state snapshot", topicCount = systemStateSnapshot.topics.length(), subscriptionCount = systemStateSnapshot.subscriptions.length()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 11
| public isolated function persistWebsubEventsSnapshot(common:SystemStateSnapshot systemStateSnapshot) returns error? { | |
| log:printDebug("Persisting system state snapshot", topicCount = systemStateSnapshot.topics.length(), subscriptionCount = systemStateSnapshot.subscriptions.length()); | |
| public isolated function persistWebsubEventsSnapshot(common:SystemStateSnapshot systemStateSnapshot) returns error? { | |
| log:printInfo("Persisting system state snapshot", topicCount = systemStateSnapshot.topics.length(), subscriptionCount = systemStateSnapshot.subscriptions.length()); |
| check produceKafkaMessage(config:state.snapshot.topic, payload); | ||
| log:printDebug("System state snapshot persisted successfully", targetTopic = config:state.snapshot.topic); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 12
| check produceKafkaMessage(config:state.snapshot.topic, payload); | |
| log:printDebug("System state snapshot persisted successfully", targetTopic = config:state.snapshot.topic); | |
| check produceKafkaMessage(config:state.snapshot.topic, payload); | |
| log:printInfo("System state snapshot persisted successfully", targetTopic = config:state.snapshot.topic); |
| isolated function produceKafkaMessage(string topicName, json payload) returns error? { | ||
| log:printDebug("Producing Kafka message", targetTopic = topicName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 13
| isolated function produceKafkaMessage(string topicName, json payload) returns error? { | |
| log:printDebug("Producing Kafka message", targetTopic = topicName); | |
| isolated function produceKafkaMessage(string topicName, json payload) returns error? { | |
| if (log:isDebugEnabled()) { | |
| log:printDebug("Producing Kafka message", targetTopic = topicName, payloadSize = payload.toJsonString().length()); | |
| } |
| isolated function refreshSubscribersCache(websubhub:VerifiedSubscription[] persistedSubscribers) { | ||
| log:printDebug("Refreshing subscribers cache from persisted data", persistedSubscriberCount = persistedSubscribers.length()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 14
| isolated function refreshSubscribersCache(websubhub:VerifiedSubscription[] persistedSubscribers) { | |
| log:printDebug("Refreshing subscribers cache from persisted data", persistedSubscriberCount = persistedSubscribers.length()); | |
| isolated function refreshSubscribersCache(websubhub:VerifiedSubscription[] persistedSubscribers) { | |
| log:printInfo("Starting subscribers cache refresh", persistedSubscriberCount = persistedSubscribers.length()); |
| } | ||
| log:printDebug("Subscribers cache refresh completed", totalCachedSubscribers = subscribersCache.length()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 15
| } | |
| log:printDebug("Subscribers cache refresh completed", totalCachedSubscribers = subscribersCache.length()); | |
| } | |
| log:printInfo("Subscribers cache refresh completed", totalCachedSubscribers = subscribersCache.length()); |
| check processStateUpdate(); | ||
| log:printDebug("Subscription processing completed", subscriberId = subscriberId, wasAdded = subscriptionAdded); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 16
| check processStateUpdate(); | |
| log:printDebug("Subscription processing completed", subscriberId = subscriberId, wasAdded = subscriptionAdded); | |
| check processStateUpdate(); | |
| log:printInfo("Subscription processed successfully", subscriberId = subscriberId, wasAdded = subscriptionAdded); |
| check processStateUpdate(); | ||
| log:printDebug("Unsubscription processing completed", subscriberId = subscriberId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 17
| check processStateUpdate(); | |
| log:printDebug("Unsubscription processing completed", subscriberId = subscriberId); | |
| check processStateUpdate(); | |
| log:printInfo("Unsubscription processed successfully", subscriberId = subscriberId); |
| foreach var topic in persistedTopics.cloneReadOnly() { | ||
| lock { | ||
| registeredTopicsCache[topic.topic] = topic.cloneReadOnly(); | ||
| } | ||
| log:printDebug("Added topic to cache during refresh", topicName = topic.topic); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 18
| foreach var topic in persistedTopics.cloneReadOnly() { | |
| lock { | |
| registeredTopicsCache[topic.topic] = topic.cloneReadOnly(); | |
| } | |
| log:printDebug("Added topic to cache during refresh", topicName = topic.topic); | |
| } | |
| foreach var topic in persistedTopics.cloneReadOnly() { | |
| lock { | |
| registeredTopicsCache[topic.topic] = topic.cloneReadOnly(); | |
| } | |
| if (log:isDebugEnabled()) { | |
| log:printDebug("Added topic to cache during refresh", topicName = topic.topic); | |
| } |
| isolated function refreshTopicCache(websubhub:TopicRegistration[] persistedTopics) { | ||
| log:printDebug("Refreshing topic cache from persisted data", persistedTopicCount = persistedTopics.length()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 19
| isolated function refreshTopicCache(websubhub:TopicRegistration[] persistedTopics) { | |
| log:printDebug("Refreshing topic cache from persisted data", persistedTopicCount = persistedTopics.length()); | |
| solated function refreshTopicCache(websubhub:TopicRegistration[] persistedTopics) { | |
| if (log:isDebugEnabled()) { | |
| log:printDebug("Refreshing topic cache from persisted data", persistedTopicCount = persistedTopics.length()); | |
| } |
| } | ||
| log:printDebug("Topic cache refresh completed", totalCachedTopics = registeredTopicsCache.length()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 20
| } | |
| log:printDebug("Topic cache refresh completed", totalCachedTopics = registeredTopicsCache.length()); | |
| } | |
| if (log:isDebugEnabled()) { | |
| log:printDebug("Topic cache refresh completed", totalCachedTopics = registeredTopicsCache.length()); | |
| } |
|
|
||
| isolated function processTopicRegistration(json payload) returns error? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 21
| isolated function processTopicRegistration(json payload) returns error? { | |
| isolated function processTopicRegistration(json payload) returns error? { | |
| if (log:isDebugEnabled()) { | |
| log:printDebug("Processing topic registration event"); | |
| } |
| log:printDebug("Processing topic registration event"); | ||
| websubhub:TopicRegistration registration = check value:cloneWithType(payload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 22
| log:printDebug("Processing topic registration event"); | |
| websubhub:TopicRegistration registration = check value:cloneWithType(payload); | |
| websubhub:TopicRegistration registration = check value:cloneWithType(payload); | |
| if (log:isDebugEnabled()) { | |
| log:printDebug("Deserialized topic registration", topicName = registration.topic); | |
| } |
| registeredTopicsCache[registration.topic] = registration.cloneReadOnly(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 23
| registeredTopicsCache[registration.topic] = registration.cloneReadOnly(); | |
| } | |
| } | |
| if (log:isDebugEnabled()) { | |
| log:printDebug("Added topic to cache", topicName = registration.topic, totalTopics = registeredTopicsCache.length()); | |
| } |
| log:printDebug("Added topic to cache", topicName = registration.topic, totalTopics = registeredTopicsCache.length()); | ||
| check processStateUpdate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 24
| log:printDebug("Added topic to cache", topicName = registration.topic, totalTopics = registeredTopicsCache.length()); | |
| check processStateUpdate(); | |
| check processStateUpdate(); | |
| if (log:isDebugEnabled()) { | |
| log:printDebug("Topic registration processing completed", topicName = registration.topic); | |
| } |
|
|
||
| isolated function processTopicDeregistration(json payload) returns error? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 25
| isolated function processTopicDeregistration(json payload) returns error? { | |
| isolated function processTopicDeregistration(json payload) returns error? { | |
| if (log:isDebugEnabled()) { | |
| log:printDebug("Processing topic deregistration event"); | |
| } |
| log:printDebug("Processing topic deregistration event"); | ||
| websubhub:TopicDeregistration deregistration = check value:cloneWithType(payload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 26
| log:printDebug("Processing topic deregistration event"); | |
| websubhub:TopicDeregistration deregistration = check value:cloneWithType(payload); | |
| websubhub:TopicDeregistration deregistration = check value:cloneWithType(payload); | |
| if (log:isDebugEnabled()) { | |
| log:printDebug("Deserialized topic deregistration", topicName = deregistration.topic); | |
| } |
| topicRemoved = removedTopic is websubhub:TopicRegistration; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 27
| topicRemoved = removedTopic is websubhub:TopicRegistration; | |
| } | |
| } | |
| if (log:isDebugEnabled()) { | |
| log:printDebug("Removed topic from cache", topicName = deregistration.topic, wasRemoved = topicRemoved, totalTopics = registeredTopicsCache.length()); | |
| } |
| log:printDebug("Removed topic from cache", topicName = deregistration.topic, wasRemoved = topicRemoved, totalTopics = registeredTopicsCache.length()); | ||
| check processStateUpdate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 28
| log:printDebug("Removed topic from cache", topicName = deregistration.topic, wasRemoved = topicRemoved, totalTopics = registeredTopicsCache.length()); | |
| check processStateUpdate(); | |
| check processStateUpdate(); | |
| if (log:isDebugEnabled()) { | |
| log:printDebug("Topic deregistration processing completed", topicName = deregistration.topic); | |
| } |
| topics = registeredTopicsCache.toArray().cloneReadOnly(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 29
| topics = registeredTopicsCache.toArray().cloneReadOnly(); | |
| } | |
| } | |
| if (log:isDebugEnabled()) { | |
| log:printDebug("Retrieved topics from cache", topicCount = topics.length()); | |
| } |
| isolated remote function onRegisterTopic(websubhub:TopicRegistration message, http:Headers headers) | ||
| returns websubhub:TopicRegistrationSuccess|websubhub:TopicRegistrationError|error { | ||
| log:printDebug("Topic registration request received", topic = message.topic, securityEnabled = config:securityOn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 30
| isolated remote function onRegisterTopic(websubhub:TopicRegistration message, http:Headers headers) | |
| returns websubhub:TopicRegistrationSuccess|websubhub:TopicRegistrationError|error { | |
| log:printDebug("Topic registration request received", topic = message.topic, securityEnabled = config:securityOn); | |
| isolated remote function onRegisterTopic(websubhub:TopicRegistration message, http:Headers headers) | |
| returns websubhub:TopicRegistrationSuccess|websubhub:TopicRegistrationError|error { | |
| log:printInfo("Topic registration request received", topic = message.topic); |
| } | ||
| check self.registerTopic(message); | ||
| log:printDebug("Topic registration completed successfully", topic = message.topic); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 31
| } | |
| check self.registerTopic(message); | |
| log:printDebug("Topic registration completed successfully", topic = message.topic); | |
| } | |
| check self.registerTopic(message); | |
| log:printInfo("Topic registered successfully", topic = message.topic); |
| log:printDebug("Checking topic existence in cache", topic = message.topic, exists = topicExist); | ||
| if topicExist { | ||
| log:printDebug("Topic registration failed - already exists", topic = message.topic); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 32
| log:printDebug("Checking topic existence in cache", topic = message.topic, exists = topicExist); | |
| if topicExist { | |
| log:printDebug("Topic registration failed - already exists", topic = message.topic); | |
| if topicExist { | |
| log:printDebug("Topic registration failed - already exists", topic = message.topic); | |
| log:printWarn("Attempted to register existing topic", topic = message.topic); |
| error? persistingResult = persist:addRegsiteredTopic(message.cloneReadOnly()); | ||
| if persistingResult is error { | ||
| common:logError("Error occurred while persisting the topic-registration", persistingResult); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 33
| error? persistingResult = persist:addRegsiteredTopic(message.cloneReadOnly()); | |
| if persistingResult is error { | |
| common:logError("Error occurred while persisting the topic-registration", persistingResult); | |
| error? persistingResult = persist:addRegsiteredTopic(message.cloneReadOnly()); | |
| if persistingResult is error { | |
| log:printError("Error occurred while persisting topic registration", topic = message.topic, errorMsg = persistingResult.message()); |
| isolated remote function onDeregisterTopic(websubhub:TopicDeregistration message, http:Headers headers) | ||
| returns websubhub:TopicDeregistrationSuccess|websubhub:TopicDeregistrationError|error { | ||
| log:printDebug("Topic deregistration request received", topic = message.topic, securityEnabled = config:securityOn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 34
| isolated remote function onDeregisterTopic(websubhub:TopicDeregistration message, http:Headers headers) | |
| returns websubhub:TopicDeregistrationSuccess|websubhub:TopicDeregistrationError|error { | |
| log:printDebug("Topic deregistration request received", topic = message.topic, securityEnabled = config:securityOn); | |
| isolated remote function onDeregisterTopic(websubhub:TopicDeregistration message, http:Headers headers) | |
| returns websubhub:TopicDeregistrationSuccess|websubhub:TopicDeregistrationError|error { | |
| log:printInfo("Topic deregistration request received", topic = message.topic); |
| } | ||
| check self.deregisterTopic(message); | ||
| log:printDebug("Topic deregistration completed successfully", topic = message.topic); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 35
| } | |
| check self.deregisterTopic(message); | |
| log:printDebug("Topic deregistration completed successfully", topic = message.topic); | |
| } | |
| check self.deregisterTopic(message); | |
| log:printInfo("Topic deregistered successfully", topic = message.topic); |
| log:printDebug("Checking topic existence in cache for deregistration", topic = message.topic, exists = topicExist); | ||
| if !topicExist { | ||
| log:printDebug("Topic deregistration failed - not found", topic = message.topic); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 36
| log:printDebug("Checking topic existence in cache for deregistration", topic = message.topic, exists = topicExist); | |
| if !topicExist { | |
| log:printDebug("Topic deregistration failed - not found", topic = message.topic); | |
| if !topicExist { | |
| log:printDebug("Topic deregistration failed - not found", topic = message.topic); | |
| log:printWarn("Attempted to deregister non-existent topic", topic = message.topic); |
| error? persistingResult = persist:removeRegsiteredTopic(message.cloneReadOnly()); | ||
| if persistingResult is error { | ||
| common:logError("Error occurred while persisting the topic-deregistration", persistingResult); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 37
| error? persistingResult = persist:removeRegsiteredTopic(message.cloneReadOnly()); | |
| if persistingResult is error { | |
| common:logError("Error occurred while persisting the topic-deregistration", persistingResult); | |
| error? persistingResult = persist:removeRegsiteredTopic(message.cloneReadOnly()); | |
| if persistingResult is error { | |
| log:printError("Error occurred while persisting topic deregistration", topic = message.topic, errorMsg = persistingResult.message()); |
| isolated remote function onSubscription(websubhub:Subscription message, http:Headers headers) | ||
| returns websubhub:SubscriptionAccepted|websubhub:BadSubscriptionError|error { | ||
| log:printDebug("Subscription request received", topic = message.hubTopic, callback = message.hubCallback, securityEnabled = config:securityOn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 38
| isolated remote function onSubscription(websubhub:Subscription message, http:Headers headers) | |
| returns websubhub:SubscriptionAccepted|websubhub:BadSubscriptionError|error { | |
| log:printDebug("Subscription request received", topic = message.hubTopic, callback = message.hubCallback, securityEnabled = config:securityOn); | |
| isolated remote function onSubscription(websubhub:Subscription message, http:Headers headers) | |
| returns websubhub:SubscriptionAccepted|websubhub:BadSubscriptionError|error { | |
| log:printInfo("Subscription request received", topic = message.hubTopic, callback = message.hubCallback); |
| log:printDebug("Topic exists check for subscription", topic = message.hubTopic, exists = topicExist); | ||
| if !topicExist { | ||
| log:printDebug("Subscription validation failed - topic not registered", topic = message.hubTopic, callback = message.hubCallback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 39
| log:printDebug("Topic exists check for subscription", topic = message.hubTopic, exists = topicExist); | |
| if !topicExist { | |
| log:printDebug("Subscription validation failed - topic not registered", topic = message.hubTopic, callback = message.hubCallback); | |
| if !topicExist { | |
| log:printDebug("Subscription validation failed - topic not registered", topic = message.hubTopic, callback = message.hubCallback); | |
| log:printWarn("Subscription attempt for non-registered topic", topic = message.hubTopic); |
| } | ||
| if isValidSubscription(subscriberId) { | ||
| if isSubscriptionExist(subscriberId) { | ||
| log:printDebug("Subscription validation failed - active subscription exists", subscriberId = subscriberId, topic = message.hubTopic, callback = message.hubCallback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 40
| } | |
| if isValidSubscription(subscriberId) { | |
| if isSubscriptionExist(subscriberId) { | |
| log:printDebug("Subscription validation failed - active subscription exists", subscriberId = subscriberId, topic = message.hubTopic, callback = message.hubCallback); | |
| if isSubscriptionExist(subscriberId) { | |
| log:printDebug("Subscription validation failed - active subscription exists", subscriberId = subscriberId, topic = message.hubTopic, callback = message.hubCallback); | |
| log:printWarn("Duplicate subscription attempt", topic = message.hubTopic, callback = message.hubCallback); |
| isolated remote function onSubscriptionIntentVerified(websubhub:VerifiedSubscription message) returns error? { | ||
| log:printDebug("Processing verified subscription intent", topic = message.hubTopic, callback = message.hubCallback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 41
| isolated remote function onSubscriptionIntentVerified(websubhub:VerifiedSubscription message) returns error? { | |
| log:printDebug("Processing verified subscription intent", topic = message.hubTopic, callback = message.hubCallback); | |
| isolated remote function onSubscriptionIntentVerified(websubhub:VerifiedSubscription message) returns error? { | |
| log:printDebug("Processing verified subscription intent", topic = message.hubTopic, callback = message.hubCallback); | |
| log:printInfo("Subscription verified and accepted", topic = message.hubTopic, callback = message.hubCallback); |
| error? persistingResult = persist:addSubscription(subscription); | ||
| if persistingResult is error { | ||
| log:printError("Error occurred while persisting the subscription ", persistingResult); | ||
| common:logError("Error occurred while persisting the subscription", persistingResult); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 42
| error? persistingResult = persist:addSubscription(subscription); | |
| if persistingResult is error { | |
| log:printError("Error occurred while persisting the subscription ", persistingResult); | |
| common:logError("Error occurred while persisting the subscription", persistingResult); | |
| error? persistingResult = persist:addSubscription(subscription); | |
| if persistingResult is error { | |
| log:printError("Error occurred while persisting the subscription", topic = subscription.hubTopic, callback = subscription.hubCallback, errorMsg = persistingResult.message()); |
| do { | ||
| while true { | ||
| kafka:BytesConsumerRecord[] records = check conn:websubEventConsumer->poll(config:kafka.consumer.pollingInterval); | ||
| log:printDebug("Polled Kafka records for state consolidation", recordCount = records.length(), pollingInterval = config:kafka.consumer.pollingInterval); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have any computation, it's better to use a function pointer, as it is only executed when we enable the debug level. Otherwise, it has unnecessary tasks.
log:printDebug("Polled Kafka records for state consolidation",
recordCount = isolated function() returns int { return records.length();},
pollingInterval = config:kafka.consumer.pollingInterval);| int messageSize = lastPersistedData.length(); | ||
| log:printDebug("Processing Kafka record for consolidation", messageSize = messageSize, offset = currentRecord.offset); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do the same as above without initializing the variable.
| websubhub:VerifiedSubscription? removedSubscription = subscribersCache.removeIfHasKey(subscriberId); | ||
| boolean subscriptionRemoved = removedSubscription is websubhub:VerifiedSubscription; | ||
| log:printDebug("Removed subscription from cache", subscriberId = subscriberId, wasRemoved = subscriptionRemoved, totalSubscriptions = subscribersCache.length()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
| log:printDebug("Processing topic deregistration event"); | ||
| websubhub:TopicDeregistration topicDeregistration = check event.fromJsonWithType(); | ||
| log:printDebug("Topic deregistration event deserialized", topic = topicDeregistration.topic); | ||
| check processTopicDeregistration(topicDeregistration); | ||
| log:printDebug("Topic deregistration event processed successfully", topic = topicDeregistration.topic); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we have a single log line for this? There is a cost of checking whether debug is enabled in each call
| log:printDebug("Partitions assigned successfully", topic = topicName, assignedPartitions = partitions.length()); | ||
|
|
||
| log:printDebug("Processing partition offsets", topic = topicName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, we can have one here
Purpose
Part of: #3