Skip to content

feat(ucs): add event logging for UCS operations#9058

Merged
likhinbopanna merged 13 commits intomainfrom
feat/ucs-event-logging
Sep 2, 2025
Merged

feat(ucs): add event logging for UCS operations#9058
likhinbopanna merged 13 commits intomainfrom
feat/ucs-event-logging

Conversation

@kanikac199
Copy link
Contributor

@kanikac199 kanikac199 commented Aug 25, 2025

Type of Change

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

Description

Added comprehensive event logging for UCS operations to improve debugging and monitoring. The changes wrap UCS calls with structured logging that captures request/response data, timing, and errors across all payment flows.

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?

Enable UCS

curl --location 'http://localhost:8080/configs/' \
--header 'api-key: test_admin' \
--header 'Content-Type: application/json' \
--data '
{
    "key": "ucs_enabled",
    "value": "true"
}'

Enable UCS authorize

--header 'api-key: test_admin' \
--header 'Content-Type: application/json' \
--header 'Authorization: api-key=dev_ya18hWOxWbhNjQWEacOVLAFiqOuhSsU3k53o5iyEK6IcxQohWPAMpCWGURyRSRYc' \
--data '{
      "key": "ucs_rollout_config_merchant_1756126931_razorpay_upi_Authorize",
      "value": "1.0"
  }'

Payments - Create

--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_Qaanra9EEOfvCZtfveDCXQbYgnzJF7vgwIqBiERdn510eGS9M49jmIZweYS5zC7y' \
--data-raw '{
  "amount": 100,
  "currency": "INR",
  "confirm": true,
  "capture_method": "automatic",
  "capture_on": "2022-09-10T10:11:12Z",
  "customer_id": "IatapayCustomer",
  "email": "[guest@example.com](mailto:guest@example.com)",
  "name": "John Doe",
  "phone": "999999999",
  "phone_country_code": "+1",
  "description": "Its my first payment request",
  "authentication_type": "no_three_ds",
  "return_url": "https://google.com/",
  "payment_method": "upi",
  "payment_method_type": "upi_collect",
  "payment_method_data": {
    "upi": {
      "upi_collect": {
      "vpa_id": "success@razorpay"
      }
    },
    "billing": {
            "address": {
                "line1": "1467",
                "line2": "Harrison Street",
                "line3": "Harrison Street",
                "city": "San Fransico",
                "state": "California",
                "zip": "94122",
                "country": "IN",
                "first_name": "Swangi",
                "last_name": "Kumari"
            },
            "phone": {
                "number": "8056594427",
                "country_code": "+91"
            },
            "email": "[swangi.kumari@juspay.in](mailto:swangi.kumari@juspay.in)"
        }
  },
  "billing": {
    "address": {
      "line1": "1467",
      "line2": "Harrison Street",
      "line3": "Harrison Street",
      "city": "San Fransico",
      "state": "California",
      "zip": "94122",
      "country": "IN",
      "first_name": "joseph",
      "last_name": "Doe"
    },
    "phone": {
      "number": "8056594427",
      "country_code": "+91"
    }
  },
  "shipping": {
    "address": {
      "line1": "1467",
      "line2": "Harrison Street",
      "line3": "Harrison Street",
      "city": "San Fransico",
      "state": "California",
      "zip": "94122",
      "country": "US",
      "first_name": "joseph",
      "last_name": "Doe"
    },
    "phone": {
      "number": "8056594427",
      "country_code": "+91"
    }
  },
  "statement_descriptor_name": "joseph",
  "statement_descriptor_suffix": "JS",
  "metadata": {
    "udf1": "value1",
    "new_customer": "true",
    "login_date": "2019-09-10T10:11:12Z"
  },
  "all_keys_required": true
}'

Logs (Success)
Screenshot 2025-08-28 at 2 46 00 PM
Logs(Failure)
Screenshot 2025-08-25 at 6 37 32 PM

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

@kanikac199 kanikac199 self-assigned this Aug 25, 2025
@kanikac199 kanikac199 requested a review from a team as a code owner August 25, 2025 13:38
@kanikac199 kanikac199 added the A-core Area: Core flows label Aug 25, 2025
@kanikac199 kanikac199 requested a review from a team as a code owner August 25, 2025 13:38
@semanticdiff-com
Copy link

semanticdiff-com bot commented Aug 25, 2025

jarnura
jarnura previously approved these changes Aug 26, 2025
@kanikac199 kanikac199 requested a review from jarnura August 28, 2025 13:28
/// It logs the actual gRPC request/response data, timing, and error information.
#[instrument(skip_all, fields(connector_name, flow_type, payment_id))]
pub async fn ucs_logging_wrapper<T, F, Fut, Req, Resp, GrpcReq, GrpcResp>(
router_data: RouterData<T, Req, Resp>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think This can be a mutable ref. Can avoid cloning router data as well

Suggested change
router_data: RouterData<T, Req, Resp>,
router_data: &mut RouterData<T, Req, Resp>,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The mutable reference approach creates lifetime issues with async closures - Rust can't move borrowed references in async move blocks.

hrithikesh026
hrithikesh026 previously approved these changes Aug 29, 2025
hrithikesh026
hrithikesh026 previously approved these changes Sep 1, 2025
@likhinbopanna likhinbopanna added this pull request to the merge queue Sep 2, 2025
Merged via the queue into main with commit 10cf161 Sep 2, 2025
21 of 25 checks passed
@likhinbopanna likhinbopanna deleted the feat/ucs-event-logging branch September 2, 2025 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-core Area: Core flows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Implement comprehensive event logging for UCS (Unified Connector Service) operations

6 participants