Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/develop/go/workers/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ import * as Components from '@site/src/components';

- [Run a Worker](/develop/go/workers/run-worker-process)
- [Sessions](/develop/go/workers/sessions)
- [Interceptors](/develop/go/workers/interceptors)
- [Serverless Workers](/develop/go/workers/serverless-workers)
34 changes: 34 additions & 0 deletions docs/develop/go/workers/interceptors.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
id: interceptors
title: Interceptors - Go SDK
sidebar_label: Interceptors
description:
Implement Interceptors in the Temporal Go SDK to manage inbound and outbound SDK calls, enhance tracing, and add
authorization to your Workflows and Activities.
toc_max_heading_level: 3
tags:
- Interceptors
- Go SDK
- Temporal SDKs
---

Interceptors wrap inbound and outbound Temporal calls so you can apply shared behavior such as tracing, logging, or
authorization. See [Interceptors](/encyclopedia/interceptors) for the inbound vs outbound model.

Register them on the Client (`client.Options.Interceptors`), the Worker (`worker.Options.Interceptors`), or both. Embed
`ClientInterceptorBase` / `WorkerInterceptorBase` and override only the methods you need. Full API:
[`go.temporal.io/sdk/interceptor`](https://pkg.go.dev/go.temporal.io/sdk/interceptor).
Comment on lines +18 to +20

:::warning Workflow interceptors and replay

Workflow interceptor methods also run during [replay](/develop/go/best-practices/testing-suite#replay). Use replay-safe
APIs for logging, randomness, and time.

:::

## Related

- [Observability - Tracing](/develop/go/platform/observability#tracing)
- [Context Propagation](/develop/go/best-practices/context-propagation)
- [Logging Interceptor sample](https://github.com/temporalio/samples-go/tree/main/logger-interceptor)
- [Plugins - Interceptors](/develop/plugins-guide#interceptors)
2 changes: 1 addition & 1 deletion docs/develop/java/best-practices/error-handling.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ Because the interceptor sees the original exception before the SDK's default con
attach `details` and a non-retryable classification consistently, rather than depending on every Activity
implementation to do it the same way. `WorkerInterceptor` and `ActivityInboundCallsInterceptor` are marked
`@Experimental`. For the general interceptor model — inbound versus outbound, and the other call categories you can
intercept — see [Interceptors](/develop/plugins-guide#interceptors).
intercept — see [Interceptors](/develop/java/workers/interceptors).

## Fail a Workflow deliberately {/* #fail-a-workflow */}

Expand Down
2 changes: 2 additions & 0 deletions docs/develop/java/workers/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ import * as Components from '@site/src/components';
## Workers

- [Run Worker processes](/develop/java/workers/run-worker-process)
- [Interceptors](/develop/java/workers/interceptors)
- [Serverless Workers](/develop/java/workers/serverless-workers)
37 changes: 37 additions & 0 deletions docs/develop/java/workers/interceptors.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
id: interceptors
title: Interceptors - Java SDK
sidebar_label: Interceptors
description:
Implement Interceptors in the Temporal Java SDK to manage inbound and outbound SDK calls, enhance tracing, and add
authorization to your Workflows and Activities.
toc_max_heading_level: 3
tags:
- Interceptors
- Java SDK
- Temporal SDKs
---

Interceptors wrap inbound and outbound Temporal calls so you can apply shared behavior such as tracing, logging, or
authorization. See [Interceptors](/encyclopedia/interceptors) for the inbound vs outbound model.

Register them on the Client (`WorkflowClientOptions.setInterceptors`) or the Worker Factory
(`WorkerFactoryOptions.setWorkerInterceptors`). Extend `WorkflowClientInterceptorBase` / `WorkerInterceptorBase` and
Comment on lines +18 to +19
override only the methods you need. Full API:
[`io.temporal.common.interceptors`](https://www.javadoc.io/doc/io.temporal/temporal-sdk/latest/io/temporal/common/interceptors/package-summary.html).
Comment on lines +20 to +21

Several interceptor APIs are marked `@Experimental`.

:::warning Workflow interceptors and replay

Workflow interceptor methods also run during [replay](/develop/java/best-practices/testing-suite#replay). Use replay-safe
APIs for logging, randomness, and time.

:::

## Related

- [Observability - Tracing](/develop/java/platform/observability#tracing)
- [Error handling - Worker Interceptor](/develop/java/best-practices/error-handling#centralize-with-interceptor)
- [Spring Boot - Interceptors](/develop/java/integrations/spring-boot-integration#interceptors)
- [Plugins - Interceptors](/develop/plugins-guide#interceptors)
2 changes: 1 addition & 1 deletion docs/develop/plugins-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ Note that you can use an existing Data Converter such as, in Python, `PydanticPa

### Interceptors

Interceptors are middleware that can run before and after various calls such as Activities, Workflows, and Signals. You can [learn more about interceptors](/develop/python/workers/interceptors) for the details of implementing them. They're used to:
Interceptors are middleware that can run before and after various calls such as Activities, Workflows, and Signals. You can [learn more about interceptors](/encyclopedia/interceptors) for the details of implementing them. They're used to:

- Create side effects such as logging and tracing.
- Modify arguments, such as adding headers for authorization or tracing propagation.
Expand Down
2 changes: 2 additions & 0 deletions docs/encyclopedia/interceptors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Common use cases:

Here are SDK-specific guides:

- [Go](/develop/go/workers/interceptors)
- [Java](/develop/java/workers/interceptors)
- [Python](/develop/python/workers/interceptors)
- [TypeScript](/develop/typescript/workers/interceptors)
- [.NET](/develop/dotnet/workers/interceptors)
2 changes: 2 additions & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ const developGoCategory = {
items: [
'develop/go/workers/run-worker-process',
'develop/go/workers/sessions',
'develop/go/workers/interceptors',
{
type: 'category',
label: 'Serverless Workers',
Expand Down Expand Up @@ -356,6 +357,7 @@ const developJavaCategory = {
},
items: [
'develop/java/workers/run-worker-process',
'develop/java/workers/interceptors',
{
type: 'category',
label: 'Serverless Workers',
Expand Down