-
Notifications
You must be signed in to change notification settings - Fork 221
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
Introduce Trace (what endpoint was matched) [RFC] #957
Conversation
e96c526
to
a62e918
Compare
Codecov Report
@@ Coverage Diff @@
## master #957 +/- ##
==========================================
+ Coverage 83.24% 83.25% +<.01%
==========================================
Files 49 50 +1
Lines 794 818 +24
Branches 48 48
==========================================
+ Hits 661 681 +20
- Misses 133 137 +4
Continue to review full report at Codecov.
|
Looks awesome, I was about to land the very similar PR but with trace replaced by My point is that |
55bb9fe
to
ee2a0da
Compare
ee2a0da
to
371a0da
Compare
Maybe it makes sense to introduce @vkostyukov what are your thoughts? |
Regarding the telemetry, I think it's enough to put resulting instance into |
@sergeykolbasov Yeah, I think exporting the Re: Meta. I'm perfectly fine if we keep metadata's purpose as a structure defining composed endpoints (built at endpoint creation), while trace could carry the information about what endpoints were matched during this evaluation (built when an endpoint is run). I hear you, we can populate |
case b @ EndpointResult.Matched(_, _, _) => | ||
EndpointResult.Matched( | ||
b.rem, | ||
a.trc.concat(b.trc), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if we move this concat
to private val trc = a.trc.concat(b.trc)
of the endpoint to generate it only once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm not sure this is possible. Neither a.trc
nor b.trc
are available until we run an endpoint (Endpoint.apply
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yeah
nvm then.
LGTM 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 from me. Regarding Response.ctx
though are there issues with that if an exception gets raise and the future your service returns is failed. You don't have a response to call ctx
there but you may have matched a Finch Endpoint in the underlying service. Feels weird but we could set it on the Requests context instead, that way we'd know if we matched but raised an exception in a finch endpoint.
Also @vkostyukov curious how this affects the benchmarks. Your comment about it being low footprint seems to indicate that it didn't have too much of an impact.
@rpless - that's a really good point about the failed request. We, however, have a top-level failure handler that always catches everything and converts it into a very basic 400 response. I think we should be fine with just setting the The new structure definitely comes at the cost yet I think we're in the position to pay it. Some recent performance optimizations should make it more-or-less even. I want to run some benchmarks to see the overhead. UPDATE: I take that back, we only handle Finch's own errors and bypass everything else. |
There is a slight (and expected) increase for path endpoints but nothing concerning:
I'm going to merge this in and employ the new data later, in a separate PR. As usual, we can iterate on performance later (if/as needed). |
We've been talking quite a bit about the ways to provide users with a context of what endpoint was actually matched (see #953 for a top-level issue). This wasn't possible today.
Both of our attempts to built-in metrics/telemetry failed because of that (see #845 and #855) as we didn't have the right tools to implement it.
I've been playing with the idea of including the matched path into an
EndpointResult
so it could be propagated along the request/input path. This way, at the very bottom (inToService
) we can extract this matched path and do something useful with that, for example, report metrics.This PR [RFC] introduces a new concept
io.finch.Trace
that represent a matched path of an endpoint and is optimized for low footprint and fast concat. Right now, we aren't doing anything useful with it inToService
as I wanted to make sure we settle on a general idea before I proceed with actually employing the new data.Let me know what do you think! Here is a quick usage example.