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

Improve performance of ApolloFederatedTracing wrapper #2167

Merged
merged 4 commits into from
Mar 24, 2024

Conversation

kyri-petrou
Copy link
Collaborator

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

@@ -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
Copy link
Collaborator Author

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 {
Copy link
Collaborator

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?

Copy link
Collaborator Author

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

@kyri-petrou
Copy link
Collaborator Author

@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

@kyri-petrou kyri-petrou merged commit 90838f1 into series/2.x Mar 24, 2024
10 checks passed
@kyri-petrou kyri-petrou deleted the improve-federated-tracing-performance branch March 24, 2024 06:15
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.

None yet

3 participants