Skip to content

Conversation

@Quinn-With-Two-Ns
Copy link
Contributor

@Quinn-With-Two-Ns Quinn-With-Two-Ns commented May 1, 2025

Add interceptor support to Springboot integration. With this PR any interceptor bean will be automatically picked up and registered with the worker/client. Similar to Quarkus support for interceptors in Temporal.

Note: Currently not supported in multi namespace.

closes: #1634

@Quinn-With-Two-Ns Quinn-With-Two-Ns requested a review from a team as a code owner May 1, 2025 22:27
new OpenTracingWorkerInterceptor(
OpenTracingOptions.newBuilder().setTracer(tracer).build());
options.setWorkerInterceptors(openTracingClientInterceptor);
interceptors.add(openTracingClientInterceptor);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cretz @Sushisource Any thoughts on the default order here? I am putting the tracing interceptor at the end of the chain. unless we want to trace the interceptors themselves maybe?

Copy link
Member

@cretz cretz May 2, 2025

Choose a reason for hiding this comment

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

Interesting. In other SDKs we have them create the tracing interceptor instead of just the tracer, so it is their responsibility to choose order. But I can understand here it's easier if tracer is the bean they configure.

Hard to say whether at the end (is that innermost?) is a good default. Some users swallow or mutate errors, and the span may be better off reflecting the results of other people's interceptors.

Say I didn't want it at the end of the chain as a user, how hard would it be for me to provide a null tracer to this constructor here and put it at the beginning of the workerInterceptors list? Just curious, because both defaults have tradeoffs, so just wondering if there was a workaround.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah end would be innermost, to work around a user would provide a customizer to change the interceptors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can check what Quarkus did

Copy link
Member

@cretz cretz May 5, 2025

Choose a reason for hiding this comment

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

👍 If there's a workaround (e.g. don't inject tracer, make the interceptor in the list yourself), that's probably good enough. I do think the tracing intercepter being the outermost makes sense to have the span cover what other interceptors are doing (from a time or exception POV).

@Quinn-With-Two-Ns Quinn-With-Two-Ns merged commit 8fbb068 into temporalio:master May 5, 2025
9 checks passed
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.

Add support for interceptor beans to Spring Boot

2 participants