Skip to content

Added the option to disconnect ContinueAsNew traces #1972

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bincyber
Copy link

@bincyber bincyber commented Jun 16, 2025

What was changed

Added two new options to the Tracing interceptor and support in the OpenTelemetry implementation:

  1. DisconnectContinueAsNewWorkflows - setting this to true will create a new root span for any workflows that are ContinueAsNew
  2. EnableSpanLinks - setting this to true will create a span link to connect the new root span to the parent span

This change is backwards compatible with these two new options defaulting to false.

Why?

Slack context: https://temporalio.slack.com/archives/CTDTU3J4T/p1702921125553459

Currently, when tracing is enabled on a workflow that ends as ContinueAsNew, the new workflow is attached to the existing trace:

Screenshot 1

Screenshot 2

The total number of spans can become extremely large and overwhelm the tracing backend (eg, Grafana Tempo, Jaeger, etc.).

Instead, it would be nice if the new workflow was created as a new, disconnected trace and linked to the existing trace:

Screenshot 3
Screenshot 4

This idea can be extended to disconnecting Child Workflows as well.

Checklist

  1. How was this tested:

Create the Temporal worker with the tracing interceptor and enable EnableSpanLinks and DisconnectContinueAsNewWorkflows:

tracingInterceptor, err := opentelemetry.NewTracingInterceptor(opentelemetry.TracerOptions{
	EnableSpanLinks:                  true,
	DisconnectContinueAsNewWorkflows: true,
})
if err != nil {
	// handle the error
}

w := worker.New(temporalClient, "example", worker.Options{
	Interceptors:                       []interceptor.WorkerInterceptor{
		tracingInterceptor,
	},
})

I don't currently use DataDog, so I have not been able to test this change on the DataDog tracing interceptor.

@bincyber bincyber requested a review from a team as a code owner June 16, 2025 11:56
@CLAassistant
Copy link

CLAassistant commented Jun 16, 2025

CLA assistant check
All committers have signed the CLA.

@Quinn-With-Two-Ns
Copy link
Contributor

Hey @bincyber thanks for the contribution. Before I start reviewing the implementation we need to first design the API. Did you look at other SDKs open telemetry interceptor or our data dog interceptor for how they support this case? We need to be consistent across our SDKs and tracing interceptors. Generally we would discuss the design in a github issue before we dive into an implementation, but we can do the design on the github issue as well if you prefer

@bincyber
Copy link
Author

Hey @bincyber thanks for the contribution. Before I start reviewing the implementation we need to first design the API. Did you look at other SDKs open telemetry interceptor or our data dog interceptor for how they support this case? We need to be consistent across our SDKs and tracing interceptors. Generally we would discuss the design in a github issue before we dive into an implementation, but we can do the design on the github issue as well if you prefer

Let's discuss the design in a GitHub issue. I've created on here: #1976

@bincyber bincyber marked this pull request as draft June 17, 2025 13:00
Comment on lines +44 to +45
// EnableSpanLinks can be set to enable span links for spans disconnected from their parent span.
EnableSpanLinks bool
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be an additional option? It seems like span links (an otel-specific feature?) could be added automatically if the disconnect continue as new workflows option is set.

Copy link
Author

Choose a reason for hiding this comment

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

I preferred to make this the default, but decided not to for backwards compatibility. Adding links results in additional tracing data which may increase costs depending on your observability vendor

TIL DataDog's SDKs also support span links: https://docs.datadoghq.com/tracing/trace_collection/span_links/

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.

4 participants