Skip to content

ISSUE-43 : Add DEBUG logging for GraphQL Client Cache HIT/MISS or Exc…#44

Open
sagarsane wants to merge 1 commit into
adobe:masterfrom
sagarsane:issues/add-logging-for-graphql-caching
Open

ISSUE-43 : Add DEBUG logging for GraphQL Client Cache HIT/MISS or Exc…#44
sagarsane wants to merge 1 commit into
adobe:masterfrom
sagarsane:issues/add-logging-for-graphql-caching

Conversation

@sagarsane
Copy link
Copy Markdown

Added DEBUG and ERROR logs when there is a Cache HIT or MISS or in case of an exception.

Description

Related Issue

Related Issue: #43

Motivation and Context

To be able to investigate issues when GraphQL Client Cache Configuration is missing or has errors. Especially on AEM 6.5.

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes and the overall coverage did not decrease.
  • All unit tests pass on CircleCi.
  • I ran all tests locally and they pass.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 29, 2024

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ommerce/graphql/client/impl/GraphqlClientImpl.java 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@billdinger
Copy link
Copy Markdown

billdinger commented Jan 29, 2024

thanks much for this, will help triage miss(ed) cache hits and other cache weirdness

CacheKey key = new CacheKey(request, options);
try {
LOGGER.debug("Cache HIT : Returning response from cache for key {}", key);
return (GraphqlResponse<T, U>) cache.get(key, () -> executeImpl(request, typeOfT, typeofU, options));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please pay attention to the fact that when 'cache' does don't have an entry for 'key' then it will execute the provided function in the second parameter of get() and if there's a valid response it will update the cache.
So your current approach is logging incorrectly both the cache hits and the cache misses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to investigate whether GraphQL Client had a Cache HIT or MISS, missing logging

3 participants