-
-
Notifications
You must be signed in to change notification settings - Fork 249
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
Improve performance of ApolloFederatedTracing
wrapper
#2167
Improve performance of ApolloFederatedTracing
wrapper
#2167
Conversation
@@ -39,7 +39,7 @@ sealed trait Wrapper[-R] extends GraphQLAspect[Nothing, R] { self => | |||
that.withWrapper(self) | |||
|
|||
// Disables tracing only for wrappers in the caliban package | |||
final private[caliban] def trace: Trace = Trace.empty | |||
final private[caliban] implicit def trace: Trace = Trace.empty |
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.
Just noticed this wasn't an implicit 🤦♂️
@@ -98,41 +98,50 @@ object ApolloFederatedTracing { | |||
wrapPureValues: Boolean | |||
): FieldWrapper[Any] = | |||
new FieldWrapper[Any](wrapPureValues) { | |||
|
|||
private def updateState(startTime: Long, fieldInfo: FieldInfo)(result: Either[ExecutionError, ResponseValue]) = | |||
ZQuery.succeed { |
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.
Do we even need to wrap this? We only execute it within a foldQuery. Could we just execute purely and then lift the result?
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.
Yeah I think that's better actually. I'll do the change
@ghostdogpr @paulpdaniels I made another small optimization that I missed initially. I'll merge it in once CI passes, but let me know if you have any concerns about it |
With these changes, we reduce the number of flatmaps performed in the ApolloFederatedTracing wrapper for the happy path (when fields are successes). Since this wrapper wraps pure values by default, this should see a noticeable improvement for users OOTB