Skip to content
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

refactor: add basic counter metrics for IMC #5006

Merged
merged 7 commits into from
Jun 18, 2024

Conversation

Chethan-rao
Copy link
Contributor

@Chethan-rao Chethan-rao commented Jun 13, 2024

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

This PR introduces basic counter metrics for IMC -

  • hits (successful read)
  • misses (failed read)
  • manual invalidations (done by applications) - makes use of eviction listener on moka that can help identify strategy based evictions

This PR also moves the add_attribute method of metrics to router_env crate. This method now takes a list of attributes as an argument as opposed to just one (key,value) pair.

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

  1. Insert new config key value pair. Data is not cached in IMC during insertion
curl --location 'http://localhost:8080/configs/' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data '{
    "key": "test_key",
    "value": "test_val_1"
}'
  1. Retrieve the inserted config so that the data gets cached to IMC. Since this is the first time the data is getting retrieved, there'll be a cache mis
curl --location 'http://localhost:8080/configs/test_key' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data ''

image

  1. Again retrieve the same config. Since in the previous retrieve, the data was cached, this retrieve will be a cache hit
curl --location 'http://localhost:8080/configs/test_key' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data ''

image

  1. Update the inserted config. This time the cache data has to be invalidated. This should increment the IN_MEMORY_CACHE_EVICTION_COUNT metric
curl --location 'http://localhost:8080/configs/test_key' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data '{
    "key": "test_key",
    "value": "test_val_2"
}'

image

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@Chethan-rao Chethan-rao added S-waiting-on-review Status: This PR has been implemented and needs to be reviewed C-refactor Category: Refactor labels Jun 13, 2024
@Chethan-rao Chethan-rao added this to the May 2024 Release milestone Jun 13, 2024
@Chethan-rao Chethan-rao self-assigned this Jun 13, 2024
@Chethan-rao Chethan-rao requested review from a team as code owners June 13, 2024 19:17
@Chethan-rao Chethan-rao linked an issue Jun 13, 2024 that may be closed by this pull request
crates/router_env/src/metrics/request.rs Outdated Show resolved Hide resolved
crates/storage_impl/src/metrics.rs Outdated Show resolved Hide resolved
crates/storage_impl/src/redis/cache.rs Outdated Show resolved Hide resolved
@likhinbopanna likhinbopanna added this pull request to the merge queue Jun 18, 2024
Merged via the queue into main with commit d2092dc Jun 18, 2024
11 checks passed
@likhinbopanna likhinbopanna deleted the add-counter-metrics-for-imc branch June 18, 2024 13:14
pixincreate added a commit that referenced this pull request Jun 20, 2024
…ress-skip

* 'main' of github.com:juspay/hyperswitch: (27 commits)
  feat(cypress): add 2 more payout connectors and bank transfer support for payout (#4993)
  chore(version): 2024.06.20.0
  Refactor(core): reverts the payment method list filtering using constraint graph (#5044)
  feat(router): add payment method type duplication check for `google_pay` (#5023)
  refactor(storage): remove `id` from payment intent, attempt and remove datamodel ext from payment intent (#4923)
  fix(events): Correct parsing of API events with user event_type for Clickhouse (#5022)
  fix(connector):  add local bank redirect type in compatibility layer, default the country to AT for Local Bank Redirect and add creds_identifier in access token  (#5038)
  refactor(connector): add amount conversion framework for noon (#4843)
  fix(logging): fix stack overflow on recording restricted keys (#4423)
  feat(core): Add logger for sessions call failure (#5036)
  chore(version): 2024.06.19.0
  fix(opensearch): handle index not present errors in search api (#4965)
  feat(multitenancy): add tenant_id as a field for data pipeline and support individual database for clickhouse  (#4867)
  refactor: add basic counter metrics for IMC (#5006)
  fix(payment_methods): populate card fields while saving card again during metadata change condition (#5019)
  feat(router): Override the `setup_future_usage` to `on_session` based on the merchant config (#5016)
  chore(docker-compose): pass correct configuration values for running SDK demo app  (#5012)
  refactor: Move trait ConnectorIntegration to crate hyperswitch_interfaces (#4946)
  chore(version): 2024.06.17.0
  chore(process_tracker): use `const` instead of `String` for `business_status` (#4849)
  ...
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-refactor Category: Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[REFACTOR] add basic counter metrics for IMC
4 participants