Skip to content

feat: add tracing to proto validation#2950

Merged
miparnisari merged 2 commits intomainfrom
trace-proto-validation
Mar 10, 2026
Merged

feat: add tracing to proto validation#2950
miparnisari merged 2 commits intomainfrom
trace-proto-validation

Conversation

@miparnisari
Copy link
Contributor

@miparnisari miparnisari commented Mar 5, 2026

Description

add tracing to proto validation

Testing

Before After
image image image image
image image image image

References

@github-actions github-actions bot added the area/api v1 Affects the v1 API label Mar 5, 2026
@codecov
Copy link

codecov bot commented Mar 5, 2026

Codecov Report

❌ Patch coverage is 84.21053% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.78%. Comparing base (c3eea34) to head (b7a0872).

Files with missing lines Patch % Lines
...iddleware/interceptorwrapper/interceptorwrapper.go 80.00% 2 Missing and 1 partial ⚠️

❌ Your project check has failed because the head coverage (74.78%) is below the target coverage (75.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2950      +/-   ##
==========================================
+ Coverage   73.82%   74.78%   +0.96%     
==========================================
  Files         494      495       +1     
  Lines       60623    60638      +15     
==========================================
+ Hits        44750    45343     +593     
+ Misses      12698    12132     -566     
+ Partials     3175     3163      -12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@miparnisari miparnisari force-pushed the trace-proto-validation branch from 1cc318f to cb441f1 Compare March 5, 2026 20:00
@miparnisari miparnisari changed the title chore: add tracing to proto validation feat: add tracing to proto validation Mar 5, 2026
@miparnisari miparnisari force-pushed the trace-proto-validation branch 2 times, most recently from 52f9626 to b078558 Compare March 6, 2026 00:35
@miparnisari miparnisari marked this pull request as ready for review March 6, 2026 00:35
@miparnisari miparnisari requested a review from a team as a code owner March 6, 2026 00:35
@miparnisari miparnisari force-pushed the trace-proto-validation branch 2 times, most recently from 59b3c1b to 9a345fb Compare March 6, 2026 17:44
@@ -1,2 +1,2 @@
// Package handwrittenvalidation defines middleware that runs custom-made validations on incoming requests.
// Package handwrittenvalidation defines middleware that runs validations on incoming requests.
package handwrittenvalidation
Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe i should rename the package...

Copy link
Contributor

Choose a reason for hiding this comment

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

We also might be able to get rid of this package? I haven't actually looked into it

Copy link
Contributor

@tstirrat15 tstirrat15 left a comment

Choose a reason for hiding this comment

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

See comment

@@ -1,2 +1,2 @@
// Package handwrittenvalidation defines middleware that runs custom-made validations on incoming requests.
// Package handwrittenvalidation defines middleware that runs validations on incoming requests.
package handwrittenvalidation
Copy link
Contributor

Choose a reason for hiding this comment

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

We also might be able to get rid of this package? I haven't actually looked into it

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think folding together the validation logic makes sense to me. If the goal is just "add spans around an interceptor," I'd rather write a function that takes an interceptor and a name and returns a new interceptor that adds spans with that name around the provided interceptor, and then we can throw it around the protovalidate interceptor. I think there's a good chance that we can get rid of this handwritten logic altogether using CEL rules that reference multiple fields and I'd rather not tie them together.

Copy link
Contributor Author

@miparnisari miparnisari Mar 6, 2026

Choose a reason for hiding this comment

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

I don't think folding together the validation logic makes sense to me.

why not? the responsibilties are the same: validate the incoming request.

the split can cause bugs. Look at the existing codebase today, in particular the Watch service: https://github.com/authzed/spicedb/blob/main/internal/services/v1/watch.go#L39. Notice something odd? if there were a handwritten validation defined, this code is buggy, it's not running it.

I'd rather write a function that takes an interceptor and a name and returns a new interceptor that adds spans with that name around the provided interceptor,

agree, i want to do this and put a span around EVERY interceptor because there are so many and i don't know where the time is being spent. but: separate PR

think there's a good chance that we can get rid of this handwritten logic altogether using CEL rules that reference multiple fields and I'd rather not tie them together.

agree, but: separate PR

@miparnisari miparnisari enabled auto-merge (squash) March 6, 2026 19:35
@miparnisari miparnisari force-pushed the trace-proto-validation branch from 9a345fb to 5c8d195 Compare March 7, 2026 03:09
@tstirrat15 tstirrat15 force-pushed the trace-proto-validation branch from 5c8d195 to 1fad59e Compare March 9, 2026 22:24
@tstirrat15 tstirrat15 force-pushed the trace-proto-validation branch from 1fad59e to 3f35624 Compare March 9, 2026 22:37

// WrapUnaryServerInterceptorWithSpans returns a new interceptor that wraps the given interceptor
// with a span, measuring the duration of the interceptor's pre-handler logic.
func WrapUnaryServerInterceptorWithSpans(
Copy link
Contributor Author

@miparnisari miparnisari Mar 9, 2026

Choose a reason for hiding this comment

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

@tstirrat15 is the idea to wrap more interceptors with this?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's the idea - it's here if we want it.

@tstirrat15 tstirrat15 force-pushed the trace-proto-validation branch from 3f35624 to b7a0872 Compare March 9, 2026 23:03
Copy link
Contributor

@tstirrat15 tstirrat15 left a comment

Choose a reason for hiding this comment

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

Maria approved my edits; I'm approving the PR.

@miparnisari miparnisari merged commit c3b75c9 into main Mar 10, 2026
44 of 45 checks passed
@miparnisari miparnisari deleted the trace-proto-validation branch March 10, 2026 00:08
@github-actions github-actions bot locked and limited conversation to collaborators Mar 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area/api v1 Affects the v1 API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants