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

feat(analytics): add smart_retries only metrics #6575

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

maverox
Copy link
Contributor

@maverox maverox commented Nov 14, 2024

Type of Change

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

Description

In the PaymentDistributionAccumulator, I added another field variant with the signature
<field_name>_with_only_smart_retries.
Where field_name can be anything from success_rate, failure_rate.

Additional Changes

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

Motivation and Context

Fixes #6574

How did you test it?

Request

curl --location 'http://localhost:8080/analytics/v1/org/metrics/payments' \
--header 'Accept: */*' \
--header 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
--header 'Connection: keep-alive' \
--header 'Content-Type: application/json' \
--header 'Origin: http://localhost:9000' \
--header 'QueryType: SingleStat' \
--header 'Referer: http://localhost:9000/' \
--header 'Sec-Fetch-Dest: empty' \
--header 'Sec-Fetch-Mode: cors' \
--header 'Sec-Fetch-Site: same-site' \
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36' \
--header 'api-key: dev_r3kVZ4URj3fMiHhJJuhHOVqteaXwKyEMGCaFo6PiCS6S9vZsb0ErV4kCVqogM60H' \
--header 'authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiMDZlOGRmZWYtMzI0Zi00Yjc0LTg2MTItYzdkZjNhOGZmZTcyIiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzI3NDM0NTkzIiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTczMTY1MTcyMCwib3JnX2lkIjoib3JnXzl3Y0kxQ2hTOGVEdnRRQmRXak9IIiwicHJvZmlsZV9pZCI6InByb19FNW5lek43YjZUbVB1WlUzbEU1VSJ9.gtctUL339INfdj6CVmZLW2NDMNcseMTCPX0uxSsOD1c' \
--header 'sec-ch-ua: "Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "macOS"' \
--data '[
    {
        "timeRange": {
            "startTime": "2024-11-07T01:30:00Z",
            "endTime": "2024-11-09T23:30:00Z"
        },
        "mode": "ORDER",
        "source": "BATCH",
        "metrics": [
            "payments_distribution"
        ],
        "delta": true
    }
]'

Response

{
    "queryData": [
        {
            "payment_success_rate": null,
            "payment_count": null,
            "payment_success_count": null,
            "payment_processed_amount": 0,
            "payment_processed_amount_usd": null,
            "payment_processed_count": null,
            "payment_processed_amount_without_smart_retries": 0,
            "payment_processed_amount_without_smart_retries_usd": null,
            "payment_processed_count_without_smart_retries": null,
            "avg_ticket_size": null,
            "payment_error_message": null,
            "retries_count": null,
            "retries_amount_processed": 0,
            "connector_success_rate": null,
            "payments_success_rate_distribution": 66.66666666666667,
            "payments_success_rate_distribution_without_smart_retries": 57.142857142857146,
            "payments_success_rate_distribution_with_only_retries": 100.0,
            "payments_failure_rate_distribution": 33.333333333333336,
            "payments_failure_rate_distribution_without_smart_retries": 42.857142857142854,
            "payments_failure_rate_distribution_with_only_retries": 0.0,
            "failure_reason_count": 0,
            "failure_reason_count_without_smart_retries": 0,
            "currency": null,
            "status": null,
            "connector": null,
            "authentication_type": null,
            "payment_method": null,
            "payment_method_type": null,
            "client_source": null,
            "client_version": null,
            "profile_id": null,
            "card_network": null,
            "merchant_id": null,
            "card_last_4": null,
            "card_issuer": null,
            "error_reason": null,
            "time_range": {
                "start_time": "2024-11-07T01:30:00.000Z",
                "end_time": "2024-11-09T23:30:00.000Z"
            },
            "time_bucket": "2024-11-07 01:30:00"
        }
    ],
    "metaData": [
        {
            "total_payment_processed_amount": 0,
            "total_payment_processed_amount_usd": 0,
            "total_payment_processed_amount_without_smart_retries": 0,
            "total_payment_processed_amount_without_smart_retries_usd": 0,
            "total_payment_processed_count": 0,
            "total_payment_processed_count_without_smart_retries": 0,
            "total_failure_reasons_count": 0,
            "total_failure_reasons_count_without_smart_retries": 0
        }
    ]
}

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

@maverox maverox requested a review from a team as a code owner November 14, 2024 13:37
Copy link

semanticdiff-com bot commented Nov 14, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/analytics/src/payments/accumulator.rs  17% smaller
  crates/api_models/src/analytics/payments.rs  0% smaller

@maverox maverox added C-feature Category: Feature request or enhancement Rust Pull requests that update Rust code A-Analytics labels Nov 14, 2024
@maverox maverox self-assigned this Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Analytics C-feature Category: Feature request or enhancement Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(analytics): add smart_retries only metrics
1 participant