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

Add response duration tracking to webhook message attempts #1877

Merged

Conversation

CodeMan62
Copy link
Contributor

Motivation

Currently, the OSS version of Svix doesn't record webhook response times, which is an important metric for monitoring webhook delivery performance. This capability exists in the commercial API (as documented at https://api.svix.com/docs#tag/Message-Attempt/operation/v1.message-attempt.get), but was missing in the open-source version.
Adding response duration tracking will provide OSS users with valuable information about webhook latency, helping them troubleshoot delivery issues and monitor the performance of their webhook endpoints.

Solution

This PR adds webhook response duration tracking to the OSS version of Svix by:

  1. Adding a response_duration_ms field to the messageattempt database model
  2. Creating a database migration to add this column to existing tables
  3. Updating the webhook client code to measure and store response times using std::time::Instant
  4. Modifying the MessageAttemptOut implementation to use the actual duration instead of hardcoding to 0
  5. Removing documentation comments that mentioned response times not being available in OSS
    With these changes, the response time in milliseconds will be available through the API for each webhook attempt, providing parity with the commercial API's functionality.

@CodeMan62 CodeMan62 requested a review from a team as a code owner April 12, 2025 02:56
Copy link
Member

@svix-jplatte svix-jplatte left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

For formatting, you might have to install a nightly toolchain and run rustfmt throught that (rustup install nightly + cargo +nightly fmt if you have rustup).

For the other failing CI check, simply run the generate-openapi.sh script in the server directory and the OpenAPI spec file will be updated.

@CodeMan62
Copy link
Contributor Author

Hey @svix-jplatte, thanks for the review. I have done all the things you said. Take a look at the changes and tell me if any changes are required

Copy link
Member

@svix-jplatte svix-jplatte left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@svix-jplatte svix-jplatte merged commit ae5a7f1 into svix:main Apr 14, 2025
13 checks passed
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.

2 participants