-
Notifications
You must be signed in to change notification settings - Fork 6
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
Rework tapir
integration according to the new API
#82
Comments
I'm not that familiar with the code, but I did a draft PR here: #89 |
@fiadliel let's continue the discussion here |
I've been wondering what one actually wants here from tapir (it'd be a shame if something was implemented that wasn't what you want). One approach I'm thinking of is that the part that calls both security and functional logic is This would mean that per-endpoint syntax would no longer be involved with extracting the span, just with creating a child span and decorating it with per-endpoint information. One potential positive benefit is that tapir interceptors could become part of the trace. Also if this change to Thoughts? |
The main idea of secured endpoints is that tapir doesn't parse inputs (the I'm working on a solution for secured endpoints and can't decide on how to act and what to demand from different kinds of inputs.
|
cc @fiadliel @janstenpickle |
N.B. the new server endpoint model is: securityLogic: A => F[E | U]
serverLogic: U => I => F[E | O] |
There's a little nuance to "doesn't parse inputs (the I parameter) until securityLogic is performed", which is that inputs except the body are parsed, in https://github.com/softwaremill/tapir/blob/master/core/src/main/scala/sttp/tapir/server/interpreter/ServerInterpreter.scala#L59 - but it looks like a hairy part of the API to interact with. Is that a I have a general issue with any solution where a single request ends up creating two root spans. There should be a 1:1 match between requests and spans (not considering child spans). There seem to be a few options for creating that root span:
The first option is not much different to using a server-specific integration (e.g. trace4cats + http4s), it uses zero value-add of what tapir provides. The second option might need experimentation, but it looks like the code could need a lot of refactoring to make it useable. Third option sounds like the hardest one. It doesn't look like there are any easy and nice solutions within the tapir code. Right now, personally, I'm using a combination of trace4cats-http4s, and a per-endpoint child span which can be annotated with endpoint name and input/output parameters. It works, but it's a bit noisy if you'd prefer a single span per request. |
Some more thoughts: tapir selects the endpoint that's used by whichever is the first to return a success. So firstly, we can't define the span name based on the endpoint (unless we can make the span name mutable). But that has always been an issue.
Need a hook to create a span wrapping |
With the release of 0.19.0-M14 the
ServerEndpoint
has changed significantly.Now it encapsulates a separate piece of security logic in form of
A => F[Either[E, U]]
which breaks the current approach to trace injection.The text was updated successfully, but these errors were encountered: